/* ============================================================================
   Inventory module — one surface model and one control kit (owner 2026-11-26, after the Fable review)
   - Light gray ground, white panels with a VISIBLE 1px border (contrast divides; no shadows, except the
     menu-style action cards, which keep the owner's gray sharp offset shadow).
   - Alignment: every control in a toolbar / form row is the same height (36px desktop, 44px phone);
     in-row list controls (+1, +case, quantity) are 32px (44px phone).
   - One line per edge: panel border outside; list header bottom line; row bottom hairline; the LAST row has
     none (the panel border closes it); category bands draw only their bottom line. Never two lines touching.
   - Color is state only: red low/short, amber open/to reorder, green counted/on Clover.
   Pages wrap their root in .inv-page; the page-local classes (st-/sc-/rc-/it-/sp-/ih-) are normalized here
   with .inv-page in front so these rules win over the old inline ones.
   ============================================================================ */

:root {
    --inv-ground: #f3f5f8;
    --inv-panel: #ffffff;
    --inv-border: #d9dde3;
    --inv-hair: #e8ebef;
    --inv-band: #eef1f5;
    --inv-ink: #1c2430;
    --inv-muted: #66707d;
    --inv-navy: var(--primary-color, #10284a);
    --inv-accent: var(--brand-primary, #0366d6);
    --inv-low: #b91c1c;      --inv-low-fill: #fdeeee;
    --inv-amber: #b45309;    --inv-amber-fill: #fdf3e6;
    --inv-good: #15803d;     --inv-good-fill: #e9f6ee;
    --inv-h: 36px;           /* toolbar / form controls */
    --inv-h-row: 32px;       /* controls inside list rows */
    --inv-radius: 14px;
    --inv-gap: 16px;         /* between panels */
}
[data-theme="dark"] {
    --inv-ground: #0d0f12;
    --inv-panel: #171a1f;
    --inv-border: #2c323a;
    --inv-hair: #242a31;
    --inv-band: #1e232a;
    --inv-ink: #eef1f5;
    --inv-muted: #9aa3ae;
    --inv-low: #f87171;      --inv-low-fill: #2a1616;
    --inv-amber: #fbbf24;    --inv-amber-fill: #2a2110;
    --inv-good: #4ade80;     --inv-good-fill: #13251a;
}
@media (max-width: 767.98px) {
    :root { --inv-h: 44px; --inv-h-row: 44px; }
}

/* ground: the whole content area of an inventory page */
main:has(.inv-page), main:has(.inv-page) > article.content { background: var(--inv-ground); }

/* ── header + section tabs (InventoryNav) ── */
.inv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 4px; }
.inv-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; line-height: 1.25; }
.inv-head .inv-meta { color: var(--inv-muted); font-size: 0.82rem; }
.inv-tabs, .inv-subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--inv-border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.inv-tabs { margin: 10px 0 var(--inv-gap); }
.inv-subtabs { margin: calc(-1 * var(--inv-gap) + 2px) 0 var(--inv-gap); }
.inv-tabs::-webkit-scrollbar, .inv-subtabs::-webkit-scrollbar { display: none; }
.inv-tabs a, .inv-subtabs a {
    display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; min-height: 42px;
    border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--inv-muted);
    font-weight: 600; font-size: 0.9rem; text-decoration: none; white-space: nowrap;
}
.inv-subtabs a { min-height: 38px; font-size: 0.84rem; padding: 0 12px; }
.inv-tabs a:hover, .inv-subtabs a:hover { color: var(--inv-ink); }
.inv-tabs a.on, .inv-subtabs a.on { color: var(--inv-ink); border-bottom-color: var(--inv-accent); }
.inv-tabs a:focus-visible, .inv-subtabs a:focus-visible { outline: 2px solid var(--inv-accent); outline-offset: -2px; }
.inv-tabs .inv-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--inv-amber); }
.inv-tabs .inv-n { font-size: 0.7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--inv-amber-fill); color: var(--inv-amber); }

/* ── panels ── */
.inv-page .inv-panel,
.inv-page .st-panel, .inv-page .sc-panel, .inv-page .rc-panel, .inv-page .it-panel, .inv-page .sp-panel {
    background: var(--inv-panel) !important;
    border: 1px solid var(--inv-border) !important;
    border-radius: var(--inv-radius) !important;
    padding: 14px 16px;
    margin: 0 0 var(--inv-gap) 0;
    overflow: clip;
}
.inv-page .inv-panel.flush, .inv-page .st-panel.flush, .inv-page .sc-panel.flush, .inv-page .rc-panel.flush { padding: 0; }
/* A band's total lines up with the last number column when rows end in a chevron column. */
.inv-list:has(.inv-chev) .inv-band .inv-bv { margin-right: 24px; }
.inv-ptitle {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    font-weight: 700; font-size: 0.95rem; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--inv-hair);
}
.inv-ptitle .inv-aside { font-weight: 500; font-size: 0.8rem; color: var(--inv-muted); }
.inv-page .inv-group-gap { margin-top: 24px; }

/* ── controls: one height per row ── */
.inv-page .st-input, .inv-page .sc-input, .inv-page .rc-input, .inv-page .it-input, .inv-page .sp-input,
.inv-page .inv-input, .inv-page select.st-input, .inv-page select.rc-input, .inv-page select.sp-input {
    height: var(--inv-h); min-height: var(--inv-h); box-sizing: border-box;
    border: 1px solid var(--inv-border); border-radius: 10px; background: var(--inv-panel); color: inherit;
    font-size: 0.86rem; padding: 0 12px; line-height: calc(var(--inv-h) - 2px);
}
.inv-page textarea.sp-input, .inv-page textarea.inv-input { height: auto; line-height: 1.45; padding: 9px 12px; }
.inv-page .st-search, .inv-page .sc-search, .inv-page .rc-search { border-radius: 999px; }
.inv-page .st-pill, .inv-page .sc-pill, .inv-page .rc-pill, .inv-page .it-pill, .inv-page .sp-pill, .inv-page .inv-pill {
    height: var(--inv-h); min-height: var(--inv-h); box-sizing: border-box;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 0 14px; border-radius: 999px; border: 1px solid var(--inv-border); background: var(--inv-panel);
    color: inherit; font-size: 0.8rem; font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer;
}
.inv-page .st-pill:hover:not(:disabled), .inv-page .sc-pill:hover:not(:disabled), .inv-page .rc-pill:hover:not(:disabled),
.inv-page .it-pill:hover:not(:disabled), .inv-page .sp-pill:hover:not(:disabled), .inv-page .inv-pill:hover:not(:disabled) {
    background: var(--inv-band); color: inherit;
}
/* primary action = navy; filter toggles = amber outline when on; nothing else uses fill */
.inv-page .st-pill.primary, .inv-page .sc-pill.primary, .inv-page .rc-pill.primary, .inv-page .it-pill.primary,
.inv-page .sp-pill.primary, .inv-page .inv-pill.primary,
.inv-page .st-pill.primary:hover:not(:disabled), .inv-page .sc-pill.primary:hover:not(:disabled), .inv-page .rc-pill.primary:hover:not(:disabled),
.inv-page .it-pill.primary:hover:not(:disabled), .inv-page .sp-pill.primary:hover:not(:disabled), .inv-page .inv-pill.primary:hover:not(:disabled) {
    background: var(--inv-navy); border-color: transparent; color: #fff;
}
.inv-page .st-pill.on, .inv-page .sc-pill.on, .inv-page .rc-pill.on, .inv-page .inv-pill.on,
.inv-page .st-pill.on:hover:not(:disabled), .inv-page .sc-pill.on:hover:not(:disabled), .inv-page .rc-pill.on:hover:not(:disabled), .inv-page .inv-pill.on:hover:not(:disabled) {
    background: var(--inv-amber-fill); border-color: var(--inv-amber); color: var(--inv-amber);
}
.inv-page .st-pill.danger, .inv-page .sc-pill.danger, .inv-page .rc-pill.danger, .inv-page .it-pill.danger, .inv-page .inv-pill.danger {
    border-color: color-mix(in srgb, var(--inv-low) 45%, transparent); color: var(--inv-low);
}
.inv-page .st-pill:disabled, .inv-page .sc-pill:disabled, .inv-page .rc-pill:disabled, .inv-page .it-pill:disabled, .inv-page .sp-pill:disabled, .inv-page .inv-pill:disabled { opacity: 0.55; cursor: default; }

/* in-row controls (+1, +case, small actions) and the quantity box share one height */
.inv-page .st-btn, .inv-page .sc-btn, .inv-page .rc-btn, .inv-page .inv-btn {
    height: var(--inv-h-row); min-height: var(--inv-h-row); min-width: 40px; box-sizing: border-box;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    padding: 0 10px; border-radius: 999px; border: 1px solid var(--inv-border); background: var(--inv-panel);
    color: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.inv-page .st-btn:hover:not(:disabled), .inv-page .sc-btn:hover:not(:disabled), .inv-page .rc-btn:hover:not(:disabled), .inv-page .inv-btn:hover:not(:disabled) { background: var(--inv-band); }
.inv-page .sc-qty, .inv-page .rc-num, .inv-page .inv-qty {
    height: var(--inv-h-row); min-height: var(--inv-h-row); line-height: calc(var(--inv-h-row) - 2px);
    text-align: right; font-variant-numeric: tabular-nums; font-weight: 600;
}

/* labels above fields: one style, one gap */
.inv-page .st-field > span:first-child, .inv-page .rc-field > span:first-child, .inv-page .sp-field > span:first-child, .inv-page .inv-field > span:first-child {
    font-size: 0.74rem; font-weight: 600; color: var(--inv-muted); line-height: 1.2;
}
.inv-page .st-field, .inv-page .rc-field, .inv-page .sp-field, .inv-page .inv-field { gap: 5px; }

/* ── record lists: one header, bands, one line per edge ── */
.inv-list { display: grid; column-gap: 18px; }
.inv-list > .inv-lh, .inv-list > .inv-row, .inv-list > .inv-band { grid-column: 1 / -1; }
.inv-list > .inv-lh, .inv-list > .inv-row { display: grid; grid-template-columns: subgrid; align-items: center; }
.inv-lh { padding: 8px 16px; border-bottom: 1px solid var(--inv-border); background: var(--inv-panel); position: sticky; top: 0; z-index: 1; }
.inv-lh > span { font-size: 0.64rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--inv-muted); white-space: nowrap; }
.inv-row { padding: 9px 16px; border-bottom: 1px solid var(--inv-hair); color: inherit; text-decoration: none; font-size: 0.86rem; min-height: 50px; box-sizing: border-box; }
a.inv-row:hover, button.inv-row:hover { background: color-mix(in srgb, var(--inv-accent) 4%, transparent); color: inherit; }
.inv-band {
    display: flex; align-items: center; gap: 10px; padding: 0 16px; min-height: 38px;
    background: var(--inv-band); border-bottom: 1px solid var(--inv-border); cursor: pointer; user-select: none;
}
.inv-row + .inv-band { border-top: 0; }
.inv-band .inv-bn { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; }
.inv-band .inv-bs { font-size: 0.76rem; color: var(--inv-muted); }
.inv-band .inv-bv { margin-left: auto; font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.inv-band .bi { color: var(--inv-muted); font-size: 0.85rem; width: 1rem; }
.inv-list > :last-child { border-bottom: 0; }
.inv-cell { min-width: 0; }
.inv-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.inv-sub { font-size: 0.74rem; color: var(--inv-muted); display: block; }
.inv-approx { display: block; font-size: 0.7rem; color: var(--inv-muted); font-weight: 400; }
.inv-num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-low { color: var(--inv-low); font-weight: 700; }
.inv-chev { color: var(--inv-muted); text-align: right; }

/* chips (state only) */
.inv-chip { display: inline-flex; align-items: center; height: 22px; font-size: 0.7rem; font-weight: 600; padding: 0 9px; border-radius: 999px; white-space: nowrap;
            background: var(--inv-band); color: var(--inv-muted); }
.inv-chip.low { background: var(--inv-low-fill); color: var(--inv-low); }
.inv-chip.amber { background: var(--inv-amber-fill); color: var(--inv-amber); }
.inv-chip.good { background: var(--inv-good-fill); color: var(--inv-good); }

/* toolbars: rows of equal-height controls; right-aligned group stays right when wrapping */
.inv-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inv-toolbar + .inv-toolbar { margin-top: 10px; }
.inv-toolbar .inv-right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.inv-toolbar .inv-summary { font-size: 0.8rem; color: var(--inv-muted); }
.inv-toolbar .inv-summary b { color: var(--inv-ink); }
.inv-panel-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--inv-border); }

/* messages */
.inv-page .st-msg, .inv-page .sc-msg, .inv-page .rc-msg, .inv-page .it-msg, .inv-page .sp-msg { margin: 0 0 var(--inv-gap) 0; }

/* bottom message (scan / save feedback) — rendered through OverlayService (layout root) */
.inv-snack {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    z-index: calc(var(--z-fab, 1050) + 1); max-width: min(520px, calc(100vw - 32px)); width: max-content;
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
    background: #1b1f26; color: #fff; font-size: 0.88rem;
}
.inv-snack .bi { font-size: 1.1rem; }
.inv-snack.ok .bi { color: #4ade80; }
.inv-snack.err { background: #7f1d1d; }
.inv-snack.err .bi { color: #fecaca; }

/* clover mark (Clover's own icon as a mask) */
.clover-mark { display: inline-block; width: 1em; height: 1em; flex: none; background: #1f8a3a;
               -webkit-mask: url(/images/clover-icon.svg) center / contain no-repeat; mask: url(/images/clover-icon.svg) center / contain no-repeat; }
.clover-mark.off { background: #a3a9b1; }
[data-theme="dark"] .clover-mark { background: #4ade80; }
[data-theme="dark"] .clover-mark.off { background: #5b616a; }
