/*
 * Server/public/ui/tokens.css — shared design tokens for /, /live and /dashboard
 * (IMPLEMENTATION_PLAN_ui-redesign.md). Load it BEFORE the page stylesheet.
 *
 * Monochrome UI: colour is only used for meaning (up / down / warn / info).
 * Themes: light by default, dark when the OS prefers dark, and an explicit
 * html[data-theme="light" | "dark"] (set by ui/theme.js) wins over the OS.
 */

/* ---------- scale, type, light theme (default) ---------- */
:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-num: var(--font-sans); /* Inter tabular figures, see body rule below */

    --r-frame: 16px;
    --r-panel: 12px;
    --r-control: 8px;
    --r-pill: 999px;

    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;

    --fs-label: 11px;
    --fs-small: 12px;
    --fs-base: 14px;
    --fs-title: 15px;
    --fs-kpi: 30px;

    --ease: cubic-bezier(.2, .8, .2, 1);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .06);

    color-scheme: light;
    --canvas:      #F3F3F1;
    --frame:       #EBEBE8;
    --panel:       #FFFFFF;
    --panel-hover: #F6F6F4;
    --line:        #E2E2DE;
    --line-soft:   #EEEEEB;
    --line-strong: #D1D1CC;

    --text:   #141414;
    --text-2: #3F3F3B;
    --text-3: #65655F;
    --text-4: #85857F;

    --accent:      #141414;
    --on-accent:   #FFFFFF;
    --accent-soft: rgba(20, 20, 20, .06);

    --up:        #13743A;
    --up-soft:   #E7F5EC;
    --up-line:   #B7E2C6;
    --down:      #C81E1E;
    --down-soft: #FDECEC;
    --down-line: #F5C2C2;
    --danger-solid: #C81E1E; /* filled danger button, white text */
    --up-solid: #13743A;    /* filled success / info / warning surfaces with white text */
    --info-solid: #1D4ED8;
    --warn-solid: #A15C07;
    --warn:      #8C5406;
    --warn-soft: #FDF4E1;
    --warn-line: #F1DCAA;
    --info:      #1D4ED8;
    --info-soft: #EAF0FE;
    --info-line: #C7D6FB;

    --hatch: rgba(0, 0, 0, .035);
}

/* ---------- dark theme: OS preference, unless the page forces light ---------- */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --canvas:      #0E0E10;
        --frame:       #151517;
        --panel:       #1A1A1D;
        --panel-hover: #212125;
        --line:        #27272B;
        --line-soft:   #1F1F23;
        --line-strong: #36363C;
        --text:   #F2F2F3;
        --text-2: #C4C4CA;
        --text-3: #8E8E96;
        --text-4: #717179;
        --accent:      #F2F2F3;
        --on-accent:   #0E0E10;
        --accent-soft: rgba(242, 242, 243, .08);
        --up:        #3DD68C;
        --up-soft:   rgba(61, 214, 140, .12);
        --up-line:   rgba(61, 214, 140, .32);
        --down:      #FF6B6B;
        --down-soft: rgba(255, 107, 107, .12);
        --down-line: rgba(255, 107, 107, .32);
        --danger-solid: #D92D2D;
        --up-solid: #11803F;
        --info-solid: #2E62D9;
        --warn-solid: #A86207;
        --warn:      #F5B544;
        --warn-soft: rgba(245, 181, 68, .12);
        --warn-line: rgba(245, 181, 68, .32);
        --info:      #7AA7FF;
        --info-soft: rgba(122, 167, 255, .12);
        --info-line: rgba(122, 167, 255, .32);
        --hatch: rgba(255, 255, 255, .028);
        --shadow-pop: 0 8px 24px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .4);
    }
}

/* ---------- dark theme: explicit choice (same values) ---------- */
:root[data-theme="dark"] {
    color-scheme: dark;
    --canvas:      #0E0E10;
    --frame:       #151517;
    --panel:       #1A1A1D;
    --panel-hover: #212125;
    --line:        #27272B;
    --line-soft:   #1F1F23;
    --line-strong: #36363C;
    --text:   #F2F2F3;
    --text-2: #C4C4CA;
    --text-3: #8E8E96;
    --text-4: #717179;
    --accent:      #F2F2F3;
    --on-accent:   #0E0E10;
    --accent-soft: rgba(242, 242, 243, .08);
    --up:        #3DD68C;
    --up-soft:   rgba(61, 214, 140, .12);
    --up-line:   rgba(61, 214, 140, .32);
    --down:      #FF6B6B;
    --down-soft: rgba(255, 107, 107, .12);
    --down-line: rgba(255, 107, 107, .32);
    --danger-solid: #D92D2D;
    --up-solid: #11803F;
    --info-solid: #2E62D9;
    --warn-solid: #A86207;
    --warn:      #F5B544;
    --warn-soft: rgba(245, 181, 68, .12);
    --warn-line: rgba(245, 181, 68, .32);
    --info:      #7AA7FF;
    --info-soft: rgba(122, 167, 255, .12);
    --info-line: rgba(122, 167, 255, .32);
    --hatch: rgba(255, 255, 255, .028);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .4);
}

/*
 * ---------- legacy names -> new tokens ----------
 * The three page stylesheets were written against their own token names
 * (Binance-like palette, yellow brand). They now resolve to the tokens
 * above; each page phase replaces them with the new names and this block
 * shrinks. Brand / yellow map to the monochrome accent.
 */
:root {
    --bg:           var(--canvas);
    --bg-elevated:  var(--frame);
    --bg-card:      var(--panel);
    --bg-hover:     var(--panel-hover);
    --bg-active:    var(--line-strong);
    --bg-subtle:    var(--frame);
    --bg-1:         var(--panel);
    --bg-2:         var(--panel-hover);
    --surface:      var(--panel);
    --surface-2:    var(--panel-hover);

    --border:        var(--line);
    --border-light:  var(--line-strong);
    --border-soft:   var(--line-soft);
    --border-subtle: var(--line);
    --border-color:  var(--line);

    --text-1:     var(--text);
    --text-color: var(--text);
    --text-muted: var(--text-3);
    --text-faint: var(--text-4);

    --brand:         var(--accent);
    --brand-soft:    var(--accent-soft);
    --brand-border:  var(--line-strong);
    --accent-color:  var(--accent);
    --yellow:        var(--accent);
    --yellow-active: var(--accent);
    --yellow-dim:    var(--accent-soft);

    --up-border:   var(--up-line);
    --up-bg:       var(--up-soft);
    --down-border: var(--down-line);
    --down-text:   var(--down);
    --info-text:   var(--info);
    --success:     var(--up);
    --danger:      var(--down);
    --warning:     var(--warn);
    --flat:        var(--text-3);
    --flat-soft:   var(--accent-soft);
}

/* ---------- base ---------- */
[hidden] { display: none !important; } /* the attribute must win over component display rules */
/*
 * Tabular figures only where numbers are shown (tables, KPIs, the former
 * monospace spots that now use var(--font-num)): in Inter the feature also
 * widens punctuation such as "-", which looks wrong in running text.
 */
table, .num, .ui-kpi-value, .ui-table, input[type="number"] { font-variant-numeric: tabular-nums; }
html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--canvas);
    color: var(--text);
}

:focus-visible {
    outline: 2px solid var(--text-3);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
