:root {
  --ink: #100908;
  --surface: #1e1613;
  --surface-2: #261c18;
  --ivory: #f1eae0;
  --ivory-dim: #cabfb0;
  --muted: #9a8f82;
  --gold: #dcb87a;
  --gold-dim: #a98c5c;
  --red: #b70404;
  --red-soft: #ff8a7a;
  --green: #8fcf9a;
  --amber: #f0c060;
  --hairline: rgba(220, 184, 122, 0.22);
  --hairline-soft: rgba(220, 184, 122, 0.12);
  --font-serif: 'Bodoni Moda', 'Times New Roman', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--ivory); }
body { font: 14px/1.45 var(--font-ui); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 40px);
  background: rgba(16, 9, 8, 0.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.mark { font-family: var(--font-serif); font-weight: 700; font-size: 12px; letter-spacing: .18em; color: var(--gold); white-space: nowrap; }
.mark span { font-family: var(--font-ui); font-weight: 600; letter-spacing: .12em; color: var(--muted); margin-left: 6px; text-transform: uppercase; font-size: 11px; }
.mark:hover { text-decoration: none; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 7px 14px; border-radius: 999px; color: var(--ivory-dim); font-weight: 600; font-size: 13px; }
.tabs a:hover { background: var(--surface); text-decoration: none; }
.tabs a.on { background: var(--surface-2); color: var(--gold); box-shadow: inset 0 0 0 1px var(--hairline); }
.who { margin-left: auto; display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 13px; }

main { padding: 24px clamp(16px, 3vw, 40px) 60px; max-width: 1400px; margin: 0 auto; }
h1 { font-family: var(--font-serif); font-weight: 600; font-size: 26px; margin: 0 0 4px; letter-spacing: .01em; }
h2 { font-family: var(--font-serif); font-weight: 600; font-size: 18px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 20px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--gold-dim);
  background: transparent; color: var(--gold); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: rgba(220, 184, 122, .08); }
.btn.solid { background: var(--gold); color: #2a1a0c; border-color: var(--gold); }
.btn.solid:hover { background: #e8c88e; }
.btn.small { padding: 4px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--gold); cursor: pointer; font-size: inherit; }
.link:hover { text-decoration: underline; }

input[type=text], input[type=email], input[type=search], input[type=date], select {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 10px;
  padding: 8px 12px; min-height: 38px; color: var(--ivory);
}
input:focus, select:focus, .btn:focus-visible, .link:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input::placeholder { color: var(--muted); }
select { padding-right: 28px; }
input[type=date] { color-scheme: dark; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.toolbar .grow { flex: 1 1 220px; min-width: 180px; }
.toolbar .spacer { flex: 1; }

/* ---------- stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: 14px; padding: 14px 16px; }
.stat .label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.stat .value { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .note { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.warn { border-color: rgba(240, 192, 96, .45); }
.stat.warn .value { color: var(--amber); }

.banner {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 12px 16px; border-radius: 12px; margin-bottom: 18px;
  background: rgba(240, 192, 96, .08); border: 1px solid rgba(240, 192, 96, .35); color: var(--ivory);
}
.banner.err { background: rgba(183, 4, 4, .14); border-color: rgba(255, 138, 122, .45); }
.banner.ok { background: rgba(143, 207, 154, .08); border-color: rgba(143, 207, 154, .35); }

.syncline { color: var(--muted); font-size: 12.5px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: -6px 0 18px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--hairline-soft); border-radius: 14px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--hairline-soft); }
th { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(220, 184, 122, .035); }
td .small { color: var(--muted); font-size: 12px; }
td.nowrap { white-space: nowrap; }
.cust-name { font-weight: 600; color: var(--ivory); }
.cust-name:hover { color: var(--gold); }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.count { color: var(--muted); font-size: 12.5px; margin: 10px 2px 0; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.b-ok { color: var(--green); background: rgba(143, 207, 154, .1); border-color: rgba(143, 207, 154, .25); }
.b-warn { color: var(--amber); background: rgba(240, 192, 96, .1); border-color: rgba(240, 192, 96, .3); }
.b-bad { color: var(--red-soft); background: rgba(183, 4, 4, .16); border-color: rgba(255, 138, 122, .3); }
.b-dim { color: var(--ivory-dim); background: rgba(202, 191, 176, .08); border-color: rgba(202, 191, 176, .2); }
.b-gold { color: var(--gold); background: rgba(220, 184, 122, .08); border-color: var(--hairline); }
.method { font-size: 12px; font-weight: 600; color: var(--ivory-dim); }

/* ---------- customer profile ---------- */
.back { display: inline-block; margin-bottom: 14px; font-size: 13px; }
.profile-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.profile-head .links { display: flex; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--hairline); font-size: 13px; }
.chip.refunded { text-decoration: line-through; color: var(--muted); }
.timeline { display: grid; gap: 14px; }
.order-card { background: var(--surface); border: 1px solid var(--hairline-soft); border-radius: 14px; padding: 16px 18px; }
.order-card.attn { border-color: rgba(240, 192, 96, .45); }
.order-card header { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 10px; }
.order-card .when { font-weight: 600; }
.order-card .oid { color: var(--muted); font-size: 12px; font-family: ui-monospace, Consolas, monospace; }
.order-card .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.lines { width: 100%; border-collapse: collapse; }
.lines td { padding: 5px 0; border: 0; }
.lines tr.sum td { color: var(--muted); font-size: 13px; }
.lines tr.total td { font-weight: 700; border-top: 1px solid var(--hairline-soft); padding-top: 8px; }
.lines tr.refund td { color: var(--red-soft); }
.deliv { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--hairline-soft); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ivory-dim); }
.deliv .err { color: var(--amber); }

/* ---------- login ---------- */
.login { max-width: 400px; margin: 12vh auto 0; text-align: center; }
.login .mark { display: block; margin-bottom: 28px; }
.login form { display: grid; gap: 12px; margin-top: 22px; }
.login input { text-align: center; min-height: 46px; font-size: 15px; }
.login .btn { justify-content: center; min-height: 46px; font-size: 14px; }
.login .msg { min-height: 20px; color: var(--ivory-dim); font-size: 13.5px; }
.login .msg.err { color: var(--red-soft); }

/* ---------- team ---------- */
.team-list { max-width: 640px; }
.team-add { display: flex; gap: 10px; max-width: 640px; margin-bottom: 18px; }
.team-add input { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--hairline); padding: 10px 18px; border-radius: 999px;
  transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.loading { color: var(--muted); padding: 40px 0; text-align: center; }

@media (max-width: 720px) {
  .who-email { display: none; }
  .stat .value { font-size: 20px; }
  th, td { padding: 9px 10px; }
  .order-card .right { margin-left: 0; }
}
