/*
 * StockTag panel theme — warm paper, coral accent, soft cards.
 *
 * Three layers, so the identity survives maintenance: primitives are the only
 * raw values in the file, semantics give them a purpose, and components read
 * semantics only. Dark mode redefines the SEMANTIC layer alone — if a component
 * ever needs its own dark block, something is wired wrong.
 *
 * Light and open on purpose: this is a system people sit in front of all day,
 * and the density of an ERP is easier to take on paper-warm ground than on a
 * cold grey one. Surfaces are lifted with a soft shadow rather than boxed in
 * with a hard border, and the coral is spent in one place at a time — on what
 * is live, or on what needs attention, never on decoration.
 */

/* ---------------------------------------------------------------- primitives */
:root {
    /* Coral: the single accent. Warm enough to sit on paper without clashing,
       dark enough at 600 to carry white text at the sizes buttons use. */
    --st-coral-50:  #FDF0ED;
    --st-coral-100: #FADDD6;
    --st-coral-200: #F5BCAF;
    --st-coral-300: #EE9482;
    --st-coral-400: #E76F58;
    --st-coral-500: #DC4F35;
    --st-coral-600: #C03D26;
    --st-coral-700: #9B301D;

    /* Paper: warm neutrals, biased a touch toward the coral so the ground
       reads as chosen rather than as undecided grey. */
    --st-paper-0:   #FFFFFF;
    --st-paper-50:  #FCFAF8;
    --st-paper-100: #F7F3EF;
    --st-paper-200: #EFE9E3;
    --st-paper-300: #E2D9D1;

    /* Slate: the cool counterweight, for type and for the quiet surfaces. */
    --st-slate-300: #C2CBD3;
    --st-slate-400: #94A0AB;
    --st-slate-500: #6E7A86;
    --st-slate-600: #55606B;
    --st-slate-700: #3F4954;
    --st-slate-800: #2B333C;
    --st-slate-850: #222932;
    --st-slate-900: #191F26;
    --st-slate-950: #10151A;

    /* Soft blue-grey, for panels that should recede without going grey. */
    --st-mist-50:   #F2F6F8;
    --st-mist-100:  #E6EDF2;

    --st-radius:    0.625rem;   /* cards are lifted, so they may be rounded */
    --st-radius-sm: 0.375rem;
    --st-radius-pill: 999px;

    --st-lift:      0 1px 2px rgba(25, 31, 38, .05), 0 2px 8px rgba(25, 31, 38, .04);
    --st-lift-2:    0 2px 4px rgba(25, 31, 38, .06), 0 8px 24px rgba(25, 31, 38, .07);
}

/* ----------------------------------------------------------------- semantics */
:root {
    --st-ground:        var(--st-paper-100);
    --st-surface:       var(--st-paper-0);
    --st-surface-sunk:  var(--st-mist-50);
    --st-line:          var(--st-paper-300);
    --st-line-soft:     var(--st-paper-200);
    --st-ink:           var(--st-slate-950);
    --st-ink-muted:     var(--st-slate-600);
    --st-ink-faint:     var(--st-slate-400);
    --st-accent:        var(--st-coral-500);
    --st-accent-strong: var(--st-coral-600);
    --st-accent-soft:   color-mix(in srgb, var(--st-coral-500) 9%, transparent);

    /* The rail is light now, and the live item is marked with coral rather
       than by inverting the whole side of the screen. */
    --st-rail:          var(--st-paper-50);
    --st-rail-edge:     var(--st-paper-200);
    --st-rail-ink:      var(--st-slate-700);
    --st-rail-muted:    var(--st-slate-400);
    --st-rail-active:   var(--st-coral-50);
    --st-rail-active-ink: var(--st-coral-600);

    --st-shadow:        var(--st-lift);
    --st-shadow-2:      var(--st-lift-2);
}

.dark {
    --st-ground:        var(--st-slate-950);
    --st-surface:       var(--st-slate-900);
    --st-surface-sunk:  var(--st-slate-850);
    --st-line:          var(--st-slate-800);
    --st-line-soft:     var(--st-slate-850);
    --st-ink:           var(--st-paper-100);
    --st-ink-muted:     var(--st-slate-300);
    --st-ink-faint:     var(--st-slate-500);
    --st-accent:        var(--st-coral-400);
    --st-accent-strong: var(--st-coral-300);
    --st-accent-soft:   color-mix(in srgb, var(--st-coral-400) 16%, transparent);

    --st-rail:          var(--st-slate-900);
    --st-rail-edge:     var(--st-slate-800);
    --st-rail-ink:      var(--st-slate-300);
    --st-rail-muted:    var(--st-slate-500);
    --st-rail-active:   color-mix(in srgb, var(--st-coral-400) 16%, transparent);
    --st-rail-active-ink: var(--st-coral-300);

    /* A shadow on a dark ground reads as dirt. Depth comes from the surface
       being lighter than the ground instead. */
    --st-shadow:        none;
    --st-shadow-2:      none;
}

/* ---------------------------------------------------------------- components */

.fi-body {
    background-color: var(--st-ground);
}

/* Sidebar: warm paper, coral for the live item. */
.fi-sidebar {
    background-color: var(--st-rail);
    border-inline-end: 1px solid var(--st-rail-edge);
}

.fi-sidebar .fi-sidebar-group-label {
    color: var(--st-rail-muted);
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.fi-sidebar .fi-sidebar-item-label {
    color: var(--st-rail-ink);
}

.fi-sidebar .fi-sidebar-item-icon {
    color: var(--st-rail-muted);
}

.fi-sidebar .fi-sidebar-item-btn:hover {
    background-color: var(--st-accent-soft);
}

.fi-sidebar .fi-sidebar-item.fi-active > .fi-sidebar-item-btn {
    background-color: var(--st-rail-active);
    /* Marking paint down the edge, the way a live row is flagged on a plate. */
    box-shadow: inset 3px 0 0 0 var(--st-accent);
}

.fi-sidebar .fi-sidebar-item.fi-active .fi-sidebar-item-label,
.fi-sidebar .fi-sidebar-item.fi-active .fi-sidebar-item-icon {
    color: var(--st-rail-active-ink);
}

/* Topbar sits on the paper, not the machine. */
.fi-topbar {
    background-color: var(--st-surface);
    border-block-end: 1px solid var(--st-line);
}

/* Cards and sections: lifted surfaces with a coral strike across the top. */
.fi-section,
.fi-wi-stats-overview-stat {
    background-color: var(--st-surface);
    border: 1px solid var(--st-line);
    border-radius: var(--st-radius);
    box-shadow: var(--st-shadow);
}

.fi-wi-stats-overview-stat {
    border-block-start: 3px solid var(--st-accent);
}

/* Tables: engraved lines, not shadows. */
.fi-ta-ctn {
    background-color: var(--st-surface);
    border: 1px solid var(--st-line);
    border-radius: var(--st-radius);
}

.fi-ta-header-cell {
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--st-ink-muted);
}

.fi-ta-row:hover {
    background-color: var(--st-accent-soft);
}

/* Anything that is a code reads as one. */
.fi-ta-text .fi-font-mono,
.fi-badge .fi-font-mono {
    letter-spacing: -0.01em;
}

/* Badges: soft, to sit with the lifted surfaces around them. */
.fi-badge {
    border-radius: var(--st-radius-pill);
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Buttons: pill, solid coral for the primary action, honest focus ring. */
.fi-btn {
    border-radius: var(--st-radius-pill);
    font-weight: 600;
}

.fi-btn-color-primary {
    box-shadow: var(--st-shadow);
}

.fi-btn:focus-visible,
.fi-input:focus-visible {
    outline-color: var(--st-accent);
}

/* Navigation badges (reorder count etc) should read as alerts, not decoration. */
.fi-sidebar .fi-badge {
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ the login page */
/* The one screen everybody sees. It carries the plate identity outright:
   soft ground, a lifted card, coral strike. */

.fi-simple-layout {
    background-color: var(--st-ground);
    background-image:
        linear-gradient(color-mix(in srgb, var(--st-ink) 4%, transparent) 1px, transparent 1px),
        linear-gradient(90deg, color-mix(in srgb, var(--st-ink) 4%, transparent) 1px, transparent 1px);
    background-size: 32px 32px;
}

.fi-simple-main {
    background-color: var(--st-surface);
    border: 1px solid var(--st-line);
    border-block-start: 3px solid var(--st-accent);
    border-radius: var(--st-radius);
    box-shadow: var(--st-shadow-2);
}

/* ------------------------------------------------------------------ branding */

.fi-logo {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

/* The viewBox is 120x100, so the box has to follow it — a square rule here
   squashes the mark, which is the sort of thing nobody reports and everybody
   notices. */
.st-brand-mark {
    width: 2.3rem;
    height: 1.9rem;
    flex: none;
}

.st-brand-word {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--st-ink);
    line-height: 1;
}

.fi-sidebar .st-brand-word {
    color: var(--st-rail-ink);
}

.st-brand-word .st-tag {
    color: var(--st-accent);
}

/* Modals and dropdowns stay on-surface in both modes. */
.fi-modal-window,
.fi-dropdown-panel {
    background-color: var(--st-surface);
    border: 1px solid var(--st-line);
    border-radius: var(--st-radius);
}

/* =============================================================== app surfaces
 *
 * Real classes, not Tailwind utilities.
 *
 * Filament compiles its stylesheet from its OWN content paths, so utility
 * classes written in an application view are emitted into the HTML with no rule
 * behind them — the markup looks right and renders as unstyled text. Anything
 * this application draws itself is styled here, where the CSS is guaranteed to
 * load because the panel registers this file directly.
 */

/* --- tab strip ------------------------------------------------------------ */
.st-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 1.25rem;
}

.st-tab {
    border: 1px solid var(--st-line);
    border-radius: var(--st-radius-pill);
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    color: var(--st-ink-muted);
    background: transparent;
    cursor: pointer;
    transition: border-color .15s, color .15s, background-color .15s;
}

.st-tab:hover { border-color: var(--st-ink-faint); color: var(--st-ink); }

.st-tab[aria-selected="true"] {
    border-color: var(--st-accent);
    background: var(--st-accent-soft);
    color: var(--st-accent-strong);
    font-weight: 600;
    /* Marking paint down the edge, as on the live sidebar item. */
    box-shadow: inset 3px 0 0 0 var(--st-accent);
}

/* --- stat tiles ----------------------------------------------------------- */
.st-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.st-stat {
    border: 1px solid var(--st-line-soft);
    border-radius: var(--st-radius);
    padding: 1rem 1.15rem;
    background: var(--st-surface);
    box-shadow: var(--st-shadow);
}

.st-stat-label {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.65rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--st-ink-faint);
    margin-bottom: 0.2rem;
}

.st-stat-value {
    font-size: 1.35rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    color: var(--st-ink);
    line-height: 1.15;
}

.st-stat-note { font-size: 0.75rem; margin-top: 0.25rem; color: var(--st-ink-muted); }
.st-stat.is-good { border-color: #35674A; }
.st-stat.is-bad  { border-color: #98413A; }
.st-stat.is-bad .st-stat-note { color: #98413A; }
.dark .st-stat.is-bad .st-stat-note { color: #D98A82; }

/* --- data tables ---------------------------------------------------------- */
.st-scroll { overflow-x: auto; }

.st-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

.st-table th {
    text-align: left;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--st-ink-faint);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--st-line);
    white-space: nowrap;
}

.st-table td {
    padding-block: 0.62rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--st-line-soft);
    color: var(--st-ink-muted);
    vertical-align: top;
}

.st-table tbody tr:last-child td { border-bottom: 0; }
.st-table tbody tr:hover { background: var(--st-accent-soft); }

.st-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-key { color: var(--st-ink); font-weight: 560; }
.st-sub { color: var(--st-ink-faint); font-size: 0.8rem; }
.st-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.st-strong { color: var(--st-ink); font-weight: 650; }

/* --- inline pills --------------------------------------------------------- */
.st-pill {
    display: inline-block;
    border-radius: var(--st-radius-pill);
    padding: 0.12rem 0.5rem;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    font-weight: 600;
    white-space: nowrap;
}

.st-pill-ok   { background: #DCE8E0; color: #35674A; }
.st-pill-warn { background: #F0E5CC; color: #8E6516; }
.st-pill-bad  { background: #F2DEDC; color: #98413A; }
.st-pill-flat { background: var(--st-surface-sunk); color: var(--st-ink-muted); }

.dark .st-pill-ok   { background: #1D2C24; color: #7FB795; }
.dark .st-pill-warn { background: #2C2519; color: #D9B265; }
.dark .st-pill-bad  { background: #2E1E1D; color: #D98A82; }

/* --- two-column split ----------------------------------------------------- */
.st-split { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .st-split { grid-template-columns: 1fr 1fr; } }

.st-h3 {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.65rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--st-ink-faint);
    margin-bottom: 0.5rem;
}

.st-empty { font-size: 0.875rem; color: var(--st-ink-faint); padding: 0.75rem 0; }

.st-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--st-line-soft);
    font-size: 0.875rem;
}

.st-row:last-child { border-bottom: 0; }
.st-note { font-size: 0.75rem; color: var(--st-ink-faint); margin-top: 0.75rem; }

/* --- report actions ------------------------------------------------------- */
.st-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    justify-content: flex-end;
}

.st-mt { margin-top: 1.5rem; }

/* --- printing a report ----------------------------------------------------
 * The screen carries navigation, tabs and buttons that mean nothing on paper.
 * Printing should produce the table somebody wanted to file, not a screenshot
 * of an application.
 */
@media print {
    .fi-sidebar, .fi-topbar, .st-tabs, .st-actions, .fi-btn { display: none !important; }
    .fi-main, .fi-body, .fi-section { background: #fff !important; color: #000 !important; }
    .fi-section { border: none !important; box-shadow: none !important; }
    .st-table th { color: #000 !important; border-bottom: 0.6pt solid #000 !important; }
    .st-table td { color: #000 !important; border-bottom: 0.3pt solid #000 !important; }
    .st-table tbody tr:hover { background: transparent !important; }
    .st-stat { border: 0.6pt solid #000 !important; }
    .st-pill { border: 0.4pt solid #000 !important; background: transparent !important; color: #000 !important; }
}

/* --- report filters ------------------------------------------------------- */
.st-filters {
    border: 1px solid var(--st-line);
    border-radius: var(--st-radius);
    background: var(--st-surface-sunk);
    padding: 0.75rem 0.9rem;
    margin-bottom: 0.75rem;
}

.st-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

.st-field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 9rem; }

.st-field-label {
    font-size: 0.6875rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--st-ink-faint);
}

.st-input {
    border: 1px solid var(--st-line);
    border-radius: var(--st-radius-sm);
    background: var(--st-surface);
    color: var(--st-ink);
    padding: 0.35rem 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.3;
}

.st-input:focus-visible {
    outline: 2px solid var(--st-accent);
    outline-offset: 1px;
    border-color: var(--st-accent);
}

/* The browser paints its own date/select glyphs from the page's colour-scheme,
   so a dark panel with a light glyph is what happens without this. */
.st-input { color-scheme: light; }
:root[data-theme="dark"] .st-input,
.dark .st-input { color-scheme: dark; }

.st-clear {
    border: 1px solid var(--st-accent);
    border-radius: var(--st-radius-pill);
    background: transparent;
    color: var(--st-accent);
    padding: 0.35rem 0.7rem;
    font-size: 0.8125rem;
    cursor: pointer;
    align-self: flex-end;
}

.st-clear:hover { background: color-mix(in srgb, var(--st-accent) 12%, transparent); }

.st-filter-note {
    font-size: 0.6875rem;
    color: var(--st-ink-faint);
    margin-top: 0.6rem;
}

/* --- a report row that opens the record behind it ------------------------- */
.st-row-link { cursor: pointer; }
.st-row-link:hover { background: color-mix(in srgb, var(--st-accent) 8%, transparent); }
a.st-row-link { text-decoration: none; color: inherit; }
.st-row-link .st-key { color: var(--st-accent); text-decoration: none; }
.st-row-link:hover .st-key { text-decoration: underline; }

/* Nothing in a report is clickable on paper, and a hover tint costs toner. */
@media print {
    .st-filters, .st-clear { display: none; }
    .st-row-link, .st-row-link:hover { background: none; cursor: auto; }
    .st-row-link .st-key { color: inherit; text-decoration: none; }
}

/* --- stocktake ------------------------------------------------------------ */
.st-sweeps { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.st-sweep {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--st-line);
    border-radius: var(--st-radius);
    padding: 0.4rem 0.7rem;
    min-width: 7.5rem;
}

.st-sweep-no {
    font-family: var(--st-font-mono, ui-monospace, monospace);
    font-size: 1rem;
    font-weight: 700;
    color: var(--st-ink-faint);
}

.st-sweep-state {
    font-size: 0.6875rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--st-ink-faint);
}

/* A walked sweep is marked on the border, not by a fill: the row of plates
   should read as progress at a glance without turning the panel into blocks. */
.st-sweep.is-done { border-color: var(--st-accent); }
.st-sweep.is-done .st-sweep-no { color: var(--st-accent); }
.st-sweep.is-done .st-sweep-state { color: var(--st-ink-muted); }

.st-confirm { display: flex; flex-direction: column; gap: 0.4rem; min-width: 15rem; text-align: left; }
.st-confirm-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }

.st-stat.is-warn { border-color: #8A6A2F; }

/* The provider panel says so in the wordmark, so a screenshot of it can never
   be mistaken for a screenshot of a client's own system. */
.st-brand-role {
    font-size: 0.625rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.1rem 0.35rem;
    border: 1px solid currentColor;
    border-radius: var(--st-radius);
    opacity: 0.75;
    margin-left: 0.35rem;
}

/* --- user guide ----------------------------------------------------------- */
.st-topic {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--st-line-soft);
}

.st-topic:last-child { border-bottom: 0; }

.st-topic-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.st-topic-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--st-ink);
    margin: 0;
}

.st-topic-link {
    font-size: 0.75rem;
    color: var(--st-accent);
    white-space: nowrap;
    text-decoration: none;
}

.st-topic-link:hover { text-decoration: underline; }

.st-topic-body {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--st-ink-muted);
    margin: 0.4rem 0 0;
    max-width: 70ch;
}

/* The trap is the part worth reading twice, so it is set apart with a rule
   rather than a fill — a tinted block here would print as a grey slab. */
.st-topic-trap {
    font-size: 0.8125rem;
    line-height: 1.6;
    margin: 0.5rem 0 0;
    padding-left: 0.7rem;
    border-left: 2px solid #8A6A2F;
    color: var(--st-ink-muted);
    max-width: 70ch;
}

.st-topic-trap-tag {
    display: inline-block;
    font-size: 0.625rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #8A6A2F;
    margin-right: 0.45rem;
}

:root[data-theme="dark"] .st-topic-trap,
.dark .st-topic-trap { border-left-color: #C79A4A; }

:root[data-theme="dark"] .st-topic-trap-tag,
.dark .st-topic-trap-tag { color: #C79A4A; }
