/* Tivexi Return Center: "control room" theme. Dark by default, matching light theme. */
:root {
  --bg: #0b0e15;
  --bg-glow: radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, .16), transparent 60%),
             radial-gradient(900px 500px at 110% 0%, rgba(34, 211, 238, .10), transparent 55%);
  --surface: #121722;
  --surface-2: #171d2a;
  --raised: #1d2433;
  --line: #262e3f;
  --line-strong: #344057;
  --text: #e8ecf4;
  --muted: #8c96ab;
  --faint: #5d677c;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-grad: linear-gradient(135deg, #7c5cff 0%, #4f8bff 55%, #22d3ee 100%);
  --accent-soft: rgba(124, 92, 255, .14);
  --accent-text: #fff;
  --ok: #34d399; --ok-bg: rgba(52, 211, 153, .12); --ok-line: rgba(52, 211, 153, .35);
  --bad: #fb7185; --bad-bg: rgba(251, 113, 133, .12); --bad-line: rgba(251, 113, 133, .38);
  --warn: #fbbf24; --warn-bg: rgba(251, 191, 36, .12); --warn-line: rgba(251, 191, 36, .38);
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 32px -12px rgba(0, 0, 0, .6);
  --glass: rgba(11, 14, 21, .72);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f4f8;
    --bg-glow: radial-gradient(1200px 600px at 10% -10%, rgba(124, 92, 255, .10), transparent 60%),
               radial-gradient(900px 500px at 110% 0%, rgba(34, 211, 238, .08), transparent 55%);
    --surface: #ffffff; --surface-2: #f7f8fb; --raised: #eef0f6;
    --line: #e3e6ef; --line-strong: #cfd4e2;
    --text: #121621; --muted: #5d6578; --faint: #8b93a6;
    --accent: #6a46ff; --accent-soft: rgba(106, 70, 255, .10);
    --ok: #059669; --ok-bg: #e8f8f1; --ok-line: #a7e3cb;
    --bad: #e11d48; --bad-bg: #fdecef; --bad-line: #f6b4c2;
    --warn: #b45309; --warn-bg: #fff6e5; --warn-line: #f5d38f;
    --shadow: 0 1px 2px rgba(18, 22, 33, .05), 0 10px 28px -14px rgba(18, 22, 33, .18);
    --glass: rgba(255, 255, 255, .78);
    color-scheme: light;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font: 16px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  background: var(--bg-glow), var(--bg); background-attachment: fixed;
  color: var(--text); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
@media (prefers-color-scheme: light) { a { color: var(--accent); } }
h2 { margin: 0 0 6px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
h3 { letter-spacing: -.01em; }
.sub { color: var(--muted); margin: 0 0 18px; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Icons (CSS masks, inherit text colour) ---------- */
.ico, [data-camera]::before, .banner::before, .modal-icon::before {
  display: inline-block; width: 18px; height: 18px; flex: none; background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat;
}
.ico.big { width: 40px; height: 40px; }
.ico-scan { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 7V5a2 2 0 0 1 2-2h2M17 3h2a2 2 0 0 1 2 2v2M21 17v2a2 2 0 0 1-2 2h-2M7 21H5a2 2 0 0 1-2-2v-2M7 8v8M11 8v8M14 8v8M17 8v8'/%3E%3C/svg%3E"); }
.ico-history { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 1 0 3-6.7L3 8'/%3E%3Cpath d='M3 3v5h5M12 7v5l3 2'/%3E%3C/svg%3E"); }
.ico-box { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M21 8 12 3 3 8v8l9 5 9-5z'/%3E%3Cpath d='m3 8 9 5 9-5M12 13v8'/%3E%3C/svg%3E"); }
.ico-plug { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M9 2v5M15 2v5M6 7h12v4a6 6 0 0 1-12 0zM12 17v5'/%3E%3C/svg%3E"); }
.ico-camera, [data-camera]::before { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M3 8a2 2 0 0 1 2-2h2l2-3h6l2 3h2a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3Ccircle cx='12' cy='13' r='4'/%3E%3C/svg%3E"); }
.ico-plus { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); width: 26px; height: 26px; }
.ico-logout { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9'/%3E%3C/svg%3E"); }
.banner.ok::before { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m8 12 3 3 5-6'/%3E%3C/svg%3E"); }
.banner.warn::before, .modal-icon::before { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0zM12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.banner.bad::before { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m15 9-6 6M9 9l6 6'/%3E%3C/svg%3E"); }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
  padding: 12px max(16px, calc((100vw - 1180px) / 2));
  background: var(--glass); backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.logo {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-grad); color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 6px 18px -6px rgba(124, 92, 255, .8);
}
.wordmark { display: flex; flex-direction: column; line-height: 1.05; font-size: 17px; letter-spacing: -.02em; }
.wordmark small { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
nav { display: flex; gap: 2px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; scrollbar-width: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  border: 0; background: none; color: var(--muted); padding: 8px 14px; border-radius: 10px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: color .15s, background .15s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tab.active .ico { color: var(--accent-2); }
@media (prefers-color-scheme: light) { .tab.active .ico { color: var(--accent); } }
.integrations { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--line);
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.pill.live i { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg), 0 0 10px var(--ok); }
.pill.demo i { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.pill.off { opacity: .6; }
.userbox { display: flex; align-items: center; gap: 8px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--raised); border: 1px solid var(--line-strong); font-weight: 700; font-size: 13px; }
.user-name { font-size: 14px; font-weight: 600; }

/* ---------- Layout ---------- */
main { max-width: 780px; margin: 0 auto; padding: 22px 16px 60px; }
main:has(#view-fba:not([hidden])) { max-width: 1180px; }
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .input { flex: 1; min-width: 200px; }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.actions .btn { flex: 1; }

/* ---------- Stepper ---------- */
.stepper { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 16px; overflow-x: auto; scrollbar-width: none; counter-reset: step; }
.stepper li {
  flex: 1; min-width: 86px; font-size: 12px; font-weight: 600; color: var(--faint);
  padding-top: 10px; position: relative; white-space: nowrap;
}
.stepper li::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; border-radius: 4px; background: var(--line); }
.stepper li.done { color: var(--muted); }
.stepper li.done::before { background: var(--ok); opacity: .8; }
.stepper li.current { color: var(--text); }
.stepper li.current::before { background: var(--accent-grad); box-shadow: 0 0 14px rgba(124, 92, 255, .7); }

/* ---------- Inputs & buttons ---------- */
.input {
  width: 100%; font: inherit; font-size: 20px; padding: 15px 16px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
#scan-input, #item-input, #fba-scan, #fba-code { font-family: var(--mono); letter-spacing: .02em; }
.input::placeholder { color: var(--faint); font-family: Inter, sans-serif; letter-spacing: 0; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input.small { font-size: 15px; padding: 11px 13px; }
textarea.input { font-size: 15px; min-height: 76px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 700; padding: 13px 20px; min-height: 50px;
  border-radius: var(--radius-sm); border: 0; cursor: pointer; text-decoration: none !important;
  background: var(--accent-grad); color: #fff;
  box-shadow: 0 8px 22px -10px rgba(124, 92, 255, .9), inset 0 1px 0 rgba(255, 255, 255, .18);
  transition: transform .08s, filter .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.secondary, .btn.ghost {
  background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong);
}
.btn.secondary:hover, .btn.ghost:hover { filter: none; box-shadow: inset 0 0 0 1px var(--faint); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 6px 10px; }
.btn.danger { background: linear-gradient(135deg, #f43f5e, #e11d48); box-shadow: 0 8px 22px -10px rgba(244, 63, 94, .9); }
.btn:disabled, .btn.disabled { opacity: .4; cursor: default; filter: grayscale(.3); pointer-events: none; box-shadow: none; }
.btn.block { width: 100%; }
[data-camera]::before { content: ""; }
label.btn { cursor: pointer; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.chip {
  font: inherit; font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 99px; cursor: pointer;
  color: var(--muted); background: transparent; border: 1px dashed var(--line-strong);
}
.chip:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Data display ---------- */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; margin: 16px 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; word-break: break-word; }
.order-link { font-size: 22px; font-weight: 800; font-family: var(--mono); letter-spacing: -.01em; }
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 7px; color: #fff; letter-spacing: .02em; }
.badge.Amazon { background: #ff9900; color: #111; } .badge.eBay { background: #0064d2; } .badge.Walmart { background: #0071ce; }
.badge:not(.Amazon):not(.eBay):not(.Walmart) { background: var(--raised); color: var(--muted); }
.items { border: 1px solid var(--line); border-radius: 12px; margin-top: 8px; overflow: hidden; background: var(--bg); }
.items div { padding: 12px 14px; border-top: 1px solid var(--line); }
.items div:first-child { border-top: 0; }
.items small { color: var(--muted); display: block; margin-top: 2px; font-size: 13px; }
code, .kv dd:has(> a[href*="track"]) { font-family: var(--mono); }

.banner {
  position: relative; padding: 14px 16px 14px 48px; border-radius: 12px; margin: 14px 0;
  font-weight: 700; border: 1px solid transparent;
}
.banner::before { content: ""; position: absolute; left: 16px; top: 15px; width: 20px; height: 20px; }
.banner small { display: block; font-weight: 500; margin-top: 3px; opacity: .9; }
.banner.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.banner.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }

.status { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.status.match { background: var(--ok-bg); color: var(--ok); }
.status.mismatch { background: var(--bad-bg); color: var(--bad); }
.status.unknown { background: var(--warn-bg); color: var(--warn); }
.status.scam { background: var(--bad); color: #fff; }
.ok-text { color: var(--ok); }

/* ---------- Photos ---------- */
.photo-box {
  display: grid; place-items: center; min-height: 260px; overflow: hidden; cursor: pointer; text-align: center;
  border: 2px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted);
  background: repeating-linear-gradient(135deg, transparent 0 14px, rgba(255, 255, 255, .015) 14px 28px), var(--bg);
  transition: border-color .15s, color .15s;
}
.photo-box:hover { border-color: var(--accent); color: var(--text); }
.photo-box img { max-width: 100%; max-height: 440px; display: block; }
.photo-empty { display: grid; justify-items: center; gap: 10px; font-weight: 600; }
.photo-empty .ico { color: var(--accent-2); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; transition: transform .2s; }
.thumb img:hover { transform: scale(1.04); }
.thumb.add {
  display: grid; place-content: center; justify-items: center; gap: 6px; text-align: center; cursor: pointer;
  border: 2px dashed var(--line-strong); color: var(--muted); font-size: 12px; font-weight: 600;
}
.thumb.add:hover { border-color: var(--accent); color: var(--text); }
.thumb-x { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; backdrop-filter: blur(4px); }
.thumb-label { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 8px 6px; font-size: 11px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(0, 0, 0, .78)); }

/* ---------- Condition picker ---------- */
.conditions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.cond {
  text-align: left; padding: 15px 18px; border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--text); transition: border-color .15s, background .15s;
}
.cond:hover { border-color: var(--line-strong); }
.cond.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Unit banner, modal ---------- */
.unit-banner {
  background: var(--accent-grad); color: #fff; border-radius: 14px; padding: 14px 18px; margin-bottom: 18px;
  font-size: 22px; font-weight: 800; letter-spacing: -.01em; box-shadow: 0 12px 30px -14px rgba(124, 92, 255, .9);
}
.unit-banner small { display: block; font-size: 13px; font-weight: 500; opacity: .9; letter-spacing: 0; }
.unit-banner.package { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); font-size: 16px; }
.modal { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 16px; background: rgba(4, 6, 12, .7); backdrop-filter: blur(6px); }
.modal-box {
  width: min(500px, 100%); max-height: 90vh; overflow: auto; padding: 26px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--warn-line); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7), 0 0 0 6px var(--warn-bg);
  animation: pop .18s ease-out;
}
.modal-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--warn-bg); color: var(--warn); margin-bottom: 12px; }
.modal-icon::before { content: ""; width: 28px; height: 28px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- History ---------- */
.history-item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; cursor: pointer;
  padding: 12px; margin: 0 -12px; border-radius: 12px; border-top: 1px solid var(--line);
}
.history-item:hover { background: var(--raised); }
.history-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: var(--raised); }
.history-item .meta { font-size: 13px; color: var(--muted); }
#history-list { margin-top: 12px; }
.detail-section { margin-top: 24px; }
.detail-section h3 { font-size: 12px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.unit-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--bg); }
.unit-card h3 { color: var(--text) !important; }

/* ---------- Small actions & links ---------- */
.small-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 22px; padding-top: 14px; border-top: 1px dashed var(--line-strong); }
.link-btn { background: none; border: 0; padding: 6px 0; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { color: var(--text); }
.link-btn.danger-text { color: var(--bad); }
.link-btn.armed { text-decoration: none; border: 1.5px solid var(--bad); background: var(--bad-bg); border-radius: 10px; padding: 10px 14px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px var(--bad-bg); } }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 0; }

/* ---------- Connections ---------- */
.conn-list { display: grid; gap: 14px; }
.conn-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.conn-head h2 { margin: 0; font-size: 20px; }
.conn details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.conn summary { cursor: pointer; font-weight: 700; }
.conn label:not(.btn):not(.thumb) { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
.conn .hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.conn code { font-size: 12px; background: var(--bg); border: 1px solid var(--line); padding: 2px 6px; border-radius: 6px; word-break: break-all; user-select: all; }

/* ---------- FBA ---------- */
.subtabs { display: flex; gap: 4px; margin-bottom: 16px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.subtab { flex: 1; border: 0; background: none; color: var(--muted); padding: 11px; border-radius: 10px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.subtab:hover { color: var(--text); }
.subtab.active { background: var(--accent-grad); color: #fff; box-shadow: 0 8px 20px -10px rgba(124, 92, 255, .9); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat {
  text-align: left; font: inherit; color: var(--text); cursor: pointer; padding: 16px 18px; border-radius: 16px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: border-color .15s, transform .1s;
}
.stat:hover { border-color: var(--line-strong); }
.stat b { display: block; font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat span { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.stat.active b { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat.delivered { border-color: var(--warn-line); }
.stat.delivered b { color: var(--warn); }
.stat.delivered.active { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg), var(--shadow); }
.stat.delivered.active b { background: none; color: var(--warn); }
.table-wrap { overflow-x: auto; margin-top: 14px; }
.pkg-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.pkg-table th { text-align: left; font-size: 11px; color: var(--faint); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 10px; border-bottom: 1px solid var(--line); }
.pkg-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; word-break: break-word; }
.pkg-table tbody tr:hover td { background: var(--raised); }
.pkg-table td a { font-family: var(--mono); font-size: 13px; }
.pkg-table tr.done td { opacity: .55; }
.pkg-table tr.attention td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

/* ---------- Overlays ---------- */
.scanner { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(4, 6, 12, .9); backdrop-filter: blur(6px); }
.scanner-inner { width: min(540px, 100%); display: grid; gap: 12px; }
#scanner-video { background: #000; border-radius: 16px; overflow: hidden; min-height: 280px; box-shadow: 0 0 0 1px var(--line-strong), 0 0 40px rgba(124, 92, 255, .35); }
.lightbox { position: fixed; inset: 0; z-index: 30; display: grid; grid-template-rows: auto 1fr; padding: 14px; background: rgba(4, 6, 12, .95); }
.lightbox-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: #fff; font-weight: 600; }
.lightbox-bar a, .lightbox-bar button { color: #fff; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 90px); margin: auto; object-fit: contain; border-radius: 8px; }
.spinner { width: 30px; height: 30px; margin: 22px auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-page main { max-width: 420px; padding-top: 14vh; }
.login-page .card { padding: 30px; }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 10px 12px; }
  .wordmark small { display: none; }
  nav { order: 3; width: 100%; }
  .tab { flex: 1; justify-content: center; padding: 9px 8px; font-size: 13px; }
  .integrations { margin-left: auto; }
  .pill { padding: 4px 8px; font-size: 11px; }
  .user-name { display: none; }
  main { padding: 16px 12px 48px; }
  .card { padding: 18px; }
  .pkg-table thead { display: none; }
  .pkg-table, .pkg-table tbody, .pkg-table tr, .pkg-table td { display: block; width: 100%; }
  .pkg-table tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  .pkg-table td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
  .pkg-table td::before { content: attr(data-label); color: var(--faint); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
}
@media (max-width: 560px) {
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 10px; }
  .tab span:not(.ico) { display: none; }
  .tab .ico { width: 20px; height: 20px; }
  .tab.active span:not(.ico) { display: inline; }
  /* Steps: bars only, with the current step's name on its (wider) bar. */
  .stepper li { min-width: 0; font-size: 0; }
  .stepper li.current { flex: 4; font-size: 12px; }
  /* Connection status: dots only, full text on long-press / hover. */
  .integrations { gap: 4px; }
  .pill { font-size: 0; padding: 7px; gap: 0; border-radius: 50%; }
  .pill i { width: 8px; height: 8px; }
  .row > .input { min-width: 0; }
  #scan-input, #item-input, #fba-scan, #fba-code { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* ---------- Brand logo (white artwork; darkened in light mode) ---------- */
.brand { gap: 12px; }
.brand-logo { height: 26px; width: auto; display: block; filter: drop-shadow(0 2px 10px rgba(124, 92, 255, .45)); }
.brand-sub {
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
  padding-left: 12px; border-left: 1px solid var(--line-strong); line-height: 1.2;
}
.login-page .brand-logo { height: 34px; }
@media (prefers-color-scheme: light) { .brand-logo { filter: invert(1) brightness(.12); } }
@media (max-width: 560px) { .brand-logo { height: 22px; } .brand-sub { display: none; } }
