/* ============================================================================
   FIFO Inventory — Linear-inspired design system (dark)
   Tokens: near-black surfaces, 1px hairlines, one violet accent, Inter.
   ========================================================================== */

:root {
  --bg: #0e0f11;            /* app background */
  --bg-sidebar: #0b0c0d;    /* chrome */
  --bg-panel: #16171a;      /* cards, inputs */
  --bg-panel-2: #1c1d21;    /* hover / raised */
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f7f8f8;
  --text-2: #9ca0a8;
  --text-3: #6b7078;
  --accent: #5e6ad2;
  --accent-hover: #6e79d8;
  --accent-soft: rgba(94, 106, 210, 0.16);
  --green: #4cb782;
  --orange: #fc7840;
  --yellow: #f2c94c;
  --red: #eb5757;
  --radius: 6px;
  --font: "Inter Variable", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: "cv01", "ss03";
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
h1, h2, h3 { letter-spacing: -0.014em; font-weight: 538; }
::selection { background: rgba(94, 106, 210, 0.4); }

/* ---------------------------------------------------------------------------
   Shell
--------------------------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 9px; padding: 2px 6px 8px; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 6px;
  background: linear-gradient(135deg, #5e6ad2, #7b86e0);
  display: grid; place-items: center; color: #fff; flex: 0 0 24px;
}
.brand-name { font-weight: 620; font-size: 13.5px; letter-spacing: -0.008em; }
.brand-sub { font-size: 11px; color: var(--text-3); }

nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group-label {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: none; letter-spacing: 0.01em;
  padding: 10px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: var(--radius);
  color: var(--text-2); font-size: 13.5px; font-weight: 480;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: #c9cdf3; }
.nav-item svg { opacity: 0.85; }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 10px; display: flex; flex-direction: column; gap: 8px;
  font-size: 12px; color: var(--text-3);
}

.org-switcher select {
  width: 100%; padding: 6px 8px; border-radius: var(--radius);
  background: var(--bg-panel); border: 1px solid var(--border);
  color: var(--text); font-size: 12.5px; cursor: pointer;
}
.org-switcher select:hover { border-color: var(--border-strong); }

.user-box { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-email { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; padding: 0 28px 48px; }

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; padding: 22px 0 14px;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 560; letter-spacing: -0.017em; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.subtitle { margin: 2px 0 0; color: var(--text-2); font-size: 13px; }

/* ---------------------------------------------------------------------------
   Cards & stats
--------------------------------------------------------------------------- */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 13.5px; font-weight: 560; color: var(--text); }
.card-actions { display: flex; gap: 8px; align-items: center; }
.card-body { padding: 14px; }

.grid-stats { display: grid; gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 14px;
}
.stat-label { font-size: 11.5px; color: var(--text-3); margin-bottom: 3px; }
.stat-value { font-size: 22px; font-weight: 560; letter-spacing: -0.017em; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
   Tables
--------------------------------------------------------------------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3);
  padding: 7px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-panel); z-index: 1;
  white-space: nowrap;
}
.tbl td { padding: 7px 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.tbl .num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
   Buttons
--------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--radius);
  background: var(--bg-panel-2); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 13px; font-weight: 510; font-family: var(--font);
  cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #232428; border-color: rgba(255, 255, 255, 0.18); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: rgba(235, 87, 87, 0.08); }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

/* ---------------------------------------------------------------------------
   Forms
--------------------------------------------------------------------------- */
.field { display: block; margin-bottom: 0; }
.field-label { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field-hint { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font); font-size: 13px; padding: 6px 9px;
}
input:hover, select:hover, textarea:hover { border-color: rgba(255, 255, 255, 0.2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="date"] { color-scheme: dark; }
select { cursor: pointer; }
textarea { resize: vertical; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.panel-form { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.panel-form .form-row { margin-bottom: 0; }

/* ---------------------------------------------------------------------------
   Badges, statuses, flashes
--------------------------------------------------------------------------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 4px;
  background: var(--bg-panel-2); border: 1px solid var(--border); color: var(--text-2);
}
.badge-sale { color: #c9cdf3; background: var(--accent-soft); border-color: rgba(94, 106, 210, 0.3); }
.badge-purchase_receipt, .badge-purchase { color: #7ad3a4; background: rgba(76, 183, 130, 0.12); border-color: rgba(76, 183, 130, 0.3); }
.badge-adjustment, .badge-transfer { color: #e8a866; background: rgba(252, 120, 64, 0.1); border-color: rgba(252, 120, 64, 0.28); }
.badge-assembly, .badge-landed_cost { color: #9bd0f5; background: rgba(91, 157, 213, 0.12); border-color: rgba(91, 157, 213, 0.3); }
.badge-customer_return, .badge-return_to_supplier { color: #d0a8f5; background: rgba(158, 119, 213, 0.12); border-color: rgba(158, 119, 213, 0.3); }
.badge-disassembly, .badge-other { color: var(--text-2); }

.status {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 1px 8px; border-radius: 999px;
}
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-posted { color: var(--green); background: rgba(76, 183, 130, 0.1); }
.status-pending { color: var(--orange); background: rgba(252, 120, 64, 0.1); }
.status-pushed_draft { color: var(--yellow); background: rgba(242, 201, 76, 0.1); }
.status-failed { color: var(--red); background: rgba(235, 87, 87, 0.1); }
.status-edited_in_xero { color: var(--text-2); background: var(--bg-panel-2); }

.flash { padding: 9px 13px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; border: 1px solid; }
.flash-ok { background: rgba(76, 183, 130, 0.08); border-color: rgba(76, 183, 130, 0.35); color: #a8e0c4; }
.flash-err { background: rgba(235, 87, 87, 0.08); border-color: rgba(235, 87, 87, 0.35); color: #f5b5b5; }

.chip-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.muted { color: var(--text-3); }
td.muted, .num.muted { color: var(--text-3); }

.empty { padding: 28px; text-align: center; color: var(--text-3); }
.empty p { margin: 0 0 12px; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 13px; }
.kv .k { color: var(--text-3); }

/* Checklist (dashboard setup) */
.checklist .step { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.checklist .step:last-child { border-bottom: none; }
.checklist .step.done { color: var(--text-3); }
.checklist .step.done .btn { opacity: 0.55; }

/* Admin tabs */
.admin-tabs { display: flex; gap: 2px; margin-bottom: 16px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 3px; width: fit-content; }
.admin-tab { padding: 5px 14px; border-radius: 5px; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.admin-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.admin-tab.active { background: var(--accent); color: #fff; }

/* ---------------------------------------------------------------------------
   Auth screens
--------------------------------------------------------------------------- */
.auth-body {
  display: grid; place-items: center; min-height: 100vh;
  background: var(--bg-sidebar);
}
.auth-card {
  width: min(380px, 92vw);
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 30px 28px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}
.auth-card h1 { margin: 0 0 4px; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.auth-card .subtitle { margin: 0 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.auth-form .btn { justify-content: center; padding: 8px 12px; }

/* ---------------------------------------------------------------------------
   Landing
--------------------------------------------------------------------------- */
.land-body { background: var(--bg); }
.land { max-width: 1000px; margin: 0 auto; padding: 0 24px 90px; }
.land-nav { display: flex; justify-content: space-between; align-items: center; padding: 20px 0; }
.land-brand { font-weight: 750; letter-spacing: -0.02em; font-size: 16px; color: var(--text); }
.land-brand span { color: var(--accent); }
.land-hero { padding: 76px 0 54px; max-width: 660px; }
.land-hero h1 { font-size: 48px; line-height: 1.05; letter-spacing: -0.035em; font-weight: 750; margin: 0 0 20px; }
.land-hero p { font-size: 17.5px; line-height: 1.6; color: var(--text-2); margin: 0 0 30px; }
.land-cta { display: flex; gap: 12px; }
.land-cta .btn { padding: 8px 16px; font-size: 13.5px; }
.land-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 30px 0; }
.land-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.land-card h3 { margin: 0 0 8px; font-size: 14px; font-weight: 650; }
.land-card p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.land-steps { counter-reset: step; margin-top: 44px; }
.land-step { display: flex; gap: 18px; padding: 16px 0; border-top: 1px solid var(--border); }
.land-step::before { counter-increment: step; content: counter(step, decimal-leading-zero); font-weight: 700; color: var(--accent); font-size: 13px; padding-top: 2px; }
.land-step div { font-size: 14px; line-height: 1.6; color: var(--text-2); }
.land-step strong { color: var(--text); }
.land-foot { margin-top: 70px; padding-top: 18px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); }
@media (max-width: 760px) { .land-grid { grid-template-columns: 1fr; } .land-hero h1 { font-size: 36px; } .shell { flex-direction: column; } .sidebar { width: 100%; flex: none; height: auto; position: static; } }

/* auth inputs fill the card */
.auth-form input { width: 100%; }

/* ---------------------------------------------------------------------------
   Dashboard density: stat sub-metrics, timeline, attention feed, quick actions
--------------------------------------------------------------------------- */
.stat .sub { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-3); margin-top: 6px; }
.stat .bar { height: 3px; border-radius: 2px; background: rgba(255,255,255,.07); margin-top: 7px; overflow: hidden; }
.stat .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.stat .bar i.g { background: var(--green); }
.stat .bar i.o { background: var(--orange); }

.two-col { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

.card-head .count { font-size: 11px; color: var(--text-3); background: var(--bg-panel-2); border: 1px solid var(--border); padding: 0 7px; border-radius: 999px; }

.timeline { position: relative; padding-left: 16px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: rgba(255,255,255,.08); }
.tl-item { position: relative; padding: 6px 0 10px; }
.tl-item::before { content: ""; position: absolute; left: -15.5px; top: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--bg-panel); }
.tl-item.warn::before { background: var(--orange); }
.tl-item .tl-head { display: flex; gap: 8px; align-items: center; margin-bottom: 2px; }
.tl-item .tl-when { margin-left: auto; font-size: 11px; color: var(--text-3); }

.attention-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.04); font-size: 12.5px; }
.attention-item:last-child { border-bottom: none; }
.attention-item .a-ic { flex: 0 0 22px; height: 22px; border-radius: 5px; display: grid; place-items: center; background: rgba(252,120,64,.12); color: var(--orange); font-weight: 700; font-size: 12px; }
.attention-item .a-ic.red { background: rgba(235,87,87,.12); color: var(--red); }
