/* Sellmetrics app shell styles — extracted from base.html (2026-08-08
   efficiency audit): inline CSS was ~19KB re-shipped on every navigation
   with zero browser caching. Served with ?v= content hash. */

        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

        :root {
            --bg-dark: #0a0e17;
            --bg-card: #111827;
            --bg-card-hover: #1a2332;
            --bg-sidebar: #0d1320;
            --border: #1e293b;
            --border-light: #2a3a50;
            --text-primary: #e2e8f0;
            --text-secondary: #8b9cb8;
            --text-muted: #546580;
            --accent-green: #34d399;
            --accent-green-dim: rgba(52, 211, 153, 0.15);
            --accent-red: #f87171;
            --accent-red-dim: rgba(248, 113, 113, 0.15);
            --accent-blue: #60a5fa;
            --accent-blue-dim: rgba(96, 165, 250, 0.15);
            --accent-yellow: #fbbf24;
            --accent-yellow-dim: rgba(251, 191, 36, 0.15);
            --accent-purple: #a78bfa;
            --font-body: 'Plus Jakarta Sans', -apple-system, sans-serif;
            --font-mono: 'JetBrains Mono', monospace;
        }

        body {
            font-family: var(--font-body);
            background: var(--bg-dark);
            color: var(--text-primary);
            display: flex;
            min-height: 100vh;
            line-height: 1.5;
        }

        /* ─── SIDEBAR ─── */
        .sidebar {
            width: 220px;
            height: 100vh;
            background: var(--bg-sidebar);
            border-right: 1px solid var(--border);
            padding: 24px 0;
            position: fixed;
            top: 0;
            left: 0;
            z-index: 50;
            display: flex;
            flex-direction: column;
        }

        .sidebar-brand {
            padding: 0 20px;
            margin-bottom: 32px;
        }

        .sidebar-brand h1 {
            font-family: var(--font-mono);
            font-size: 18px;
            font-weight: 700;
            color: var(--accent-green);
            letter-spacing: -0.5px;
        }

        .sidebar-brand span {
            font-size: 11px;
            color: var(--text-muted);
            font-weight: 400;
            display: block;
            margin-top: 2px;
        }

        /* Cross-app switcher — only renders when tenant has >1 enabled app */
        .app-switcher {
            display: flex;
            gap: 3px;
            padding: 10px 12px 14px;
            border-bottom: 1px solid var(--border);
            margin-bottom: 10px;
        }
        .app-switcher-btn {
            flex: 1;
            min-width: 0;
            padding: 5px 4px;
            font-size: 10px;
            font-weight: 600;
            text-align: center;
            border-radius: 5px;
            border: 1px solid var(--border-light);
            color: var(--text-secondary);
            background: transparent;
            text-decoration: none;
            transition: background 0.12s, color 0.12s;
        }
        .app-switcher-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
        .app-switcher-btn.active {
            background: var(--accent-green-dim);
            color: var(--accent-green);
            border-color: var(--accent-green);
            cursor: default;
        }

        /* flex:1 + overflow makes the nav the scroll region so the footer
           (Settings link) stays pinned + visible even on short viewports /
           when the app-switcher + many nav items overflow. min-height:0 lets
           a flex child shrink below its content height so scrolling engages. */
        .sidebar-nav {
            flex: 1;
            overflow-y: auto;
            min-height: 0;
            /* Themed, auto-hiding scrollbar — invisible until the sidebar is
               hovered, thin + subtle to match the dark theme, no arrow buttons.
               (Default OS scrollbar clashed badly on dark.) */
            scrollbar-width: thin;                      /* Firefox */
            scrollbar-color: transparent transparent;   /* hidden until hover */
        }
        .sidebar:hover .sidebar-nav { scrollbar-color: rgba(255,255,255,0.18) transparent; }
        .sidebar-nav::-webkit-scrollbar { width: 6px; }
        .sidebar-nav::-webkit-scrollbar-track { background: transparent; }
        .sidebar-nav::-webkit-scrollbar-button { display: none; height: 0; width: 0; }
        .sidebar-nav::-webkit-scrollbar-thumb {
            background: transparent;                    /* hidden by default */
            border-radius: 3px;
        }
        .sidebar:hover .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
        .sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.30); }

        /* Subtle "more below" cue — a soft fade at the bottom of the nav, shown
           ONLY when items sit below the fold (JS toggles .can-scroll). Sticky so
           it pins to the visible bottom edge as the list scrolls, and
           pointer-events:none so it never sits on top of a link. Fades to the
           sidebar bg so it reads as "content continues" without any chrome. */
        .sidebar-nav::after {
            content: '';
            display: block;
            position: sticky;
            bottom: 0;
            height: 26px;
            margin-top: -26px;            /* overlay — adds no scroll height */
            background: linear-gradient(to bottom, transparent, var(--bg-sidebar));
            pointer-events: none;
            opacity: 0;
            transition: opacity .18s ease;
        }
        .sidebar-nav.can-scroll::after { opacity: 1; }

        .sidebar-nav a {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 20px;
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.15s ease;
            border-left: 3px solid transparent;
        }

        .sidebar-nav a:hover {
            color: var(--text-primary);
            background: rgba(255,255,255,0.03);
        }

        .sidebar-nav a.active {
            color: var(--accent-green);
            background: var(--accent-green-dim);
            border-left-color: var(--accent-green);
        }

        .sidebar-nav a svg {
            width: 18px;
            height: 18px;
            opacity: 0.7;
        }

        .sidebar-nav a.active svg { opacity: 1; }

        .sidebar-footer {
            padding: 16px 20px;
            border-top: 1px solid var(--border);
        }

        .sidebar-footer p {
            font-size: 11px;
            color: var(--text-muted);
            font-family: var(--font-mono);
        }

        /* ─── MAIN CONTENT ─── */
        .main {
            margin-left: 220px;
            flex: 1;
            padding: 32px;
            min-height: 100vh;
        }

        .page-header {
            margin-bottom: 28px;
        }

        .page-header h2 {
            font-size: 22px;
            font-weight: 700;
            letter-spacing: -0.3px;
        }

        .page-header p {
            color: var(--text-secondary);
            font-size: 14px;
            margin-top: 4px;
        }

        /* ─── CARDS ─── */
        .card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 20px;
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 16px;
        }

        .card-header h3 {
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 0.8px;
            color: var(--text-muted);
            font-weight: 600;
        }

        /* ─── KPI ROW ─── */
        .kpi-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
            gap: 10px;
            margin-bottom: 24px;
        }

        /* Dashboard overview: force all cards into one row */
        .kpi-grid-fit {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
            gap: 8px;
            margin-bottom: 24px;
        }
        .kpi-grid-fit .kpi-value {
            font-size: 17px;
        }
        .kpi-grid-fit .kpi { padding: 10px 12px; }

        .kpi {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 10px;
            padding: 12px 14px;
            transition: border-color 0.2s;
        }

        .kpi:hover { border-color: var(--border-light); }

        .kpi-label {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.6px;
            color: var(--text-muted);
            font-weight: 600;
            margin-bottom: 4px;
        }

        .kpi-value {
            font-family: var(--font-mono);
            font-size: 20px;
            font-weight: 700;
            letter-spacing: -0.5px;
        }

        .kpi-value.green { color: var(--accent-green); }
        .kpi-value.red { color: var(--accent-red); }
        .kpi-value.blue { color: var(--accent-blue); }
        .kpi-value.yellow { color: var(--accent-yellow); }
        .kpi-value.purple { color: var(--accent-purple); }

        .kpi-sub {
            font-size: 11px;
            color: var(--text-secondary);
            margin-top: 3px;
        }

        /* ─── GRID LAYOUTS ─── */
        .grid-2 {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
            margin-bottom: 24px;
        }

        .grid-3 {
            display: grid;
            grid-template-columns: 2fr 1fr;
            gap: 20px;
            margin-bottom: 24px;
        }

        /* ─── TABLE ─── */
        .table-wrapper { overflow-x: auto; }

        table {
            width: 100%;
            border-collapse: collapse;
            font-size: 13px;
            table-layout: auto;
        }

        thead th {
            text-align: left;
            padding: 10px 12px;
            color: var(--text-muted);
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.6px;
            font-weight: 600;
            border-bottom: 1px solid var(--border);
            white-space: nowrap;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }

        /* Column resize handle */
        thead th .col-resize-handle {
            position: absolute;
            right: 0;
            top: 0;
            bottom: 0;
            width: 5px;
            cursor: col-resize;
            background: transparent;
            z-index: 10;
            transition: background 0.15s;
        }
        thead th .col-resize-handle:hover,
        thead th .col-resize-handle.active {
            background: var(--accent-blue);
        }

        thead th:hover { color: var(--text-secondary); }

        tbody td {
            padding: 10px 12px;
            border-bottom: 1px solid rgba(30,41,59,0.5);
            font-family: var(--font-mono);
            font-size: 12px;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        tbody tr:hover { background: rgba(255,255,255,0.02); }

        td.title-cell {
            font-family: var(--font-body);
            overflow: hidden;
            text-overflow: ellipsis;
            color: var(--text-secondary);
        }

        td.positive { color: var(--accent-green); }
        td.negative { color: var(--accent-red); }

        /* Number inputs: hide the browser spinner arrows (COGS cost fields
           etc.) — typed entry only, arrows just add visual noise. */
        input[type="number"]::-webkit-inner-spin-button,
        input[type="number"]::-webkit-outer-spin-button {
            -webkit-appearance: none;
            margin: 0;
        }
        input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

        /* Order/PO identifier columns must never ellipsis-clip: users copy &
           look these up. The global `tbody td` ellipsis + the resizable-columns
           JS (which pins table-layout:fixed widths) would otherwise cut a full
           order number down to e.g. "112-4177355…" on a narrow viewport. The
           min-width reserves room before the JS pins widths; overflow:visible
           is the belt-and-suspenders so it stays readable even if pinned tight. */
        th.col-orderid, td.col-orderid {
            min-width: 185px;
            white-space: nowrap;
            overflow: visible;
            text-overflow: clip;
        }


        /* ─── /skus: a financial table must never clip a number ───
           The global `tbody td` ellipsis is right for prose columns and wrong
           for money: "$1,049…" is not a number, it is a rumour. The sku table
           is sized wide (see its colgroup) and scrolls horizontally instead;
           only the product title is allowed to ellipsis, because it is prose
           and the full text lives in the drill-down. */
        .sku-table tbody td {
            overflow: visible;
            text-overflow: clip;
            white-space: nowrap;
        }
        /* A long SKU used to paint straight over PRODUCT: the rule above is
           nowrap + overflow:visible so currency is never clipped, which for a
           28-character SKU means it simply overlaps the next column (Tyler
           screenshot 2026-08-13). Identifiers wrap inside their own cell —
           they are not numbers, so a line break costs nothing. */
        .sku-table td.sku-cell {
            white-space: normal;
            overflow-wrap: anywhere;
            word-break: break-word;
        }
        .sku-table td.sku-cell .sku-id { font-family: var(--font-mono); font-size: 11.5px; }
        .sku-table td.sku-cell .ids { display: block; font-size: 10px; margin-top: 2px; }

        /* Two clean lines then an ellipsis. Previously white-space:normal +
           overflow:hidden let a long title wrap to five lines and get sliced
           mid-word with no ellipsis, so it read as corrupted rather than
           shortened. Full text on hover (title attr) and in the drill-down. */
        .sku-table td.title-cell { white-space: normal; overflow: hidden; }
        /* Clamp an inner span, not the <td>: display:-webkit-box on a table cell
           stops it being a table-cell, the clamp is ignored, and a third line
           bleeds out under the row. */
        .sku-table td.title-cell .clamp2 {
            display: -webkit-box;
            -webkit-line-clamp: 2;
            line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        /* Stacked secondary figure: avg price, $/ea, WFS split, refund count.
           Vertical space is free in this table; horizontal space is not. */
        .sku-table td .sub {
            display: block;
            font-size: 10px;
            color: var(--text-muted);
            white-space: normal;
            line-height: 1.25;
            margin-top: 1px;
        }
        .sku-table td .sub.pos { color: var(--accent-green); }
        /* Keep the horizontal scroll inside the card so a wide table can never
           slide under the fixed sidebar. */
        .table-wrapper { overflow-x: auto; max-width: 100%; }

        /* A flex item defaults to min-width:auto, so <main> refused to shrink
           below its widest child and grew to fit the table instead. .card and
           .table-wrapper then inherited that width, `max-width:100%` resolved
           to the table's own width, and overflow-x never engaged — so the whole
           PAGE scrolled sideways (measured on /skus: main 1846px, document
           2066px, viewport 1234px) and the sidebar scrolled away with it.
           min-width:0 lets main shrink to the flex line; the table then scrolls
           inside its own wrapper, which is what .table-wrapper was always for.
           Applies to every wide table in the app, not just /skus. 2026-08-13. */
        main.main { min-width: 0; }

        /* ─── BADGES ─── */
        .badge {
            display: inline-block;
            padding: 3px 8px;
            border-radius: 4px;
            font-size: 11px;
            font-weight: 600;
            font-family: var(--font-mono);
        }

        .badge-green { background: var(--accent-green-dim); color: var(--accent-green); }
        .badge-red { background: var(--accent-red-dim); color: var(--accent-red); }
        .badge-blue { background: var(--accent-blue-dim); color: var(--accent-blue); }
        .badge-gray { background: rgba(148,163,184,0.15); color: #94a3b8; }
        .badge-yellow { background: var(--accent-yellow-dim); color: var(--accent-yellow); }
        .badge-purple { background: rgba(167,139,250,0.15); color: var(--accent-purple); }

        /* ─── SEARCH / FILTER ─── */
        .toolbar {
            display: flex;
            gap: 12px;
            margin-bottom: 20px;
            align-items: center;
        }

        .search-input {
            background: var(--bg-card);
            border: 1px solid var(--border);
            color: var(--text-primary);
            padding: 8px 14px;
            border-radius: 6px;
            font-size: 13px;
            font-family: var(--font-body);
            width: 300px;
            outline: none;
            transition: border-color 0.2s;
        }

        .search-input:focus { border-color: var(--accent-blue); }
        .search-input::placeholder { color: var(--text-muted); }

        .filter-btn {
            background: var(--bg-card);
            border: 1px solid var(--border);
            color: var(--text-secondary);
            padding: 8px 14px;
            border-radius: 6px;
            font-size: 13px;
            font-family: var(--font-body);
            cursor: pointer;
            transition: all 0.15s;
            text-decoration: none;
        }

        .filter-btn:hover { border-color: var(--border-light); color: var(--text-primary); }
        .filter-btn.active { background: var(--accent-green-dim); border-color: var(--accent-green); color: var(--accent-green); }

        /* ─── PAGINATION ─── */
        .pagination {
            display: flex;
            gap: 8px;
            justify-content: center;
            margin-top: 20px;
        }

        .pagination a {
            color: var(--text-secondary);
            text-decoration: none;
            padding: 6px 12px;
            border-radius: 4px;
            font-size: 13px;
            background: var(--bg-card);
            border: 1px solid var(--border);
        }

        .pagination a:hover { border-color: var(--border-light); }
        .pagination a.current { background: var(--accent-green-dim); color: var(--accent-green); border-color: var(--accent-green); }

        /* ─── CHART CONTAINER ─── */
        .chart-container {
            position: relative;
            height: 260px;
        }

        /* ─── MODAL ─── */
        .modal-backdrop {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.7);
            z-index: 100;
            justify-content: center;
            align-items: center;
        }

        .modal-backdrop.active { display: flex; }

        .modal {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 24px;
            width: 600px;
            max-height: 80vh;
            overflow-y: auto;
        }

        .modal h3 {
            font-size: 16px;
            margin-bottom: 16px;
        }

        /* ─── HAMBURGER BUTTON (mobile only) ─── */
        .hamburger {
            display: none;
            position: fixed;
            top: 12px;
            left: 12px;
            z-index: 60;
            background: var(--bg-sidebar);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 8px;
            cursor: pointer;
            color: var(--text-secondary);
            transition: all 0.2s ease;
        }
        .hamburger:hover { color: var(--text-primary); border-color: var(--border-light); }
        .hamburger svg { display: block; width: 22px; height: 22px; }

        /* ─── MOBILE OVERLAY ─── */
        .sidebar-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.6);
            z-index: 45;
            opacity: 0;
            /* On mobile this element is display:block at all times so the fade
               can animate. opacity:0 hides it visually but does NOT stop it
               from capturing taps — without pointer-events:none the invisible
               overlay sits over the whole page body (z-index 45 > static .main)
               and eats every tap, leaving the content unclickable when the menu
               is closed. Only re-enable taps when it's the active backdrop. */
            pointer-events: none;
            transition: opacity 0.25s ease;
        }
        .sidebar-overlay.active { opacity: 1; pointer-events: auto; }

        /* ─── RESPONSIVE ─── */
        @media (max-width: 1200px) {
            .grid-2, .grid-3 { grid-template-columns: 1fr; }
        }

        @media (max-width: 768px) {
            .hamburger { display: block; }

            .sidebar {
                transform: translateX(-100%);
                transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            }
            .sidebar.open { transform: translateX(0); }
            .sidebar-overlay { display: block; }

            .main {
                margin-left: 0;
                padding: 20px 16px;
                padding-top: 56px; /* space for hamburger */
            }

            .page-header h2 { font-size: 18px; }
            .page-header p { font-size: 13px; }

            /* Tables scroll horizontally on mobile */
            .table-wrapper, table { display: block; overflow-x: auto; }

            /* Modal fits mobile screens */
            .modal { width: 95vw; max-height: 90vh; padding: 16px; }
        }
    