/* ============================================================================
   theme.css — the design tokens and base styles every mng page loads first.

   Colours exist ONLY here. Pages and components use the tokens (var(--surface),
   var(--text-2), rgb(var(--success-rgb) / .15) …), never a hex value, so the
   light and dark themes are the same CSS with different numbers underneath.

   Theme choice: <html data-theme="auto|light|dark"> (lib/ui.php themeAttr(),
   from the mng_theme cookie). "auto" — and a page with no attribute — follows
   the device setting.

   Replaces dark-theme.css (2026-10-13), which repainted a light UI dark with
   ~100 !important overrides. Nothing here is !important except the
   reduced-motion switch at the end.
   ============================================================================ */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin-wght.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                   U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191,
                   U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Dark (default) -------------------------------------------------------- */
:root {
    color-scheme: dark;

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Malayalam', sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

    /* "ink" is what translucent overlays are made of: white on dark, slate on light.
       rgb(var(--ink) / .06) is a hover wash in either theme. */
    --ink: 255 255 255;

    --bg: #0c1120;
    --bg-bar: #10172a;
    --surface: #141b2e;
    --surface-2: #1a2237;
    --surface-3: #232d46;
    --field: #182036;
    --border: #252f48;
    --border-strong: #35415e;

    --text: #e8ecf4;
    --text-2: #a9b2c7;
    --text-3: #7c869e;

    --accent: #22c3ee;
    --accent-rgb: 34 195 238;
    --accent-hover: #52d2f3;
    --accent-fg: #04222c;
    --accent-text: #56d2f3;

    --success: #3ccf8e;  --success-rgb: 60 207 142;
    --warning: #f2b544;  --warning-rgb: 242 181 68;
    --danger: #f45d63;   --danger-rgb: 244 93 99;
    --info: #6aa6f8;     --info-rgb: 106 166 248;
    --violet: #a68af6;   --violet-rgb: 166 138 246;
    --orange: #f59a4a;   --orange-rgb: 245 154 74;
    --whatsapp: #25d366;
    --on-fill: #0b1220;   /* text on a solid status fill (bright fills in dark, deep fills in light) */

    --shadow-1: 0 1px 2px rgb(0 0 0 / .35);
    --shadow-2: 0 4px 16px rgb(0 0 0 / .32);
    --shadow-pop: 0 14px 40px rgb(0 0 0 / .5);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    --bar-h: 56px;
    --tabbar-h: 0px;

    /* Names the pages were written against — kept so nothing that still says
       var(--card-bg) breaks. New code uses the tokens above. */
    --primary-color: var(--accent);
    --primary-hover: var(--accent-hover);
    --dark-bg: var(--bg);
    --card-bg: var(--surface);
    --secondary-bg: var(--surface-2);
    --text-color: var(--text);
    --text-muted: var(--text-2);
    --border-color: var(--border);
    --input-bg: var(--field);
    --input-border: var(--border-strong);
}

/* ---- Light ------------------------------------------------------------------
   Written twice (explicit choice, and "auto" on a light device) because plain
   CSS cannot share a block between a selector and a media query. Keep the two
   copies identical. */
:root[data-theme="light"] {
    color-scheme: light;
    --ink: 15 23 42;
    --bg: #f3f5f9;  --bg-bar: #ffffff;  --surface: #ffffff;  --surface-2: #f4f6fa;  --surface-3: #e9edf4;
    --field: #ffffff;  --border: #e2e7ef;  --border-strong: #cdd5e2;
    --text: #131b2d;  --text-2: #4a556d;  --text-3: #79849b;
    --accent: #0a9ec7;  --accent-rgb: 10 158 199;  --accent-hover: #0888ab;  --accent-fg: #ffffff;  --accent-text: #0780a2;  --on-fill: #ffffff;
    --success: #12925a;  --success-rgb: 18 146 90;
    --warning: #b4730c;  --warning-rgb: 214 146 30;
    --danger: #d8353d;   --danger-rgb: 216 53 61;
    --info: #2d6ad3;     --info-rgb: 45 106 211;
    --violet: #6f4bd6;   --violet-rgb: 111 75 214;
    --orange: #cc6316;   --orange-rgb: 214 112 32;
    --shadow-1: 0 1px 2px rgb(15 23 42 / .06);
    --shadow-2: 0 4px 14px rgb(15 23 42 / .08);
    --shadow-pop: 0 12px 36px rgb(15 23 42 / .16);
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]):not([data-theme="light"]) {
        color-scheme: light;
        --ink: 15 23 42;
        --bg: #f3f5f9;  --bg-bar: #ffffff;  --surface: #ffffff;  --surface-2: #f4f6fa;  --surface-3: #e9edf4;
        --field: #ffffff;  --border: #e2e7ef;  --border-strong: #cdd5e2;
        --text: #131b2d;  --text-2: #4a556d;  --text-3: #79849b;
        --accent: #0a9ec7;  --accent-rgb: 10 158 199;  --accent-hover: #0888ab;  --accent-fg: #ffffff;  --accent-text: #0780a2;  --on-fill: #ffffff;
        --success: #12925a;  --success-rgb: 18 146 90;
        --warning: #b4730c;  --warning-rgb: 214 146 30;
        --danger: #d8353d;   --danger-rgb: 216 53 61;
        --info: #2d6ad3;     --info-rgb: 45 106 211;
        --violet: #6f4bd6;   --violet-rgb: 111 75 214;
        --orange: #cc6316;   --orange-rgb: 214 112 32;
        --shadow-1: 0 1px 2px rgb(15 23 42 / .06);
        --shadow-2: 0 4px 14px rgb(15 23 42 / .08);
        --shadow-pop: 0 12px 36px rgb(15 23 42 / .16);
    }
}

/* ---- Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11';   /* Inter's single-storey a reads better at small sizes */
}

h1, h2, h3, h4, h5, h6 { color: var(--text); line-height: 1.25; letter-spacing: -0.011em; font-weight: 650; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

a { color: var(--accent-text); }
a:hover { color: var(--accent-hover); }

small, .small { color: var(--text-2); }
.text-muted, .subtitle { color: var(--text-2); }
.text-faint { color: var(--text-3); }
.num, .tabular { font-variant-numeric: tabular-nums; }
code, kbd, .mono { font-family: var(--font-mono); font-size: .92em; }
code { background: rgb(var(--accent-rgb) / .1); color: var(--accent-text); padding: 1px 6px; border-radius: 4px; }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px; color: var(--text-2); }

hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

::selection { background: rgb(var(--accent-rgb) / .3); }

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

/* ---- Form controls ---------------------------------------------------------
   Every page assumes full-width fields; that default is kept. */
input, select, textarea {
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 9px 11px;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: rgb(var(--accent-rgb) / .45); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(var(--accent-rgb) / .2);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:disabled, select:disabled, textarea:disabled, input[readonly] { opacity: .7; cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; accent-color: var(--accent); box-shadow: none; }
input[type="color"] { padding: 2px; height: 38px; }
input[type="file"] { padding: 7px; }
label { color: var(--text); }
button { font: inherit; }

/* ---- Tables (base; .data-table in mng.css is the full component) ----------- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; color: var(--text); }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-3); font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
thead th { background: var(--surface-2); }
tbody tr:hover { background: rgb(var(--ink) / .025); }

/* ---- Scrollbars ------------------------------------------------------------ */
* { scrollbar-color: rgb(var(--ink) / .2) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgb(var(--ink) / .18); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgb(var(--ink) / .3); background-clip: content-box; }

/* ---- Icons (lib/ui.php icon(); sprite inlined by renderIconSprite()) ------- */
.i {
    width: 1.15em; height: 1.15em;
    flex: none;
    vertical-align: -0.2em;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.i-sm { width: 14px; height: 14px; }
.i-lg { width: 20px; height: 20px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
