/* 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 { margin-top: auto; 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; } }

/* ---------- Account button ---------- */
.acctBtn { display: inline-flex; align-items: center; gap: 8px; border-radius: 99px; padding: 6px 12px; }
@media (max-width: 900px) { .acctBtn span { display: none; } .acctBtn { padding: 6px 9px; } }
.themeGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.themeOpt { border: 2px solid var(--line); border-radius: 12px; padding: 10px; background: var(--sunk); cursor: pointer; display: grid; gap: 8px; text-align: left; color: var(--ink); font-weight: 600; }
.themeOpt[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.themeOpt .sw { height: 34px; border-radius: 8px; display: flex; overflow: hidden; border: 1px solid #0003; }
.themeOpt .sw i { flex: 1; }
.permList { display: grid; gap: 8px; }
.permList label, .whList label { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.permList input, .whList input { margin-top: 3px; }
.whList { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--sunk); }

/* ---------- Themes (each user picks one; Nexvora is the default above) ---------- */
.panel, .kpi { background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.btn.primary { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
html[data-sv-theme="light"] {
  --bg: #f3f6fa; --bg-glow: rgba(14, 159, 148, .08); --side: rgba(255, 255, 255, .96);
  --surface: #ffffff; --surface-2: #f8fafc; --sunk: #f2f5f9; --line: #d8e0ea; --line-teal: rgba(14, 159, 148, .35);
  --ink: #102030; --muted: #586a7d;
  --accent: #0b8f86; --accent-2: #1d6fd1; --accent-soft: rgba(11, 143, 134, .12); --on-accent: #ffffff; --blue: #2563eb;
  --ok: #15803d; --ok-soft: rgba(21, 128, 61, .12); --warn: #b45309; --warn-soft: rgba(180, 83, 9, .12);
  --crit: #c2331f; --crit-soft: rgba(194, 51, 31, .1); --idle: #6d28d9; --idle-soft: rgba(109, 40, 217, .1);
  color-scheme: light;
}
html[data-sv-theme="light"] .panel, html[data-sv-theme="light"] .kpi { box-shadow: 0 6px 20px rgba(16, 32, 48, .06); }
html[data-sv-theme="light"] .kpi .v { color: var(--ink); }
html[data-sv-theme="ocean"] {
  --bg: #050d1c; --bg-glow: rgba(56, 189, 248, .12); --side: rgba(4, 11, 24, .94);
  --surface: #0a1a33; --surface-2: #0e2342; --sunk: #081529; --line: #1a3358; --line-teal: rgba(56, 189, 248, .32);
  --accent: #38bdf8; --accent-2: #6366f1; --accent-soft: rgba(56, 189, 248, .13); --on-accent: #04121f; --blue: #a5b4fc;
}
html[data-sv-theme="forest"] {
  --bg: #06120d; --bg-glow: rgba(74, 222, 128, .10); --side: rgba(5, 15, 11, .94);
  --surface: #0b1f17; --surface-2: #10291f; --sunk: #091a13; --line: #1c3d2e; --line-teal: rgba(74, 222, 128, .3);
  --accent: #4ade80; --accent-2: #14b8a6; --accent-soft: rgba(74, 222, 128, .12); --on-accent: #052012; --blue: #5eead4;
}
html[data-sv-theme="sunset"] {
  --bg: #140b0b; --bg-glow: rgba(251, 146, 60, .12); --side: rgba(18, 9, 9, .94);
  --surface: #221311; --surface-2: #2c1814; --sunk: #1b0f0d; --line: #45261f; --line-teal: rgba(251, 146, 60, .32);
  --accent: #fb923c; --accent-2: #f43f5e; --accent-soft: rgba(251, 146, 60, .13); --on-accent: #2a0d02; --blue: #fda4af;
}
.form .permList input, .form .whList input { width: auto; flex: none; }
.permList label span, .whList label span { color: var(--ink); font-weight: 500; font-size: .92rem; text-transform: none; letter-spacing: 0; }

/* ---------- Plan & subscription ---------- */
.chip.sample.warn { background: var(--warn-soft); color: var(--warn); }
.planBanner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: 12px; font-weight: 500; }
.planBanner.warn { background: var(--warn-soft); border: 1px solid var(--warn); }
.planBanner.crit { background: var(--crit-soft); border: 1px solid var(--crit); }
.planNow { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr); gap: 22px; align-items: center; }
.planNowName { display: grid; gap: 4px; }
.planName { font-family: var(--f-display); font-size: 1.6rem; font-weight: 800; }
.usageBox { display: grid; gap: 12px; }
.usage-top { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 5px; color: var(--muted); }
.usage-top b { color: var(--ink); }
.usage .bar { height: 8px; border-radius: 99px; background: var(--sunk); border: 1px solid var(--line); overflow: hidden; }
.usage .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.usage .bar i.full { background: var(--warn); }
.pendingNote { margin-top: 16px; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--line-teal); font-size: .88rem; }
.planGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.planCard { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 20px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--sunk); }
.planCard.pop { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.planCard .tag { position: absolute; top: -11px; left: 18px; padding: 2px 10px; border-radius: 99px; background: var(--accent); color: var(--bg, #06111f); font-size: .72rem; font-weight: 700; }
.planCard h3 { font-family: var(--f-display); font-size: 1.15rem; }
.priceRow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; }
.priceRow .price { font-family: var(--f-display); font-size: 1.7rem; font-weight: 800; }
.priceRow .price small { font-size: .8rem; font-weight: 600; color: var(--muted); }
.priceRow .per { color: var(--muted); }
.priceRow .hint { flex-basis: 100%; }
.planCard ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; font-size: .9rem; flex: 1; }
.planCard li { padding-left: 22px; position: relative; }
.planCard li::before { content: ""; position: absolute; left: 2px; top: .38em; width: 10px; height: 6px; border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(-45deg); }
.planCard .btn { width: 100%; justify-content: center; }
.form textarea { width: 100%; font: inherit; color: var(--ink); background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; resize: vertical; }
@media (max-width: 900px) {
  .planGrid, .planNow { grid-template-columns: 1fr; }
}

/* ---------- Orders (Pro) ---------- */
.proTag { margin-left: auto; font-size: .64rem; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 700; letter-spacing: .05em; }
.tab[aria-selected="true"] .proTag { background: var(--accent); color: var(--bg); }
#orderKpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, tr.clickable:focus td { background: var(--accent-soft); }
.dialog.wide { width: min(760px, 100%); }
.orderHead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.orderHead h2 { font-size: 1.3rem; margin-top: 2px; }
.orderMeta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--sunk); border: 1px solid var(--line); }
.orderMeta > div { display: grid; gap: 3px; min-width: 0; }
.orderMeta b { overflow-wrap: anywhere; }
.history summary { cursor: pointer; color: var(--muted); font-size: .85rem; font-weight: 600; }
.history ul { margin: 8px 0 0; padding-left: 1.1em; display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.oLineHead, .oLine { display: grid; grid-template-columns: minmax(0, 1fr) 90px 100px 28px; gap: 8px; align-items: center; }
.oLineHead { font-size: .74rem; color: var(--muted); font-weight: 600; }
#oLines { display: grid; gap: 8px; }
.oLine input { width: 100%; }
.oDel { font-size: 1.3rem; line-height: 1; color: var(--muted); }
.form:not(:has(.oPrice)) .oLineHead, .form:not(:has(.oPrice)) .oLine { grid-template-columns: minmax(0, 1fr) 90px 28px; }
input[type="date"], .form textarea { color-scheme: dark; }
html[data-sv-theme="light"] input[type="date"] { color-scheme: light; }
input[type="date"] { background: var(--sunk); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; min-width: 0; color: var(--ink); font: inherit; }
.empty-state .chip { justify-self: center; }
@media (max-width: 700px) {
  #orderKpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .orderMeta { grid-template-columns: minmax(0, 1fr); }
  .oLineHead { display: none; }
  .oLine, .form:not(:has(.oPrice)) .oLine { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 24px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .form:not(:has(.oPrice)) .oLine { grid-template-columns: minmax(0, 1fr) 24px; }
  .oLine .oItem { grid-column: 1 / -1; }
}
