/* Layout: left sidebar (logo, nav, pilot card) + main column; on phones the sidebar becomes a sticky top bar.
   Look: Nexvora StockView 2026 deck, deep navy with teal glow, single dark theme by design. */
:root {
  --bg: #06111f; --bg-glow: rgba(35, 213, 196, .10); --side: rgba(5, 14, 27, .92);
  --surface: #0c1d33; --surface-2: #10263f; --sunk: #091829; --line: #1b3956; --line-teal: rgba(47, 227, 207, .30);
  --ink: #eaf4fb; --muted: #8fa8be;
  --accent: #2fe3cf; --accent-2: #1f8fd6; --accent-soft: rgba(47, 227, 207, .12); --on-accent: #032421; --blue: #60a5fa;
  --ok: #34d399; --ok-soft: rgba(52, 211, 153, .14); --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .14);
  --crit: #f87171; --crit-soft: rgba(248, 113, 113, .14); --idle: #a78bfa; --idle-soft: rgba(167, 139, 250, .16);
  --f-display: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  color: var(--ink); font: 15px/1.5 var(--f-body);
  background:
    radial-gradient(900px 520px at 85% -8%, var(--bg-glow), transparent 70%),
    radial-gradient(700px 480px at 20% 108%, rgba(31, 143, 214, .10), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; }
h1 em, h2 em { font-style: normal; color: var(--accent); }
h2 { font-size: 1.02rem; font-weight: 700; }
.num, td.n, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); font-size: .86em; }
.eyebrow { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* App shell */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 16px; background: var(--side); border-right: 1px solid var(--line); }
.brand { border: 0; background: none; padding: 0 6px; cursor: pointer; display: grid; gap: 6px; text-align: left; }
.logo { width: 150px; height: auto; display: block; }
.product { font-family: var(--f-display); font-weight: 800; font-size: 1.15rem; letter-spacing: .01em; }
.product span { color: var(--accent); }
.tabs { display: flex; flex-direction: column; gap: 4px; }
.tab { display: flex; align-items: center; gap: 12px; border: 0; background: none; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; cursor: pointer; text-align: left; white-space: nowrap; }
.tab:hover { color: var(--ink); background: rgba(255, 255, 255, .04); }
.tab[aria-selected="true"] { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--line-teal); font-weight: 600; }
.tab .count { margin-left: auto; font-size: .72rem; padding: 0 7px; border-radius: 99px; background: var(--crit-soft); color: var(--crit); font-weight: 700; }
.pilot { margin-top: auto; padding: 16px; border-radius: 12px; background: linear-gradient(160deg, rgba(47, 227, 207, .14), rgba(31, 143, 214, .08)); border: 1px solid var(--line-teal); display: grid; gap: 8px; }
.pilot strong { font-family: var(--f-display); font-size: .98rem; line-height: 1.3; }
.pilot .eyebrow { color: var(--accent); }
.side-foot { font-size: .75rem; color: var(--muted); padding-inline: 6px; }

.maincol { min-width: 0; padding: 26px 32px 60px; display: grid; gap: 22px; align-content: start; }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.top h1 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.company { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; padding: 8px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); }
.company strong { font-weight: 600; }
.chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.chip.sample { background: var(--accent-soft); color: var(--accent); }
main { display: grid; gap: 22px; min-width: 0; }

@media (max-width: 900px) {
  .app { display: block; }
  .side { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; height: auto; flex-direction: column; gap: 10px; padding: 12px 16px 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { display: flex; align-items: center; gap: 10px; padding: 0; }
  .logo { width: 112px; }
  .product { font-size: 1rem; }
  .tabs { flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 4px; margin-inline: -4px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 8px 12px; gap: 8px; font-size: .9rem; }
  .tab svg.i { width: 16px; height: 16px; }
  .pilot, .side-foot { display: none; }
  .maincol { padding: 18px 16px 48px; gap: 16px; }
  .top { align-items: flex-start; gap: 10px; }
  input, select { font-size: 16px; } /* stops phones zooming into fields */
  .company { padding: 6px 12px; gap: 8px; }
  .company .eyebrow { display: none; }
}

/* Panels and KPIs */
.view { display: grid; gap: 18px; }
.panel { background: linear-gradient(180deg, rgba(16, 38, 63, .92), rgba(12, 29, 51, .92)); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head p { margin: 0; color: var(--muted); font-size: .85rem; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
#orderKpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1240px) and (min-width: 701px) { #kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } #kpis > .kpi { grid-column: span 2; } #kpis > .kpi:nth-child(n+4) { grid-column: span 3; } }
@media (max-width: 700px) { .kpis, #orderKpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; } }
.kpi { position: relative; background: linear-gradient(180deg, rgba(18, 44, 70, .9), rgba(11, 27, 47, .9)); border: 1px solid var(--line-teal); border-radius: var(--r); padding: 16px; display: grid; gap: 4px; min-width: 0; box-shadow: 0 0 28px rgba(47, 227, 207, .06), inset 0 1px 0 rgba(255, 255, 255, .04); }
.kpi .ic { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line-teal); background: rgba(47, 227, 207, .08); display: grid; place-items: center; color: var(--accent); margin-bottom: 8px; }
.kpi .v { white-space: nowrap; font-family: var(--f-display); font-size: clamp(1.4rem, 2.2vw, 1.85rem); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--ink); }
.kpi.crit .v { color: var(--crit); } .kpi.warn .v { color: var(--warn); } .kpi.idle .v { color: var(--idle); }
.kpi .l { font-weight: 600; font-size: .9rem; color: var(--ink); }
.kpi .s { font-size: .8rem; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-2b { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .grid-2, .grid-2b { grid-template-columns: minmax(0, 1fr); } }
.chart-box { position: relative; height: 260px; }
.chart-box.short { height: 200px; }

/* Alerts */
.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 470px; overflow-y: auto; }
.alert { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px 10px 0; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.alert .stripe { align-self: stretch; }
.alert.crit .stripe { background: var(--crit); } .alert.warn .stripe { background: var(--warn); } .alert.idle .stripe { background: var(--idle); }
.alert .t { font-weight: 600; font-size: .9rem; overflow-wrap: anywhere; }
.alert .d { font-size: .8rem; color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--surface-2); padding: 7px 13px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .85rem; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: linear-gradient(90deg, var(--accent), #22c3e6); border-color: transparent; color: var(--on-accent); box-shadow: 0 0 18px rgba(47, 227, 207, .25); }
.btn.primary:hover { filter: brightness(1.08); color: var(--on-accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* Pills */
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); } .pill.idle { background: var(--idle-soft); color: var(--idle); }
.pill.info { background: var(--accent-soft); color: var(--accent); } .pill.none { background: transparent; color: var(--muted); border: 1px solid var(--line); }

/* Tables */
.tbl-wrap { overflow-x: auto; margin-inline: -4px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: rgba(255, 255, 255, .02); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover td { background: rgba(47, 227, 207, .04); }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; white-space: nowrap; }
td .sub { display: block; font-size: .78rem; color: var(--muted); }
#invTbl td:first-child, #fastTbl td:first-child, #deadTbl td:first-child, #moveTbl td:nth-child(2) { min-width: 170px; }
.cover { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.cover-bar { width: 54px; height: 6px; border-radius: 3px; background: var(--sunk); border: 1px solid var(--line); overflow: hidden; }
.cover-bar i { display: block; height: 100%; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--accent); }

/* Filters and forms */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: .78rem; color: var(--muted); font-weight: 600; }
input[type="search"], input[type="text"], input[type="number"], select { background: var(--sunk); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.filters input[type="search"] { width: min(320px, 100%); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--sunk); }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: .85rem; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.form { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: minmax(0, 1fr); } }
.form input, .form select { width: 100%; }
.hint { font-size: .8rem; color: var(--muted); margin: 0; }
.err { font-size: .82rem; color: var(--crit); margin: 0; min-height: 1.2em; }
.mv-toggle { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mv-btn { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--sunk); color: var(--muted); cursor: pointer; text-align: left; min-width: 0; }
.mv-btn svg { width: 28px; height: 28px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.mv-btn b { display: block; font-family: var(--f-display); font-size: 1rem; color: var(--ink); white-space: nowrap; }
@media (max-width: 480px) { .mv-btn { padding: 12px 10px; gap: 8px; } .mv-btn svg { width: 22px; height: 22px; } .mv-btn b { font-size: .95rem; } }
.mv-btn small { display: block; font-size: .78rem; color: var(--muted); }
.mv-btn.in[aria-pressed="true"] { background: linear-gradient(135deg, rgba(52, 211, 153, .22), rgba(47, 227, 207, .10)); border-color: var(--ok); color: var(--ok); }
.mv-btn.out[aria-pressed="true"] { background: linear-gradient(135deg, rgba(96, 165, 250, .22), rgba(31, 143, 214, .10)); border-color: var(--blue); color: var(--blue); }
.stepper { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--sunk); }
.stepper button { border: 0; background: var(--surface-2); color: var(--accent); font-size: 1.4rem; font-weight: 600; cursor: pointer; }
.stepper button:active { background: var(--accent-soft); }
.form .stepper input { border: 0; border-radius: 0; text-align: center; font-family: var(--f-display); font-size: 1.3rem; font-weight: 700; padding: 10px 4px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.btn.big { width: 100%; padding: 13px; font-size: 1rem; border-radius: 12px; }
.item-row { display: flex; gap: 12px; align-items: center; min-width: 0; }
.item-row .ic { width: 40px; height: 40px; border-radius: 10px; background: rgba(251, 191, 36, .12); color: var(--warn); display: grid; place-items: center; flex: none; }
.item-card { background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 4px; font-size: .88rem; }

/* Upload */
.drop { border: 2px dashed var(--line-teal); border-radius: var(--r); padding: 30px 18px; text-align: center; background: rgba(47, 227, 207, .04); display: grid; gap: 8px; justify-items: center; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { font-family: var(--f-display); font-size: 1.08rem; }
.cols { display: flex; flex-wrap: wrap; gap: 6px; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.map-grid select { width: 100%; }
.steps { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; color: var(--muted); font-size: .9rem; }
.steps b { color: var(--ink); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-teal); padding: 10px 16px; border-radius: 10px; font-weight: 500; font-size: .9rem; z-index: 20; max-width: calc(100% - 32px); box-shadow: 0 0 24px rgba(47, 227, 207, .18); }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: .9rem; }
.foot { color: var(--muted); font-size: .8rem; padding-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.linkbtn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; font-size: inherit; }
@media (prefers-reduced-motion: no-preference) { .toast { animation: rise .2s ease-out; } @keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } } }

/* ---------- App additions: sign-in screens, dialogs, team ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: linear-gradient(180deg, rgba(16, 38, 63, .95), rgba(12, 29, 51, .95)); border: 1px solid var(--line-teal); border-radius: 18px; padding: 28px 24px; display: grid; gap: 16px; box-shadow: 0 0 40px rgba(47, 227, 207, .10); }
.auth-card .logo { width: 150px; }
.auth-card h1 { font-size: 1.5rem; font-weight: 800; }
.auth-card p { margin: 0; color: var(--muted); font-size: .9rem; }
.auth-card form { display: grid; gap: 12px; }
.auth-card input { width: 100%; }
.auth-switch { text-align: center; font-size: .88rem; color: var(--muted); }
.userbox { display: grid; gap: 4px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, .03); border: 1px solid var(--line); font-size: .82rem; }
.userbox strong { font-size: .9rem; }
.dialog-back { position: fixed; inset: 0; background: rgba(2, 8, 16, .7); display: grid; place-items: center; padding: 16px; z-index: 30; }
.dialog { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line-teal); border-radius: 16px; padding: 20px; display: grid; gap: 14px; }
.dialog .actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: var(--f-mono); font-size: .8rem; }
.empty-state { padding: 28px 16px; text-align: center; display: grid; gap: 10px; justify-items: center; color: var(--muted); }
.empty-state strong { color: var(--ink); font-family: var(--f-display); font-size: 1.05rem; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
td .linkbtn { font-size: .82rem; }
@media (max-width: 900px) { .userbox { display: none; } }
/* Stock movement selector: In / Out / Count / Transfer */
.mv-toggle { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mv-btn { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--sunk); color: var(--muted); cursor: pointer; text-align: left; min-width: 0; }
.mv-btn svg { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.mv-btn b { display: block; font-family: var(--f-display); font-size: .98rem; color: var(--ink); white-space: nowrap; }
.mv-btn small { display: block; font-size: .76rem; color: var(--muted); }
.mv-btn.in[aria-pressed="true"] { background: linear-gradient(135deg, rgba(52, 211, 153, .22), rgba(47, 227, 207, .10)); border-color: var(--ok); color: var(--ok); }
.mv-btn.out[aria-pressed="true"] { background: linear-gradient(135deg, rgba(96, 165, 250, .22), rgba(31, 143, 214, .10)); border-color: var(--blue); color: var(--blue); }
.mv-btn.count[aria-pressed="true"] { background: rgba(251, 191, 36, .14); border-color: var(--warn); color: var(--warn); }
.mv-btn.transfer[aria-pressed="true"] { background: rgba(167, 139, 250, .16); border-color: var(--idle); color: var(--idle); }
.stepper { display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--sunk); }
.stepper button { border: 0; background: var(--surface-2); color: var(--accent); font-size: 1.4rem; font-weight: 600; cursor: pointer; }
.form .stepper input { border: 0; border-radius: 0; text-align: center; font-family: var(--f-display); font-size: 1.3rem; font-weight: 700; padding: 10px 4px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.btn.big { width: 100%; padding: 13px; font-size: 1rem; border-radius: 12px; }
.item-row { display: flex; gap: 12px; align-items: center; min-width: 0; }
.item-row .ic { width: 40px; height: 40px; border-radius: 10px; background: rgba(251, 191, 36, .12); color: var(--warn); display: grid; place-items: center; flex: none; }
@media (max-width: 900px) { input, select { font-size: 16px; } }
