/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --page: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fb; --sunken: #eef0f3;
  --ink: #111318; --ink-2: #4a4f5c; --muted: #7b8191; --line: #e4e6eb; --line-2: #d4d7de;
  --brand: #c8102e; --brand-2: #9e0c24; --brand-soft: #fde8eb; --brand-ink: #ffffff;
  --side: #14161c; --side-ink: #c9ccd4; --side-active: #ffffff; --side-hover: #1f222b;
  --link: #b00e28;
  --good: #0f8a3c; --good-soft: #e3f5ea; --good-mark: #0ca30c;
  --warn: #a85a00; --warn-soft: #fff1dc; --warn-mark: #f59e0b;
  --crit: #c42b2b; --crit-soft: #fde7e7; --crit-mark: #d03b3b;
  --info: #1f5fbf; --info-soft: #e7effc; --info-mark: #2a78d6;
  --neutral-soft: #eceef2;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0f13; --surface: #171a21; --surface-2: #1c2029; --sunken: #12151b;
    --ink: #eef0f4; --ink-2: #b9bfcc; --muted: #8a91a1; --line: #262b35; --line-2: #313744;
    --brand: #e8334f; --brand-2: #ff5a73; --brand-soft: #3a1219; --side: #0a0c10; --side-hover: #151821;
    --link: #ff7d91;
    --good: #3ccf6e; --good-soft: #10291a; --good-mark: #0ca30c;
    --warn: #ffb547; --warn-soft: #33230b; --warn-mark: #fab219;
    --crit: #ff6b6b; --crit-soft: #351414; --crit-mark: #e04848;
    --info: #79a8f0; --info-soft: #14233d; --info-mark: #3987e5;
    --neutral-soft: #222732;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0f13; --surface: #171a21; --surface-2: #1c2029; --sunken: #12151b;
  --ink: #eef0f4; --ink-2: #b9bfcc; --muted: #8a91a1; --line: #262b35; --line-2: #313744;
  --brand: #e8334f; --brand-2: #ff5a73; --brand-soft: #3a1219; --side: #0a0c10; --side-hover: #151821;
  --link: #ff7d91;
  --good: #3ccf6e; --good-soft: #10291a; --good-mark: #0ca30c;
  --warn: #ffb547; --warn-soft: #33230b; --warn-mark: #fab219;
  --crit: #ff6b6b; --crit-soft: #351414; --crit-mark: #e04848;
  --info: #79a8f0; --info-soft: #14233d; --info-mark: #3987e5;
  --neutral-soft: #222732;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--page); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
code { background: var(--sunken); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
h1 { font-size: 24px; letter-spacing: -.02em; margin: 0; font-weight: 750; }
h2 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: 13px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; }
.logo { display: flex; gap: 10px; align-items: center; padding: 4px 8px 10px; }
.logo-mark { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #e8334f, #9e0c24); color: #fff; display: grid; place-items: center; font-weight: 800; letter-spacing: .02em; box-shadow: 0 4px 14px rgba(232, 51, 79, .35); }
.logo-title { color: #fff; font-weight: 700; line-height: 1.15; }
.logo-sub { font-size: 12px; color: #8a8f9c; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--side-ink); font-weight: 500; text-decoration: none; }
.side nav a:hover { background: var(--side-hover); color: #fff; }
.side nav a.active { background: linear-gradient(90deg, rgba(232, 51, 79, .22), rgba(232, 51, 79, .06)); color: var(--side-active); box-shadow: inset 3px 0 0 #e8334f; }
.side nav a svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-count { margin-left: auto; background: #e8334f; color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.nav-count:empty { display: none; }
.nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5d6270; padding: 16px 12px 6px; }
.side-foot { margin-top: auto; font-size: 12px; color: #8a8f9c; padding: 12px; border-top: 1px solid #22252e; }
.side-foot b { color: #fff; font-weight: 600; }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 28px; background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.crumbs { font-weight: 600; color: var(--ink-2); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.mode-chip { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--info-soft); color: var(--info); white-space: nowrap; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 16px; padding: 0; }
.icon-btn.menu { display: none; }
.actor { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px 4px 3px 4px; }
.actor select { border: 0; background: transparent; padding: 6px 4px; max-width: 280px; font-weight: 500; }
.avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--brand-soft); color: var(--brand); flex: none; }
main { padding: 26px 28px 60px; max-width: 1360px; width: 100%; margin: 0 auto; }
.banner { margin: 16px 28px 0; background: var(--warn-soft); color: var(--warn); padding: 10px 14px; border-radius: 10px; font-weight: 600; border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); }
.loading { color: var(--muted); padding: 40px; text-align: center; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: var(--shadow-lg); }
  .icon-btn.menu { display: inline-block; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  main { padding: 18px 16px 48px; }
  .actor select { max-width: 170px; }
  .mode-chip { display: none; }
}

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card.flush { padding: 0; overflow: hidden; } .card.flush .card-head { padding: 16px 18px 0; }
.cols { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
.cols-3-2 { display: grid; gap: 18px; grid-template-columns: 3fr 2fr; }
@media (max-width: 1100px) { .cols, .cols-3-2 { grid-template-columns: 1fr; } }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .k-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.kpi .k-ico svg { width: 18px; height: 18px; }
.kpi .k-val { font-size: 30px; font-weight: 750; letter-spacing: -.03em; margin-top: 8px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.crit .k-ico { background: var(--crit-soft); color: var(--crit); }
.kpi.warn .k-ico { background: var(--warn-soft); color: var(--warn); }
.kpi.good .k-ico { background: var(--good-soft); color: var(--good); }
.kpi.info .k-ico { background: var(--info-soft); color: var(--info); }
.kpi.brand .k-ico { background: var(--brand-soft); color: var(--brand); }
.kpi.neutral .k-ico { background: var(--neutral-soft); color: var(--ink-2); }

/* ---------- status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--neutral-soft); color: var(--ink-2); white-space: nowrap; line-height: 1.6; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.GREEN, .pill.RECEIVED, .pill.RESOLVED, .pill.CLOSED, .pill.VERIFIED, .pill.CONNECTED, .pill.SUCCESS, .pill.FLEETX_TICKET_LINKED { background: var(--good-soft); color: var(--good); }
.pill.ORANGE, .pill.AWAITING_FLEETX_TICKET, .pill.PENDING_VERIFICATION, .pill.PARTIALLY_RECEIVED, .pill.WARNING { background: var(--warn-soft); color: var(--warn); }
.pill.RED, .pill.INTEGRATION_FAILED, .pill.ERROR, .pill.FAILED { background: var(--crit-soft); color: var(--crit); }
.pill.ASSIGNED, .pill.APPROVED, .pill.DISPATCHED, .pill.IN_TRANSIT, .pill.CENTRAL, .pill.OPEN, .pill.NOT_CONFIGURED, .pill.PENDING { background: var(--info-soft); color: var(--info); }
.pill.big { font-size: 13px; padding: 4px 12px; }

/* ---------- plant health bar ---------- */
.health { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--surface); }
.health > div { min-width: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- plant cards ---------- */
.plants { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.plant { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface-2); position: relative; }
.plant.RED { border-color: color-mix(in srgb, var(--crit) 45%, var(--line)); }
.plant.ORANGE { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.plant-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.plant-name { font-weight: 650; } .plant-code { font-size: 12px; color: var(--muted); }
.plant-stock { display: flex; align-items: baseline; gap: 6px; margin: 10px 0 8px; }
.plant-stock b { font-size: 26px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.gauge { position: relative; height: 10px; background: var(--sunken); border-radius: 5px; margin: 6px 0 4px; }
.gauge .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; }
.gauge .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 1px; }
.gauge-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.plant-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-2); font-size: 12.5px; flex-wrap: wrap; }

/* ---------- pipeline bars ---------- */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 34px; align-items: center; gap: 10px; font-size: 13px; cursor: default; }
.bar-row .lbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 12px; background: var(--sunken); border-radius: 0 4px 4px 0; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--info-mark); min-width: 2px; }
.bar-row .v { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.bar-row:hover .bar-fill { filter: brightness(1.12); }

/* ---------- activity feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .dot { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--sunken); color: var(--ink-2); font-size: 13px; }
.feed .what { font-weight: 550; } .feed .when { font-size: 12px; color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.empty { color: var(--muted); text-align: center; padding: 28px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------- forms & buttons ---------- */
button, .btn { font: inherit; font-weight: 550; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: background .12s, border-color .12s; }
button:hover, .btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
button.primary, .btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:hover, .btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
button.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
button.danger { color: var(--crit); }
button:disabled { opacity: .5; cursor: not-allowed; }
form.f { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; }
form.f label, .field { display: grid; gap: 5px; color: var(--ink-2); font-size: 12.5px; font-weight: 550; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--ink); width: 100%; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type=radio], input[type=checkbox] { width: auto; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; } .kv dd { margin: 0; font-weight: 500; }
details > summary { cursor: pointer; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details > summary::before { content: "＋"; color: var(--brand); font-weight: 700; }
details[open] > summary::before { content: "−"; }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.radio-card b { display: block; } .radio-card span { color: var(--muted); font-size: 12.5px; }

/* ---------- ticket detail ---------- */
.ticket-hero { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; }
.id-pair { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.id-chip { border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; background: var(--surface); }
.id-chip small { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.id-chip b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.stepper { display: flex; gap: 0; margin: 18px 0 20px; overflow-x: auto; padding-bottom: 4px; }
.step { flex: 1; min-width: 92px; text-align: center; position: relative; font-size: 11.5px; color: var(--muted); }
.step::before { content: ""; position: absolute; top: 11px; left: -50%; right: 50%; height: 2px; background: var(--line-2); z-index: 0; }
.step:first-child::before { display: none; }
.step .c { width: 24px; height: 24px; border-radius: 50%; margin: 0 auto 6px; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--line-2); position: relative; z-index: 1; font-size: 11px; font-weight: 700; }
.step.done { color: var(--ink-2); } .step.done .c { background: var(--good-mark); border-color: var(--good-mark); color: #fff; } .step.done::before { background: var(--good-mark); }
.step.now { color: var(--ink); font-weight: 650; } .step.now .c { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 20%, transparent); } .step.now::before { background: var(--good-mark); }
.raise { border: 1.5px dashed color-mix(in srgb, var(--warn) 60%, transparent); background: var(--warn-soft); border-radius: 12px; padding: 16px; }
.raise h2 { color: var(--warn); margin-bottom: 6px; letter-spacing: .02em; }
.raise ol { margin: 6px 0 12px; padding-left: 18px; color: var(--ink-2); }
.linked { border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); background: var(--good-soft); border-radius: 12px; padding: 16px; }
.qty-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.qty { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.qty b { display: block; font-size: 22px; font-weight: 750; font-variant-numeric: tabular-nums; } .qty span { font-size: 12px; color: var(--muted); }
.qty.hl { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); } .qty.hl b { color: var(--brand); }
.progress { height: 8px; background: var(--sunken); border-radius: 4px; overflow: hidden; display: flex; gap: 2px; margin: 14px 0 6px; }
.progress div { height: 100%; }
.dispatch { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; background: var(--surface-2); }
.dispatch-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.actions select, .actions input { width: auto; }

/* ---------- misc ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.toolbar .grow { flex: 1; min-width: 200px; }
.tabs { display: inline-flex; background: var(--sunken); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--ink-2); font-size: 13px; text-decoration: none; }
.tabs a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.empty-state { text-align: center; padding: 30px; color: var(--muted); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--page); padding: 11px 18px; border-radius: 12px; max-width: 90vw; z-index: 60; box-shadow: var(--shadow-lg); font-weight: 550; }
.toast.err { background: var(--crit); color: #fff; }
.tip { position: fixed; z-index: 70; pointer-events: none; background: var(--ink); color: var(--page); font-size: 12.5px; padding: 7px 10px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 260px; }
.callout { background: var(--info-soft); color: var(--ink-2); border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.owner-card { display: flex; gap: 14px; align-items: center; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 14px; }
.owner-card .avatar { width: 46px; height: 46px; font-size: 16px; border-radius: 12px; }

/* icon sizing */
button svg, .btn svg { width: 16px; height: 16px; flex: none; }
.feed .dot svg { width: 16px; height: 16px; }
.icon-btn svg { width: 18px; height: 18px; vertical-align: middle; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.cols-3 { display: grid; gap: 18px; grid-template-columns: 1.1fr 1fr 1fr; }
@media (max-width: 1200px) { .cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) { .cols-3 { grid-template-columns: 1fr; } }
.plants { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.plant-people { display: grid; gap: 2px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.plant-people b { color: var(--ink-2); font-weight: 550; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.tag-mgr { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); letter-spacing: .03em; }
.plant-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin-top: 6px; }
.plant-picks label { display: flex; align-items: center; gap: 7px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; color: var(--ink); font-weight: 500; cursor: pointer; }
.plant-picks label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.person-edit td { background: var(--surface-2); }
.checkline { display: flex !important; flex-direction: row; align-items: center; gap: 8px; }
.fx-frame-wrap { position: relative; border-top: 1px solid var(--line); }
.fx-frame-wrap iframe { display: block; width: 100%; height: 75vh; border: 0; background: #fff; }
.fx-fallback { padding: 10px 18px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
[hidden] { display: none !important; }
#alertBtn.on { color: #e8334f; }
#alertBtn svg { width: 18px; height: 18px; }

/* sign-in */
body.gated .shell { filter: blur(3px); pointer-events: none; user-select: none; }
.gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--page) 85%, transparent); }
.gate-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 26px; box-shadow: var(--shadow); display: grid; gap: 12px; }
.gate-card .logo { padding: 0 0 6px; }
.gate-card h1 { margin: 4px 0 0; font-size: 22px; }
.gate-card p { margin: 0; }
.gate-card label { display: grid; gap: 5px; font-weight: 550; font-size: 13px; }
.gate-card button.primary { justify-content: center; padding: 10px 14px; }
.gate-card .small { font-size: 12.5px; }
.gate-err { background: var(--crit-soft, var(--warn-soft)); color: var(--crit); padding: 8px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.actor .who { display: grid; line-height: 1.2; padding-right: 4px; }
.actor .who b { font-size: 13px; }
.actor .who span { font-size: 11.5px; color: var(--muted); }
.actor button.ghost { padding: 6px 8px; font-size: 12.5px; }
.reset-box { margin-bottom: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.big-code { font-size: 16px; font-weight: 700; padding: 4px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line-2); user-select: all; }
@media (max-width: 700px) { .actor .who, #pwBtn { display: none; } }
.gate-card .logo-title { color: var(--ink); }

.fx-launch { padding: 22px 18px 24px; display: grid; justify-items: start; gap: 12px; border-top: 1px solid var(--line); }
.fx-launch p { margin: 0; max-width: 680px; font-size: 13px; }
.btn.big { padding: 12px 22px; font-size: 15px; }

.pill.UNCOUNTED { background: var(--neutral-soft); color: var(--muted); }
.plant.UNCOUNTED { opacity: .85; }
.warn-callout { background: var(--warn-soft); color: var(--ink); margin-bottom: 18px; border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); }

/* ---------- phones: smaller type, tighter spacing, everything fits the width ---------- */
@media (max-width: 640px) {
  body { font-size: 13px; line-height: 1.45; }
  h1 { font-size: 19px; }
  h2 { font-size: 14px; }
  h3 { font-size: 12.5px; }
  .topbar { padding: 6px 10px; gap: 8px; padding-top: max(6px, env(safe-area-inset-top)); }
  .crumbs { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .top-right { gap: 6px; }
  .icon-btn { width: 32px; height: 32px; border-radius: 8px; font-size: 14px; }
  .icon-btn svg, #alertBtn svg { width: 16px; height: 16px; }
  .actor { padding: 2px; border-radius: 9px; }
  .actor .avatar { width: 26px; height: 26px; font-size: 11px; border-radius: 7px; }
  .actor button.ghost { padding: 4px 6px; font-size: 12px; }
  main { padding: 12px 10px 40px; }
  .banner { margin: 10px 10px 0; padding: 8px 10px; font-size: 12.5px; }
  .page-head { margin-bottom: 12px; gap: 8px; }
  .page-head p { font-size: 12.5px; }
  .page-head .row button, .page-head .row .btn { padding: 6px 10px; font-size: 12.5px; }
  .card { padding: 12px; margin-bottom: 12px; border-radius: 12px; }
  .card.flush .card-head { padding: 12px 12px 0; }
  .card-head { margin-bottom: 10px; }
  .card-head p { font-size: 12px; }
  .cols, .cols-3-2, .cols-3 { gap: 12px; }

  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .kpi { padding: 10px; border-radius: 12px; }
  .kpi .k-top { font-size: 11.5px; gap: 6px; }
  .kpi .k-ico { width: 26px; height: 26px; border-radius: 8px; }
  .kpi .k-ico svg { width: 14px; height: 14px; }
  .kpi .k-val { font-size: 21px; margin-top: 4px; }
  .kpi .k-sub { font-size: 11px; }

  table { font-size: 12px; }
  th, td { padding: 7px 8px; }
  th { font-size: 10px; letter-spacing: .03em; }
  .mono { font-size: 11px; }
  .table-wrap td, .table-wrap th { white-space: nowrap; }
  .table-wrap td.empty { white-space: normal; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .pill { font-size: 10.5px; padding: 1px 7px; }
  .pill.big { font-size: 12px; padding: 3px 10px; }
  td.empty { padding: 18px; }

  button, .btn { padding: 7px 11px; border-radius: 9px; font-size: 13px; }
  .btn.big { padding: 10px 16px; font-size: 14px; }
  input, select, textarea { padding: 7px 9px; font-size: 14px; border-radius: 8px; }
  form.f { gap: 9px; grid-template-columns: 1fr 1fr; }
  form.f label, .field { font-size: 12px; }
  .toolbar { gap: 8px; } .toolbar .grow { min-width: 100%; }
  .tabs a { padding: 5px 9px; font-size: 12px; }

  .plants { grid-template-columns: 1fr 1fr; gap: 8px; }
  .plant { padding: 10px; border-radius: 10px; }
  .plant-name { font-size: 13px; }
  .plant-stock { margin: 6px 0 4px; } .plant-stock b { font-size: 20px; }
  .plant-foot { font-size: 11px; margin-top: 6px; padding-top: 6px; }
  .bar-row { grid-template-columns: 110px 1fr 28px; font-size: 12px; gap: 8px; }
  .feed li { grid-template-columns: 26px 1fr; gap: 8px; padding: 8px 0; }
  .feed .dot { width: 26px; height: 26px; border-radius: 8px; }
  .feed .what { font-size: 12.5px; } .feed .when { font-size: 11px; }
  .legend { gap: 10px; font-size: 12px; }

  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { font-size: 11.5px; margin-top: 6px; } .kv dd { font-size: 13px; }
  .step { min-width: 64px; font-size: 10.5px; }
  .qty-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .qty { padding: 8px; } .qty b { font-size: 17px; } .qty span { font-size: 11px; }
  .raise, .linked, .dispatch { padding: 12px; }
  .id-chip { padding: 5px 9px; } .id-chip b { font-size: 12.5px; }
  .callout { font-size: 12.5px; padding: 10px 12px; }
  .owner-card { padding: 10px; gap: 10px; }
  .gate-card { padding: 20px; }
  .toast { font-size: 13px; padding: 9px 14px; bottom: 14px; }
  .fx-frame-wrap iframe { height: 65vh; }
}
@media (max-width: 360px) {
  .plants, form.f { grid-template-columns: 1fr; }
  .kpi .k-val { font-size: 19px; }
}

/* stock and Gmail import cards */
.ok-text { color: var(--good, #1f9d55); font-weight: 600; white-space: nowrap; }
td .up { color: var(--good, #1f9d55); font-weight: 600; }
td .down { color: var(--bad, #d64545); font-weight: 600; }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
label.inline input { width: auto; }
details summary { cursor: pointer; margin: 6px 0; }
