/* Order Desk
   Palette: ink #15202b, slate #eceff2, marine #0a5c7a. Hanken Grotesk for the interface,
   JetBrains Mono only for identifiers (order ids, tracking numbers, the address label). */

@font-face { font-family: "Hanken Grotesk"; font-weight: 400; font-display: swap; src: url("/fonts/hanken-grotesk-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-weight: 500; font-display: swap; src: url("/fonts/hanken-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-weight: 600; font-display: swap; src: url("/fonts/hanken-grotesk-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-weight: 700; font-display: swap; src: url("/fonts/hanken-grotesk-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url("/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url("/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }

:root {
  --ink: #15202b;
  --muted: #5b6978;
  --line: #d6dce3;
  --line-strong: #b9c2cc;
  --bg: #eceff2;
  --surface: #ffffff;
  --row-hover: #f3f6f9;
  --accent: #0a5c7a;
  --accent-strong: #08485f;
  --accent-soft: #dcecf3;
  --warn-bg: #fbeec9;
  --warn-ink: #6b4300;
  --info-bg: #dbeaf5;
  --info-ink: #0b4a6b;
  --ok-bg: #d9efe0;
  --ok-ink: #17582f;
  --bad-bg: #f9e0dd;
  --bad-ink: #a3281d;
  --neutral-bg: #e4e8ec;
  --radius: 6px;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr-copy { position: fixed; left: -9999px; top: 0; opacity: 0; }
.no-scroll { overflow: hidden; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Buttons and fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: default; border-color: var(--line-strong); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-primary:disabled:hover { background: var(--accent); border-color: var(--accent); }
.btn-small { min-height: 30px; padding: 3px 10px; font-size: 14px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--accent); }
.btn-quiet:hover { background: var(--accent-soft); border-color: transparent; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface);
}
textarea { min-height: 84px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }

.error-text { color: var(--bad-ink); font-weight: 500; }
.notice { padding: 10px 12px; border-radius: var(--radius); background: var(--info-bg); color: var(--info-ink); }
.notice-error { background: var(--bad-bg); color: var(--bad-ink); }

/* ---------- Sign in ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: min(400px, 100%); padding: 28px 26px 26px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.auth-card h1 { font-size: 24px; letter-spacing: -0.01em; }
.auth-card .sub { margin: 4px 0 18px; color: var(--muted); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 18px; background: var(--bg); border-radius: var(--radius); }
.auth-tabs button { border: 0; border-radius: 4px; padding: 7px; background: transparent; font-weight: 600; color: var(--muted); cursor: pointer; }
.auth-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.auth-form { display: grid; gap: 14px; }
.auth-form .btn { width: 100%; }
.auth-card .notice { margin-bottom: 14px; }

/* ---------- Shell ---------- */
.topbar { background: var(--ink); color: #fff; }
.topbar-inner { max-width: 1360px; margin: 0 auto; padding: 0 20px; height: 54px; display: flex; align-items: center; gap: 28px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #c4cfda; text-decoration: none; padding: 6px 12px; border-radius: var(--radius); font-weight: 600; }
.nav a:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,0.16); }
.whoami { display: flex; align-items: center; gap: 12px; color: #c4cfda; font-size: 14px; }
.whoami .btn { min-height: 30px; padding: 2px 10px; font-size: 14px; background: transparent; color: #fff; border-color: rgba(255,255,255,0.35); }
.whoami .btn:hover { border-color: #fff; }
.page { max-width: 1360px; margin: 0 auto; padding: 20px; }

/* ---------- Orders: tabs and filters ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tab {
  display: inline-flex; align-items: baseline; gap: 8px;
  padding: 8px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-weight: 600;
}
.tab:hover { border-color: var(--ink); }
.tab .count { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tab[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.filters {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; align-items: end;
  padding: 14px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.filters .field-wide { grid-column: span 2; }
.filters-actions { display: flex; gap: 8px; }

/* ---------- Orders table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table-wrap.is-loading { opacity: 0.6; transition: opacity 0.15s; }
table.orders { width: 100%; border-collapse: collapse; }
table.orders th {
  position: sticky; top: 0; padding: 10px 12px; text-align: left; white-space: nowrap;
  font-size: 13px; font-weight: 600; color: var(--muted);
  background: #f7f9fb; border-bottom: 1px solid var(--line);
}
table.orders th.num { text-align: right; }
table.orders td { padding: 10px 12px; vertical-align: top; border-bottom: 1px solid var(--line); }
table.orders tbody tr:last-child td { border-bottom: 0; }
table.orders tbody tr { cursor: pointer; }
table.orders tbody tr:hover { background: var(--row-hover); }
table.orders tbody tr.is-selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 13px; color: var(--muted); }
.cell-title { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--neutral-bg); color: var(--ink);
}
.chip-warn { background: var(--warn-bg); color: var(--warn-ink); }
.chip-info { background: var(--info-bg); color: var(--info-ink); }
.chip-ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip-bad { background: var(--bad-bg); color: var(--bad-ink); }

.empty { padding: 48px 20px; text-align: center; }
.empty-title { font-size: 17px; font-weight: 600; margin-bottom: 4px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; color: var(--muted); }
.pager-buttons { display: flex; gap: 8px; }

/* ---------- Drawer ---------- */
.drawer-host { position: fixed; inset: 0; z-index: 20; }
.backdrop { position: absolute; inset: 0; background: rgba(21, 32, 43, 0.4); }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(580px, 100vw);
  background: var(--bg); overflow-y: auto; outline: none;
  box-shadow: -10px 0 30px rgba(21, 32, 43, 0.18);
  animation: drawer-in 0.18s ease-out;
}
@keyframes drawer-in { from { transform: translateX(28px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.drawer-head .grow { flex: 1; min-width: 0; }
.drawer-head h2 { font-size: 19px; overflow-wrap: anywhere; }
.drawer-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 14px; color: var(--muted); margin-top: 2px; }
.icon-btn { width: 34px; height: 34px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-size: 18px; line-height: 1; }
.icon-btn:hover { border-color: var(--ink); }
.drawer-body { display: grid; gap: 14px; padding: 16px 18px 28px; }
.pad { padding: 24px 18px; }

.panel { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > h3 { font-size: 15px; margin-bottom: 10px; }

/* The ship-to card is styled like a parcel label: a dashed cut line around the address. */
.label { padding: 14px 16px 16px; background: var(--surface); border: 2px dashed var(--ink); border-radius: 8px; }
.label-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.label-head h3 { font-size: 15px; }
.label address { display: grid; gap: 1px; font-style: normal; font-family: var(--mono); font-size: 14.5px; line-height: 1.5; }
.label .label-name { font-weight: 500; font-size: 16px; }
.label .label-foot { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; color: var(--muted); }
.label .btn-primary { min-height: 40px; padding: 8px 18px; }

.item { padding: 10px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 0; }
.item:last-child { padding-bottom: 0; }
.item-title { font-weight: 600; }
.item-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 2px 0 8px; font-size: 14px; color: var(--muted); }
.amazon-form { display: grid; grid-template-columns: 1fr 130px auto; gap: 8px; align-items: end; }
.amazon-form input { font-family: var(--mono); font-size: 14px; }
.items { list-style: none; margin: 0; padding: 0; }

.ship-done { font-weight: 600; color: var(--ok-ink); }
.ship-line { margin: 2px 0 10px; font-size: 14px; }
.ship-form { display: grid; gap: 10px; }
.ship-form .row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.ship-form .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ship-form input { font-family: var(--mono); font-size: 14px; }
.ship-error { margin-bottom: 10px; }
details.resend > summary { cursor: pointer; font-weight: 600; color: var(--accent); margin-bottom: 10px; }

.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; }
.totals .grand { font-weight: 700; }

/* ---------- Users ---------- */
.users-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.users-head h1 { font-size: 20px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
table.users { width: 100%; border-collapse: collapse; }
table.users th, table.users td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.users th { font-size: 13px; color: var(--muted); background: #f7f9fb; }
table.users tr:last-child td { border-bottom: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40;
  max-width: min(520px, calc(100vw - 32px)); padding: 10px 16px; border-radius: var(--radius);
  background: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 6px 24px rgba(21, 32, 43, 0.3);
}
.toast-error { background: var(--bad-ink); }

/* ---------- Narrow screens ---------- */
@media (max-width: 1080px) {
  .col-tracking, .col-amazon { display: none; }
}
@media (max-width: 820px) {
  .col-items { display: none; }
  .filters .field-wide { grid-column: auto; }
  .topbar-inner { gap: 12px; padding: 0 12px; }
  .whoami .who-name { display: none; }
  .page { padding: 12px; }
  .amazon-form { grid-template-columns: 1fr; }
  .ship-form .row { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .drawer { animation: none; }
  .table-wrap.is-loading { transition: none; }
}

.chip-group { display: inline-flex; flex-wrap: wrap; gap: 4px; }
