/* ============================================================
   ALAN FACELIFT (Oct 2026) — the look agreed from the compliance-dashboard
   mock-up: IBM Plex, cool grey canvas, dark slate rail, flat white panels
   with hairline borders, pill tabs, colour only where it means something.

   Loaded AFTER style.css and the page templates' own <style> blocks are
   overridden where needed. Revert the whole facelift by removing the
   <link> to this file in base.html.
   ============================================================ */

:root {
    --bg: #eef1f4;
    --surface: #ffffff;
    --sunk: #f6f8fa;
    --ink: #1c2631;
    --muted: #5a6776;
    --faint: #8794a3;
    --line: #dbe1e8;
    --slate: #2d3a4a;
    --rail: #243040;
    --rail-ink: #c9d3de;
    --tile: #0f6b4c;
    --accent: #2f5f8f;
    --mabel: #6a4bb8;  --mabel-soft: #efeafb;
    --bad: #c62828;    --bad-soft: #fdecec;
    --warn: #b25e09;   --warn-soft: #fdf1e3;
    --ok: #08795a;     --ok-soft: #e4f5ee;
    --info: #3d6a96;   --info-soft: #e8f0f8;
    --font: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

    /* Re-point the legacy tokens so the thousands of inline var(--gray-*) uses
       pick up the new cool palette without touching the templates. */
    --primary: #2d3a4a;
    --primary-dark: #243040;
    --success: #08795a;
    --warning: #b25e09;
    --danger: #c62828;
    --gray-50: #f6f8fa;
    --gray-100: #edf1f5;
    --gray-200: #dbe1e8;
    --gray-300: #c5ced8;
    --gray-400: #8794a3;
    --gray-500: #6a7785;
    --gray-600: #5a6776;
    --gray-700: #3d4a59;
    --gray-800: #1c2631;
    --gray-900: #121a23;
    --radius: 8px;
    --shadow: none;
    --shadow-md: 0 4px 14px rgba(20,30,45,0.08);

    --rail-width: 76px;
    --topbar-height: 52px;
    --header-height: 52px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
}
button, input, select, textarea { font-family: inherit; }
code, kbd, pre, .mono, .fr-code { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============================================================
   RAIL
   ============================================================ */
.global-header {
    background: var(--rail);
    box-shadow: none;
    padding: 14px 7px 12px;
    gap: 6px;
}
.gh-centre { padding-top: 0; }
.gh-wordmark {
    font: 700 0.95rem/1 var(--mono);
    color: #fff;
    letter-spacing: 0.06em;
    text-decoration: none;
    padding: 4px 0 10px;
    display: block;
    text-align: center;
}
.gh-brand { display: none; }
.global-header .sandbox-badge { font-size: 8px; padding: 2px 5px; box-shadow: none; }

.gh-left {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
    gap: 4px;
}
.gh-nav-tab,
.gh-nav-tab-production.active,
.gh-nav-tab-quality.active {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--rail-ink);
    font-size: 10.5px;
    font-weight: 600;
    padding: 8px 2px 7px;
    border-radius: 8px;
    gap: 3px;
}
.gh-nav-tab svg,
.gh-nav-tab-production.active svg,
.gh-nav-tab-quality.active svg { stroke: currentColor !important; width: 19px; height: 19px; }
.gh-nav-tab:hover { background: rgba(255,255,255,0.06); color: #fff; }
.gh-nav-tab:hover svg { stroke: currentColor; }
.gh-nav-tab.active { background: rgba(255,255,255,0.10) !important; color: #fff !important; }

.gh-actions { border-top: 0; gap: 6px; padding: 0.4rem 4px; }
.gh-rail-action {
    background: var(--tile);
    border-radius: 7px;
    box-shadow: none;
    font-size: 10px;
    padding: 7px 2px 6px;
}
.gh-rail-action:hover { background: #0c5a40; box-shadow: none; }
.gh-rail-action:active { background: #094732; }

.gh-right { border-top: 1px solid rgba(255,255,255,0.08); gap: 4px; padding-top: 8px; }
.gh-operator-pill:hover { background: rgba(255,255,255,0.06); }
.gh-operator-avatar { background: rgba(255,255,255,0.12) !important; border: 0 !important; }
.gh-operator-avatar svg { stroke: #fff !important; }
.gh-mini-icon-lg {
    background: transparent;
    border: 0;
    box-shadow: none;
    width: 40px;
    height: 36px;
    border-radius: 8px;
}
.gh-mini-icon-lg svg { stroke: var(--rail-ink); width: 19px; height: 19px; }
.gh-mini-icon-lg:hover { background: rgba(255,255,255,0.08); border: 0; box-shadow: none; }
.gh-mini-icon-lg:hover svg, .gh-mini-icon-lg.active svg { stroke: #fff; }
.gh-mini-icon-lg.active { background: rgba(255,255,255,0.10); }
.gh-mini-scan { background: transparent !important; border: 0 !important; }
.gh-mini-scan svg { stroke: #7fd3b0 !important; }
.gh-mini-scan:hover, .gh-mini-scan.active { background: rgba(127,211,176,0.14) !important; }
.gh-mini-logout:hover { background: rgba(255,123,114,0.14) !important; }
.gh-mini-logout:hover svg { stroke: #ff9b93 !important; }

/* ============================================================
   TOP BAR
   ============================================================ */
.gh-topbar {
    background: var(--surface);
    box-shadow: none;
    border-bottom: 1px solid var(--line);
    padding: 0 18px;
    gap: 14px;
}
.gh-page-title {
    font: 600 1rem/1.2 var(--font);
    color: var(--ink);
    white-space: nowrap;
    margin: 0;
}
.gh-hello {
    margin-left: auto;
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
    flex-shrink: 0;
}
#gh-search-slot:empty { flex: 1; }
#gh-search-slot .orders-tab-search {
    background: var(--sunk);
    border: 1px solid var(--line);
    box-shadow: none;
    border-radius: 8px;
    padding: 0.38rem 0.8rem;
}
#gh-search-slot .orders-tab-search:hover { border-color: var(--faint); box-shadow: none; }
#gh-search-slot .orders-tab-search:focus-within {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47,95,143,0.14);
}
#gh-search-slot .orders-tab-search input { color: var(--ink); font-size: 13px; }
#gh-search-slot .orders-tab-search input::placeholder { color: var(--faint); }
#gh-search-slot .orders-tab-search svg.search-icon { color: var(--faint); }
#gh-search-slot .orders-tab-search .kbd {
    background: var(--surface); border-color: var(--line); color: var(--faint); font-family: var(--mono);
}

/* Pill tabs — Production (Orders / Scan Drop / New Order / Actions) and
   Quality (Dashboard / Core Documentation / Forms & Records / Product Register).
   Each tab used to have its own pastel colour + shimmer; the mock-up uses one
   neutral pill with the selected tab filled slate. */
.orders-tab, .qms-tabs-row .tab, .tabs .tab,
.tab-dashboard, .tab-coredocs, .tab-formslogs, .tab-products,
#ordertab-orders, #ordertab-scandrop, #ordertab-new, #ordertab-actions {
    background: var(--surface) !important;
    border: 1px solid var(--line) !important;
    color: var(--muted) !important;
    border-radius: 999px !important;
    padding: 4px 12px !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    box-shadow: none !important;
    margin-bottom: 0 !important;
}
.orders-tab::before, .qms-tabs-row .tab::before,
.tab-dashboard::before, .tab-coredocs::before, .tab-formslogs::before, .tab-products::before { display: none !important; }
.orders-tab:hover, .qms-tabs-row .tab:hover, .tabs .tab:hover { border-color: var(--faint) !important; color: var(--ink) !important; }
.orders-tab.active, .qms-tabs-row .tab.active, .tabs .tab.active,
.tab-dashboard.active, .tab-coredocs.active, .tab-formslogs.active, .tab-products.active,
#ordertab-orders.active, #ordertab-scandrop.active, #ordertab-new.active, #ordertab-actions.active {
    background: var(--slate) !important;
    border-color: var(--slate) !important;
    color: #fff !important;
}
.tabs { border-bottom: 0; gap: 4px; }

/* ============================================================
   CONTENT CANVAS
   ============================================================ */
main.content { background: transparent; }
.page-header h1, h1 { letter-spacing: -0.01em; }
.page-header h1 { font-size: 1.35rem; }
h2 { font-weight: 700; }
h3 { font-weight: 600; }

/* Panels / cards — flat white with a hairline */
.card, .chart-card, .nav-card, .kpi-card, .hub-tile, .qmsp-tile, .workflow-tile,
.sku-section, .trigger-card, .qms-modal-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: none;
}
.nav-card:hover, .hub-tile:hover, .workflow-tile:hover { border-color: var(--faint); box-shadow: none; }
.nav-card h3 { color: var(--ink); }

/* Tile headers were gradient banners with a blue strip — now a quiet panel header */
.tile-header {
    background: transparent !important;
    color: var(--ink) !important;
    border-left: 0 !important;
    border-bottom: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    padding: 0.6rem 0.9rem;
    margin: -1rem -1rem 0.75rem -1rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--muted) !important;
}

/* KPI tiles — white with a 3px severity stripe on top, like the health strip */
.kpi-card { border-left: 0; position: relative; overflow: hidden; text-align: left; }
.kpi-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--info); }
.kpi-card.kpi-warning::before { background: var(--warn); }
.kpi-card.kpi-danger::before { background: var(--bad); }
.kpi-value { font-size: 1.6rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }

/* Buttons */
.btn { border-radius: 6px; font-weight: 600; font-size: 0.8rem; padding: 0.45rem 0.85rem; transition: background .15s, border-color .15s; }
.btn-primary, .btn-primary:hover {
    background: var(--slate) !important;
    color: #fff !important;
    border: 1px solid var(--slate) !important;
    font-weight: 700;
}
.btn-primary:hover { background: #1f2a37 !important; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--sunk); border-color: var(--faint); }
.btn-danger { background: var(--bad); border-color: var(--bad); }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-sm { padding: 0.25rem 0.55rem; font-size: 0.74rem; }

/* Forms */
input[type="text"], input[type="number"], input[type="date"], input[type="email"],
input[type="password"], input[type="search"], input[type="datetime-local"], select, textarea {
    border-color: var(--line);
    border-radius: 6px;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(47,95,143,0.12); }
.form-group label, label { color: var(--muted); }

/* Tables */
.data-table { border: 1px solid var(--line); border-radius: 8px; box-shadow: none; background: var(--surface); }
.data-table th {
    background: var(--sunk);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--line);
    padding: 0.6rem 0.9rem;
}
.data-table td { border-bottom: 1px solid var(--line); padding: 0.55rem 0.9rem; font-size: 0.84rem; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--sunk); }

/* Badges & chips */
.badge, .urgency-badge, .days-badge { border-radius: 4px; font-weight: 600; }

/* Flash messages */
.flash { border-radius: 8px; font-size: 0.84rem; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.flash-error { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.flash-warning { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.flash-info { background: var(--info-soft); color: var(--info); border-color: transparent; }

/* Modals */
.qms-modal-header { background: var(--surface) !important; border-bottom: 1px solid var(--line); color: var(--ink) !important; }
.qms-modal-overlay { background: rgba(18,26,35,0.45); }
.scan-modal-card { border-radius: 10px; box-shadow: 0 18px 50px rgba(20,30,45,0.22); }

/* Alert slide-out */
.alert-panel { box-shadow: -10px 0 40px rgba(20,30,45,0.15); }
.alert-panel-header { border-bottom: 1px solid var(--line); }

/* Quality: the Forms & Records sidebar */
.qms-forms-sidebar { background: var(--surface); border-right: 1px solid var(--line); }
.qms-forms-sidebar a.active { background: var(--sunk) !important; border-left-color: var(--slate) !important; color: var(--ink) !important; }
.qms-forms-sidebar a.active .fr-code { color: var(--ink); }

/* ============================================================
   INLINE-STYLE FLATTENING
   Most pages style their banners and buttons inline with the old gradients.
   Rather than edit hundreds of templates (and the JS that builds HTML
   strings), flatten the common gradients here. Light gradients become the
   neutral sunk surface (their dark text stays readable); dark ones become
   flat slate / green / blue.
   ============================================================ */
[style*="linear-gradient(135deg,#dbeafe,#e2e8f0)"],
[style*="linear-gradient(135deg, #dbeafe, #e2e8f0)"],
[style*="linear-gradient(135deg,#e2e8f0,#f1f5f9)"],
[style*="linear-gradient(135deg, #e2e8f0, #f1f5f9)"],
[style*="linear-gradient(to right,#e2e8f0,#f1f5f9)"],
[style*="linear-gradient(to right, #e2e8f0, #f1f5f9)"],
[style*="linear-gradient(135deg,#dbeafe,#bfdbfe)"],
[style*="linear-gradient(to bottom, #f0f1f3, #d8dbe0)"] {
    background: var(--sunk) !important;
    border-color: var(--line) !important;
}
button[style*="linear-gradient(135deg,#dbeafe,#e2e8f0)"],
button[style*="linear-gradient(135deg, #dbeafe, #e2e8f0)"] {
    background: var(--slate) !important;
    color: #fff !important;
    border: 1px solid var(--slate) !important;
}
[style*="linear-gradient(135deg,#1e3a8a,#2563eb)"],
[style*="linear-gradient(135deg,#1e3a5f,#2d5a8e)"],
[style*="linear-gradient(to right,#2d3a4a,#314258)"] {
    background: var(--slate) !important;
}
[style*="linear-gradient(135deg,#047857,#10b981)"],
[style*="linear-gradient(135deg,#059669,#10b981)"],
[style*="linear-gradient(135deg, #059669, #10b981)"],
[style*="linear-gradient(135deg,#047857,#059669)"] {
    background: var(--ok) !important;
}
[style*="linear-gradient(135deg,#d1fae5,#a7f3d0)"] {
    background: var(--ok-soft) !important;
}

/* Soft drop shadows on inline popups → one consistent elevation */
[style*="box-shadow:0 20px 60px"], [style*="box-shadow: 0 20px 60px"] {
    box-shadow: 0 18px 50px rgba(20,30,45,0.22) !important;
}

/* Inline stat boxes (pastel fill + matching border, centred number) used on the
   register pages → white tile with a 3px coloured top edge, like the health strip. */
[style*="flex:1;"][style*="text-align:center"][style*="background:#fef2f2"],
[style*="flex:1;"][style*="text-align:center"][style*="background:#fdf2f8"] { background: var(--surface) !important; border-color: var(--line) !important; box-shadow: inset 0 3px 0 var(--bad); }
[style*="flex:1;"][style*="text-align:center"][style*="background:#fffbeb"] { background: var(--surface) !important; border-color: var(--line) !important; box-shadow: inset 0 3px 0 var(--warn); }
[style*="flex:1;"][style*="text-align:center"][style*="background:#ecfdf5"] { background: var(--surface) !important; border-color: var(--line) !important; box-shadow: inset 0 3px 0 var(--ok); }
[style*="flex:1;"][style*="text-align:center"][style*="background:#eff6ff"],
[style*="flex:1;"][style*="text-align:center"][style*="background:#f0f9ff"] { background: var(--surface) !important; border-color: var(--line) !important; box-shadow: inset 0 3px 0 var(--info); }

/* Navy/blue solid buttons → slate */
button[style*="background:#1e3a8a"], button[style*="background:#1e40af"], button[style*="background:#2563eb"],
a[style*="background:#1e3a8a"], a[style*="background:#1e40af"], a[style*="background:#2563eb"] {
    background: var(--slate) !important; border-color: var(--slate) !important;
}

/* Table headers that were painted dark inline → the standard quiet header */
.data-table th[style*="background"] { background: var(--sunk) !important; color: var(--muted) !important; }

/* Login */
.login-container { background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 18px 50px rgba(20,30,45,0.10); }
.login-wordmark { font: 700 1.6rem/1 var(--mono); letter-spacing: 0.08em; color: var(--ink); margin-bottom: 6px; }
.login-header p { color: var(--muted); font-size: 0.85rem; }

/* Scan mode bar (takes over the top bar) */
.gh-scanbar { background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 6px 18px rgba(20,30,45,0.06); }
.gh-scanbar-group { border-right-color: var(--line); }
.gh-scanbar-head { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); }
.gh-scanbar .scan-mode-btn { background: var(--tile); border-color: var(--tile); border-radius: 6px; font-weight: 600; font-size: 0.76rem; }
.gh-scanbar .scan-mode-btn:hover { background: #0c5a40; border-color: #0c5a40; }
.gh-scanbar .scan-mode-btn.active, .gh-scanbar .scan-mode-btn.active:hover { background: var(--slate); border-color: var(--slate); }
#scan-right-cluster .gh-operator-avatar { background: var(--sunk) !important; }
#scan-right-cluster .gh-operator-avatar svg { stroke: var(--slate) !important; }
#scan-right-cluster .gh-operator-name { color: var(--ink); }
#scan-right-cluster .gh-mini-scan, .global-header.scan-active .gh-mini-scan { background: var(--tile) !important; }
#scan-right-cluster .gh-mini-scan svg, .global-header.scan-active .gh-mini-scan svg { stroke: #fff !important; }
