/* ====================================================================
   AVedge BOQ Portal — one palette, two themes. THE single source.

   This file was lifted verbatim out of app.css so that the BOQ builder
   (app.css), the passive catalogue (passive_builder.css), the network
   diagram editor (topology_editor.css) and the Zoho attach dialog
   (zoho_attach.css) all read the SAME tokens. There is deliberately no
   second palette anywhere: a colour that is themed here is themed on
   every page at once, and one that is forgotten is forgotten on every
   page at once — which a test catches.

   Every colour comes from a custom property defined once on :root
   (light) and overridden once under [data-theme="dark"]. Nothing
   outside this file may hard-code a colour.

   Naming: --<family>-bg / -tx / -bd  = fill / text / border of one
   meaning-bearing family (ok, pos, amber, err, crit, info, jun, vio).
   Those triples are what keep the triage severities distinguishable
   from each other rather than merely legible.

   The --canvas-* family at the end is the network diagram's own
   surface. It is a VIEWING palette only: the exported SVG/PNG and the
   HLD render carry their own hard-coded light colours and never read
   these (see SVG_EXPORT_CSS in topology_editor.js).

   Theme selection: <html data-theme="light|dark">, resolved before
   first paint by an inline script in every page, from
   localStorage["avedge_boq_theme"], falling back to the OS setting.

   The AVedge finance dashboard reads this same palette. It cannot link
   this path (it is served from AVedge/website/static/ and also mounted
   standalone), so the file is MIRRORED to
   AVedge/website/static/css/theme.css and a test fails if the two ever
   diverge — see AVedge/website/test_finance_theme.py. Edit THIS file and
   re-run AVedge/website/mirror_theme.py; never edit the mirror. The
   finance pages resolve the same localStorage key, so the BOQ portal and
   the dashboard switch together. Their CSP is script-src 'self', so the
   pre-paint resolver there is an external file, not an inline script.
   ==================================================================== */
:root {
  color-scheme: light;

  /* --- brand ------------------------------------------------------ */
  --navy: #1B2A4A;              /* topbar gradient start */
  --navy-2: #24365e;            /* topbar gradient middle */
  --navy-3: #2b3f6e;            /* topbar gradient end */
  --navy-fill: #1B2A4A;         /* filled UI: table heads, active pills, modal head */
  --navy-fill-hover: #24365e;
  --navy-fill-bd: #1B2A4A;      /* edge of a navy-filled control (light: = the fill) */
  --on-navy: #FFFFFF;           /* text on a navy fill */
  --on-navy-soft: #CFE3F5;      /* secondary text/icons on the header */
  --on-navy-dim: #B9C6DE;       /* tertiary text on the header */
  --on-violet: #FFFFFF;         /* text on a violet fill */
  --accent-tx: #1B2A4A;         /* navy used AS TEXT (SKUs, headings, grand total) */
  --violet: #6C4BD8;            /* violet fill */
  --violet-hover: #5a3cc2;
  --violet-tx: #6C4BD8;         /* violet used as text */
  --violet-bd: #6C4BD8;
  --violet-tint: #F6F3FD;       /* violet hover wash */
  --cyan: #19B6D9;
  --cyan-hover: #16a6c6;
  --cyan-bd: #1296B4;           /* 3.5:1 vs the panel; #14a3c3 was 2.98 */
  --on-cyan: #06323C;
  --cyan-tint: #F7FCFE;
  --focus: #0E90B4;             /* focus ring — 3:1 against the page */

  /* --- surfaces --------------------------------------------------- */
  --bg: #F2F4F8;
  --panel: #FFFFFF;
  --panel-2: #FAFBFD;           /* sub-panels, toolbars, commit bars */
  --panel-3: #EDF1F8;           /* group bands, section rows, code chips */
  --inset: #F4F6FB;             /* installed / read-only content */
  --zebra: #F7F9FC;
  --row-child: #FCFCFE;         /* nested BOQ accessory lines */
  --row-out: #FBFBFD;           /* excluded rows */
  --field-bg: #FFFFFF;
  --disabled-bg: #F5F5F5;
  --border: #D8DDE7;            /* hairlines and container edges */
  --border-soft: #EDEFF4;
  --field-bd: #838B9A;          /* interactive control edges — 3:1 */
  --shadow: rgba(0,0,0,.25);
  --overlay: rgba(27,42,74,.45);

  /* --- text ------------------------------------------------------- */
  --ink: #22252B;
  --muted: #616A78;
  --sub-tx: #5A6B8C;            /* subordinate SKUs (accessories, installed) */
  --link: #0E7490;

  /* --- ok / deep green -------------------------------------------- */
  --ok-bg: #E8F8EE;
  --ok-tx: #16794C;
  --ok-bd: #B4E6C9;
  /* --- pos / light green (accepted, clean, substituted-in) --------- */
  --pos-bg: #F1FAF3;
  --pos-tx: #1E7A45;
  --pos-bd: #BFE5CB;
  /* --- amber (PRICE NEEDED, discontinued, omissions, gates) -------- */
  --amber-bg: #FFF3CD;
  --amber-tx: #7A5F12;
  --amber-bd: #EAD48A;
  --amber-soft: #FDF6E3;
  --amber-cell: #FFF9E8;
  --amber-strong: #6b5310;
  --amber-code-bg: #fff8e1;
  /* --- err / mid red ---------------------------------------------- */
  --err-bg: #FDECEA;
  --err-tx: #B0352A;
  --err-bd: #F2B8B2;
  --err-row: #FDF1EF;
  --err-soft: #FFF6F5;
  /* --- crit / deep red (triage errors, negative slack) ------------- */
  --crit-bg: #FBE6E4;
  --crit-tx: #A12F23;
  --crit-glow: rgba(161,47,35,.18);
  --danger: #C0392B;
  /* --- info / cyan ------------------------------------------------ */
  --info-bg: #E1F5FB;
  --info-tx: #0E7490;
  --info-bd: #A5E3F2;
  --info2-bg: #EEF6FB;
  --info2-bd: #BFE0EE;
  /* --- jun / carried-reference orange ------------------------------ */
  --jun-bg: #FDEBD8;
  --jun-tx: #8F5210;
  --jun-bd: #F5CFA0;
  /* --- violet soft (Aug price, overrides, substitutions) ----------- */
  --vio-bg: #EDE8FB;
  --vio-bd: #D4C8F5;
  --sub-vio-bg: #EDE8FC;
  --sub-vio-tx: #4C33A8;
  --sub-vio-bd: #CFC2F2;
  /* --- neutral chip ----------------------------------------------- */
  --neutral-bg: #F1F2F4;
  --neutral-bd: #D8DDE7;
  /* --- Zoho subform chips ----------------------------------------- */
  --sf-hw-bg: #E9F0FB;  --sf-hw-bd: #BBD0EC;  --sf-hw-tx: #1B4A85;
  --sf-sw-bg: #F3EEFE;  --sf-sw-bd: #CFC0F3;  --sf-sw-tx: #52379F;

  /* --- data visualisation (finance dashboard charts) --------------
     One categorical set, two selected steps — NOT an automatic flip. The
     light steps were validated against the panel (#FFFFFF) and the dark
     steps against the dark panel (#141922) with the data-viz validator:
     lightness band, chroma floor, all-pairs CVD separation (deutan/tritan),
     normal-vision separation and >=3:1 contrast all PASS in both modes.
       light  worst all-pairs CVD dE 14.9 · normal dE 21.6
       dark   worst all-pairs CVD dE 10.6 · normal dE 17.6
     Slot order is fixed and never cycled: 1 cyan, 2 violet, 3 amber, then
     --chart-other, a deliberate neutral for the "everything else" band —
     it is grey on purpose and is never a fourth series.
     --chart-tick / --chart-label are TEXT on the panel and carry text
     contrast (5.5:1 / 15.4:1 light, 6.9:1 / 14.6:1 dark); --chart-grid is
     deliberately recessive. Chart marks read these through JavaScript, so a
     value forgotten here is forgotten on every chart at once. */
  --chart-1: #0098BA;
  --chart-2: #6C4BD8;
  --chart-3: #B0660A;
  --chart-other: #7C8698;
  --chart-fill-1: rgba(0,152,186,.10);
  --chart-grid: rgba(27,42,74,.12);
  --chart-tick: #616A78;
  --chart-label: #22252B;
  --chart-tip-bg: #FFFFFF;
  --chart-tip-bd: #D8DDE7;

  /* --- misc ------------------------------------------------------- */
  --count-chip: rgba(255,255,255,.75);
  --lead-glow: rgba(108,75,216,.09);
  --spinner-track: rgba(27,42,74,.25);
  --spinner-head: #1B2A4A;
  --on-navy-rule: rgba(255,255,255,.35);
  --on-navy-bd: rgba(255,255,255,.4);
  /* a warning that lives ON the navy header, so it is the same amber in
     both themes (the header is navy either way) */
  --warn-on-navy: #f4b400;
  /* Deliberately NOT overridden in dark. It is the paper an exported
     artefact is printed on — a preview of a PNG that Zoho will receive, or
     of a page in an HLD. Showing it on anything but white would make the
     preview a lie. If you find yourself wanting a dark value here, you want
     --canvas-paper instead. */
  --artefact-white: #FFFFFF;

  /* --- network-diagram canvas (VIEWING ONLY — see header) ---------- */
  /* Light theme reproduces the document exactly: white sheet, the same
     #231D5E ink build_topology_visio.py draws with, and the same white
     scroll surround the editor has always had. */
  --canvas-desk: #FFFFFF;       /* the scroll area around the sheet */
  --canvas-paper: #FFFFFF;      /* the sheet itself */
  --canvas-grid: rgba(27,42,74,.045);
  --canvas-ink: #231D5E;        /* titles, node labels, edges, legend text */
  --canvas-ink-2: #6E6E78;      /* subtitle, footer, "+N more" */
  --canvas-node-fill: #FFFFFF;  /* .n-box — invisible on white by design */
  --canvas-node-sel: #FAF7FF;
  --canvas-edge: #231D5E;
  --canvas-edge-dashed: #787890;
  --canvas-elabel-bg: #FFFFFF;
  --canvas-elabel-bd: #D2D5E4;
  --canvas-zone-fill: rgba(108,75,216,.05);
  --canvas-zone-bd: #B9A9EE;
  --canvas-zone-tx: #6C4BD8;
  --canvas-tier: #5A5496;
  --canvas-panel: #F4F5FA;      /* legend + assumptions boxes */
  --canvas-panel-bd: #231D5E;
  --canvas-mark: #8A6D1A;       /* the assumption "*" drawn on the diagram */
  /* The icon plate. Transparent in light: the vendor PNGs are authored
     for white and already sit on white, so there is nothing to place. */
  --canvas-chip: transparent;
  --canvas-chip-bd: transparent;

  /* --- MSIL ARC model families (reference/msil_arc/type_map.json) ---------
     ONE colour per ARC switch model, shared by the /msil page, the rack
     elevation, the rack-wise diagrams and the BOQ sheets (plan R-e). The
     token NAMES are declared in type_map.json (no hex there — tested); the
     VALUES live here, once per theme. Families step through distinct hues
     (purple core, blue leaf, green distribution, orange access, indigo
     multigig, teal 6200M multigig, steel industrial) so two models are never
     told apart by shade alone; dark values are the same hue, lifted. */
  --msil-spine-12900e: #5B2A86;
  --msil-core-12900e: #7B3F9E;
  --msil-leaf-5945: #1F5F8B;
  --msil-leaf-5710: #2A7FA6;
  --msil-dist-8100: #0B6E4F;
  --msil-dist-6300m: #138A5A;
  --msil-access-6200m-24: #C96A12;
  --msil-access-6200m-24poe: #B5471F;
  --msil-access-6200m-48: #D98E04;
  --msil-mgig-6300l-24: #1D4ED8;
  --msil-mgig-6300l-48: #3B5BDB;
  --msil-mgig-6200m-48: #0E7490;
  --msil-industrial-4100i-12: #6B7280;
  --msil-industrial-4100i-24: #4B5563;
  --msil-licence: #8B5CF6;
  --msil-optic: #DB2777;
  --msil-optic-industrial: #9D174D;
  --msil-dac: #A16207;
  --msil-aoc: #BE185D;
  --msil-spare: #78716C;
}

[data-theme="dark"] {
  color-scheme: dark;

  /* Header navy is lifted off near-black so the topbar still reads as a
     band rather than dissolving into the page; the white wordmark keeps
     12.3:1 against it. */
  --navy: #22345C;
  --navy-2: #2B4172;
  --navy-3: #33497F;
  --navy-fill: #2E4270;
  --navy-fill-hover: #3A5289;
  --navy-fill-bd: #5A79C4;      /* 3.9-4.2:1 on every dark surface, so a filled button still has an edge */
  --on-navy: #EAF1FF;
  --accent-tx: #9FC2F0;         /* navy-as-text inverts to a light blue */
  --violet: #7B5BE8;
  --violet-hover: #6B4BD8;
  --violet-tx: #B9A3FF;
  --violet-bd: #8A6FF0;
  --violet-tint: #241C3F;
  --cyan: #3EC8E8;
  --cyan-hover: #56D4F0;
  --cyan-bd: #3EC8E8;
  --on-cyan: #06323C;
  --cyan-tint: #0E2630;
  --focus: #45D3F2;

  --bg: #0B0E14;
  --panel: #141922;
  --panel-2: #1A202B;
  --panel-3: #232B39;
  --inset: #1C232F;
  --zebra: #191E28;
  --row-child: #161B25;
  --row-out: #12171F;
  --field-bg: #1B2230;
  --disabled-bg: #232936;
  --border: #2A3341;
  --border-soft: #222A36;
  --field-bd: #66748C;
  --shadow: rgba(0,0,0,.70);
  --overlay: rgba(3,5,9,.72);

  --ink: #E6EAF2;
  --muted: #98A2B6;
  --sub-tx: #8FA3C4;
  --link: #58D3EF;

  --ok-bg: #0F2A1E;   --ok-tx: #63D89B;   --ok-bd: #1E5137;
  --pos-bg: #10281C;  --pos-tx: #6FE0A5;  --pos-bd: #22563B;
  --amber-bg: #3A2C0A; --amber-tx: #F2C55C; --amber-bd: #6A5115;
  --amber-soft: #2E2408;
  --amber-cell: #33280B;
  --amber-strong: #FFDA8A;
  --amber-code-bg: #3F310D;
  --err-bg: #37191A;  --err-tx: #FF9C90;  --err-bd: #63302C;
  --err-row: #2B1618;
  --err-soft: #2E1618;
  --crit-bg: #3D1A18; --crit-tx: #FF9184;
  --crit-glow: rgba(255,145,132,.22);
  --danger: #FF7A6B;
  --info-bg: #0D2B35; --info-tx: #63D2EC; --info-bd: #1B4E5D;
  --info2-bg: #12232E; --info2-bd: #234356;
  --jun-bg: #3A250F;  --jun-tx: #EFAF6A;  --jun-bd: #66401A;
  --vio-bg: #251E42;  --vio-bd: #40336E;
  --sub-vio-bg: #251E42; --sub-vio-tx: #B9A3FF; --sub-vio-bd: #40336E;
  --neutral-bg: #1F2531; --neutral-bd: #2A3341;
  --sf-hw-bg: #16253C;  --sf-hw-bd: #2A4568;  --sf-hw-tx: #9BC2F5;
  --sf-sw-bg: #241C3F;  --sf-sw-bd: #40336E;  --sf-sw-tx: #B9A3FF;

  /* --- data visualisation — the dark STEPS of the same three hues --- */
  --chart-1: #299AB2;
  --chart-2: #8F7BF5;
  --chart-3: #B68C38;
  --chart-other: #6E7A90;
  --chart-fill-1: rgba(41,154,178,.20);
  --chart-grid: rgba(159,181,225,.16);
  --chart-tick: #98A2B6;
  --chart-label: #E6EAF2;
  --chart-tip-bg: #1A202B;
  --chart-tip-bd: #2A3341;

  --count-chip: rgba(255,255,255,.14);
  --lead-glow: rgba(123,91,232,.22);
  --spinner-track: rgba(230,234,242,.28);
  --spinner-head: #E6EAF2;
  --on-navy-rule: rgba(255,255,255,.30);
  --on-navy-bd: rgba(255,255,255,.46);   /* 3.2:1 on the lightest end of the dark header */

  /* --- network-diagram canvas ------------------------------------- */
  /* The sheet itself goes dark. It is a viewing mode: the ink inverts to
     a light blue-white, links lighten enough to carry across the sheet,
     and the vendor PNGs — which are transparent artwork drawn in dark
     strokes for a white page — get a light plate behind them rather than
     being recoloured. Nothing here reaches the export. */
  --canvas-desk: #070A0F;
  --canvas-paper: #121826;      /* 15.1:1 under --canvas-ink */
  --canvas-grid: rgba(159,181,225,.07);
  --canvas-ink: #E4EAF7;        /* 14.6:1 on the sheet */
  --canvas-ink-2: #A3AFC6;      /* 7.4:1 — subtitle / footer stay subordinate */
  --canvas-node-fill: #1B2334;
  --canvas-node-sel: #2C2456;
  --canvas-edge: #9FB6DE;       /* 8.4:1 — a 4px line must read, not glow */
  --canvas-edge-dashed: #8592AC;
  --canvas-elabel-bg: #1B2334;
  --canvas-elabel-bd: #3B4761;
  --canvas-zone-fill: rgba(123,91,232,.14);
  --canvas-zone-bd: #8873D8;
  --canvas-zone-tx: #BFAAFF;    /* 8.0:1 on the sheet */
  --canvas-tier: #A79FE4;       /* 8.1:1 */
  --canvas-panel: #1A2130;
  --canvas-panel-bd: #46536C;
  --canvas-mark: #F2C55C;       /* same amber the chrome uses for "assumed" */
  /* A near-white rounded plate under every vendor icon. 34 of the 100
     bundled PNGs are >40% dark ink on transparency (the whole Fortinet
     family is 100%, and Fortinet-logo averages luminance 12) — those
     would simply disappear on a dark sheet. The plate is honest: the
     artwork is untouched and sits deliberately on its own light tile
     instead of accidentally on the wrong background. */
  --canvas-chip: rgba(238,242,249,.95);
  --canvas-chip-bd: rgba(255,255,255,.30);

  /* MSIL ARC model families — same hues as light, lifted for a dark panel */
  --msil-spine-12900e: #B48AE0;
  --msil-core-12900e: #C79BEA;
  --msil-leaf-5945: #7FB6E0;
  --msil-leaf-5710: #8CCBEA;
  --msil-dist-8100: #5FC9A4;
  --msil-dist-6300m: #6FD9AF;
  --msil-access-6200m-24: #F0A75A;
  --msil-access-6200m-24poe: #F08A64;
  --msil-access-6200m-48: #F5C565;
  --msil-mgig-6300l-24: #8FB1FF;
  --msil-mgig-6300l-48: #A9BEFF;
  --msil-mgig-6200m-48: #67D4EE;
  --msil-industrial-4100i-12: #B6BDC9;
  --msil-industrial-4100i-24: #9AA3B2;
  --msil-licence: #C4B5FD;
  --msil-optic: #F9A8D4;
  --msil-optic-industrial: #F472B6;
  --msil-dac: #FACC15;
  --msil-aoc: #FB7185;
  --msil-spare: #D6D3D1;
}

/* dark / light toggle — an icon control, sized to sit beside "Refresh from
   IRIS" without competing with it. Lives on the navy header in BOTH themes,
   so its colours are the on-navy pair, not the page palette. */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--on-navy-bd);
  color: var(--on-navy-soft);
  border-radius: 6px;
  padding: 5px;
  line-height: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { border-color: var(--cyan); color: var(--on-navy); background: transparent; }
.theme-toggle:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.theme-toggle svg { width: 17px; height: 17px; display: block; }
.theme-toggle .th-moon { display: block; }
.theme-toggle .th-sun  { display: none; }
[data-theme="dark"] .theme-toggle .th-moon { display: none; }
[data-theme="dark"] .theme-toggle .th-sun  { display: block; }
