* { box-sizing: border-box; }
:root {
  --bg: #f6f4f0;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e2da;
  --accent: #2c2623;
  --gold: #9a7449;
  --ok: #1f5c43;
  --warn: #b45309;
  --danger: #b91c1c;
}
body {
  margin: 0; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px;
}
.hidden { display: none !important; }

.auth-gate {
  position: fixed; inset: 0; background: rgba(28,25,23,0.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 999; padding: 16px;
}
.auth-card {
  background: var(--card); border-radius: 16px; padding: 28px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.auth-card h2, .auth-card h3 { margin: 0 0 10px; }
.auth-card p { color: var(--muted); font-size: 13px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; background: #1c1917; color: #f5f5f4; display: flex; flex-direction: column;
  padding: 20px 14px; flex-shrink: 0;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 6px 10px 22px; border-bottom: 1px solid #302b28; }
.logo-mark { color: #d6b286; font-size: 20px; }
.logo-title { font-weight: 700; font-size: 15px; }
.logo-sub { font-size: 11px; color: #a8a29e; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; flex: 1; }
.nav-btn {
  background: transparent; color: #d6d3d1; border: none; text-align: left; padding: 11px 12px;
  border-radius: 10px; cursor: pointer; font-size: 14px; transition: background 0.15s;
}
.nav-btn:hover { background: #292524; color: #fff; }
.nav-btn.active { background: #d6b286; color: #1c1917; font-weight: 600; }

.sidebar-foot { border-top: 1px solid #302b28; padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.status-pill { font-size: 12px; background: #292524; padding: 7px 10px; border-radius: 8px; color: #e7e5e4; }
.btn-link { background: none; border: none; color: #a8a29e; font-size: 12px; cursor: pointer; text-align: left; padding: 4px 2px; }
.btn-link:hover { color: #fff; }

.main { flex: 1; padding: 24px 28px; overflow-x: hidden; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.page-head h1 { margin: 0; font-size: 22px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card {
  background: var(--card); border-radius: 14px; padding: 16px 18px; border: 1px solid var(--line);
}
.kpi-card.danger { border-left: 4px solid var(--danger); }
.kpi-card.warn { border-left: 4px solid var(--warn); }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-val { font-size: 26px; font-weight: 700; margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1080px) { .grid-2, .sim-layout { grid-template-columns: 1fr !important; } }

.panel {
  background: var(--card); border-radius: 14px; padding: 18px 20px; border: 1px solid var(--line);
  margin-bottom: 16px;
}
.panel h3 { margin: 0 0 14px; font-size: 15px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid #f0ece6; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #f3f4f6; color: #4b5563; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.span-2 { grid-column: span 2; }
.form-actions { grid-column: span 2; display: flex; justify-content: flex-end; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #d6d3d1; border-radius: 9px; font-size: 13px;
  font-family: inherit; background: #fff;
}
input:focus, select:focus { outline: none; border-color: var(--gold); }

.btn-primary, .btn-secondary, .btn-danger, .btn-sm {
  border: none; border-radius: 9px; padding: 9px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #0c0a09; }
.btn-secondary { background: #efeae2; color: var(--ink); }
.btn-secondary:hover { background: #e3dcd0; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.action-group { display: flex; flex-wrap: wrap; gap: 6px; }
.inline-row { display: flex; gap: 8px; align-items: center; }
.inline-row input { flex: 1; }

.sim-layout { display: grid; grid-template-columns: 1.2fr 390px; gap: 20px; align-items: start; }
.json-box {
  background: #1c1917; color: #e7e5e4; padding: 14px; border-radius: 10px; font-size: 12px;
  overflow-x: auto; max-height: 300px; line-height: 1.45;
}
.phone-frame {
  background: #1c1917; border-radius: 34px; padding: 12px; box-shadow: 0 18px 40px rgba(0,0,0,0.18);
}
.phone-notch {
  text-align: center; color: #e7e5e4; font-size: 12px; padding: 6px 0 10px; font-weight: 600;
}
.phone-screen {
  background: #f7f4ef; border-radius: 24px; min-height: 580px; max-height: 660px; overflow-y: auto; padding: 14px;
}
.empty-phone { text-align: center; color: var(--muted); padding: 180px 20px; font-size: 13px; line-height: 1.7; }
.mp-card { background: #fff; border-radius: 14px; padding: 14px; margin-bottom: 12px; box-shadow: 0 4px 14px rgba(0,0,0,0.05); }
.mp-hero { width: 100%; height: 190px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; background: #eee; }
.hint { font-size: 12px; color: var(--muted); }
.qr-box { display: flex; justify-content: center; padding: 14px; background: #faf8f5; border-radius: 12px; margin: 12px 0; }
.guide-panel li { margin-bottom: 10px; line-height: 1.65; }
code { background: #f2ede6; padding: 2px 6px; border-radius: 5px; font-size: 12px; }
