:root {
  --bg: #0b1120;
  --panel: #111a2e;
  --panel-2: #16223c;
  --line: #243049;
  --ink: #e6edf7;
  --muted: #8aa0c2;
  --muted-2: #5f7596;
  --accent: #38bdf8;
  --accent-ink: #04293b;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 80% -10%, #14233f 0%, var(--bg) 55%) fixed;
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

button { font: inherit; cursor: pointer; }
input, button, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------- auth screens ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; box-shadow: var(--shadow);
}
.brandmark { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brandmark .logo {
  width: 34px; height: 34px; border-radius: 9px; background: #0f172a;
  display: grid; place-items: center;
}
.brandmark h1 { font-size: 16px; margin: 0; letter-spacing: .2px; }
.brandmark .sub { font-size: 11px; color: var(--muted-2); margin-top: 1px; letter-spacing: .4px; text-transform: uppercase; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 12px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; outline: none; transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }
.btn {
  width: 100%; padding: 11px 14px; border: 0; border-radius: 10px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); transition: filter .15s, opacity .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); width: auto; padding: 8px 12px; font-weight: 500; }
.btn-ghost:hover { background: var(--panel-2); filter: none; }
.btn-sm { width: auto; padding: 7px 12px; border-radius: 8px; font-size: 13px; }
.note { font-size: 12.5px; color: var(--muted); margin-top: 14px; }
.err { background: rgba(248,113,113,.12); border: 1px solid rgba(248,113,113,.4); color: #fecaca; padding: 9px 11px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; }
.ok { background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.4); color: #bbf7d0; padding: 9px 11px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; }

.secret-box { background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 12px; margin: 12px 0; }
.secret-box code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: 1px; word-break: break-all; color: var(--accent); }
.backup-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.backup-codes code { background: var(--bg); border: 1px solid var(--line); padding: 7px; border-radius: 7px; text-align: center; font-family: ui-monospace, monospace; }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: rgba(11,17,32,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brandmark { margin: 0; }
.topbar .spacer { flex: 1; }
.who { font-size: 12.5px; color: var(--muted); }
.shell { max-width: 1200px; margin: 0 auto; padding: 20px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .n { font-size: 28px; font-weight: 700; line-height: 1.1; }
.kpi .l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.kpi.warn .n { color: var(--warn); }
.kpi.bad .n { color: var(--bad); }
.kpi.good .n { color: var(--good); }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 9px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.tab.active { background: var(--panel-2); color: var(--ink); border-color: var(--accent); }
.tab .badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 999px; background: var(--line); color: var(--ink); font-size: 11px; text-align: center; }
.tab.active .badge { background: var(--accent); color: var(--accent-ink); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 14px; margin: 0; }
.panel-head .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted-2); font-weight: 600; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--panel-2); cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
.ref { font-family: ui-monospace, monospace; color: var(--accent); font-weight: 600; }
.dim { color: var(--muted); }
.right { text-align: right; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted-2); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line); }
.pill.paid { color: var(--accent); border-color: rgba(56,189,248,.45); }
.pill.packing { color: var(--warn); border-color: rgba(251,191,36,.45); }
.pill.shipped, .pill.delivered, .pill.out_for_delivery { color: var(--good); border-color: rgba(52,211,153,.45); }
.pill.late { color: var(--bad); border-color: rgba(248,113,113,.5); background: rgba(248,113,113,.08); }

/* ---------- drawer (order detail) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(2,6,16,.6); backdrop-filter: blur(2px); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(540px, 100%); z-index: 50;
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; animation: slidein .18s ease;
}
@keyframes slidein { from { transform: translateX(20px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { padding: 18px 20px; overflow: auto; flex: 1; }
.x { margin-left: auto; background: transparent; border: 0; color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 6px; }
.x:hover { color: var(--ink); }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; margin: 4px 0 16px; }
.kv dt { color: var(--muted-2); font-size: 12px; }
.kv dd { margin: 0; }
.sec-title { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted-2); margin: 18px 0 8px; }
.line-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 9px; background: var(--bg); border: 1px solid var(--line); flex: none; }
.line-item .ph { width: 56px; height: 56px; border-radius: 9px; background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted-2); font-size: 10px; flex: none; }
.line-item .meta { font-size: 12.5px; color: var(--muted); }
.tag { display: inline-block; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: 11.5px; margin: 2px 4px 0 0; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field textarea { width: 100%; min-height: 110px; padding: 11px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; outline: none; resize: vertical; font-family: ui-monospace, monospace; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.muted-row { font-size: 12px; color: var(--muted-2); margin-top: 8px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80; padding: 11px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); }
.toast.ok { background: #064e3b; color: #bbf7d0; border: 1px solid #10b981; }
.toast.err { background: #4c0519; color: #fecaca; border: 1px solid #f43f5e; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=date], .toolbar select { padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }

@media (max-width: 720px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  th.hide-sm, td.hide-sm { display: none; }
}
