/* ==========================================================================
   themes.css — Complete ERP Theme, Density, Radius & Grid System
   Supports:
     - 4 Studio Themes: Clean, Tactical, NASA, Stark HUD
     - 10 National & Global Themes: India, Australia, USA, Britain, New Zealand,
       South Africa, West Indies, Pakistan, Sri Lanka, Classic Enterprise
     - Density Scales: Compact (2px/8px), Formal (6px/12px), Easy (12px/16px)
     - Corner Geometries: Sharp (0px), Soft (9px)
     - Studio Component Suite: Data Grids, Form Inputs, Buttons, Choice Controls,
       Dropdowns, Badges, Tabs, Dialogs, Charts, and Live Token Customizer.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Studio Theme Definitions
   -------------------------------------------------------------------------- */

/* Clean Studio — Modern High-Contrast Light Theme */
:root[data-theme="clean"],
[data-theme="clean"] {
  --bg: #eef1f6;
  --panel: #ffffff;
  --panel2: #f6f8fb;
  --text: #18212f;
  --muted: #64708a;
  --line: #dde3ee;
  --accent: #2f5fe3;
  --accent-t: #ffffff;
  --accent2: #e5484d;
  --heading-color: #2f5fe3;
  --menupath-bg: #2f5fe3;
  --menupath-text: #ffffff;
  --menupath-border: #1b45ba;
  --head: #eef2fa;
  --hover: #eaf1ff;
  --alt: #fafbfd;
  --good: #2fbf71;
  --warn: #f0a020;
  --bad: #e5484d;
  --toolbar-bg: #eef2fa;
  --toolbar-text: #18212f;
  --toolbar-border: #dde3ee;
  --topbar-bg: #ffffff;
  --topbar-text: #18212f;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hfont: var(--font);
  --upper: none;
  --track: 0;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;

  /* TRYERP Mappings */
  --primary: #2f5fe3;
  --primary-dark: #1b45ba;
  --primary-soft: #eaf1ff;
  --primary-soft-hover: #dbe7ff;
  --primary-400: #5580f0;
  --primary-50: #f4f7fe;
  --primary-100: #d6e2fc;
  --primary-700: #1b45ba;
  --primary-border: #b3c9f8;
  --sidebar-bg: #141b29;
  --sidebar-bg-2: #1e2738;
  --sidebar-text: #dce3f0;
  --sidebar-active: #2f5fe3;
}

/* Tactical HUD — Terminal Green & Amber Military Monospace (Dark) */
:root[data-theme="tactical"],
[data-theme="tactical"] {
  --bg: #0c0f0a;
  --panel: #131810;
  --panel2: #1a2015;
  --text: #cfe3b4;
  --muted: #7f9366;
  --line: #2c3a22;
  --accent: #b7e04a;
  --accent-t: #0c0f0a;
  --accent2: #ffb000;
  --heading-color: #b7e04a;
  --menupath-bg: #b7e04a;
  --menupath-text: #0c0f0a;
  --menupath-border: #8cb82b;
  --head: #1d2517;
  --hover: #243320;
  --alt: #10150d;
  --good: #2fbf71;
  --warn: #ffb000;
  --bad: #e5484d;
  --toolbar-bg: #1d2517;
  --toolbar-text: #cfe3b4;
  --toolbar-border: #2c3a22;
  --topbar-bg: #131810;
  --topbar-text: #cfe3b4;
  --font: "Share Tech Mono", ui-monospace, Menlo, Consolas, monospace;
  --hfont: var(--font);
  --upper: uppercase;
  --track: 0.08em;
  --shadow: inset 0 0 0 1px rgba(183, 224, 74, 0.08), 0 2px 8px rgba(0, 0, 0, 0.5);
  --brk: block;
  color-scheme: dark;
  --bg-img: repeating-linear-gradient(0deg, rgba(183, 224, 74, 0.035) 0 1px, transparent 1px 3px);

  /* TRYERP Mappings */
  --primary: #b7e04a;
  --primary-dark: #8cb82b;
  --primary-soft: #243320;
  --primary-soft-hover: #2d4028;
  --primary-400: #c9ea6c;
  --primary-50: #141b11;
  --primary-100: #29381f;
  --primary-700: #7a9e22;
  --primary-border: #4d6632;
  --sidebar-bg: #090d07;
  --sidebar-bg-2: #10160c;
  --sidebar-text: #cfe3b4;
  --sidebar-active: #1d2517;
}

/* NASA Mission Control — Deep Space Navy & Mars Rocket Red (Dark) */
:root[data-theme="nasa"],
[data-theme="nasa"] {
  --bg: #0b1530;
  --panel: #101e42;
  --panel2: #162755;
  --text: #eaf0ff;
  --muted: #8ea0c9;
  --line: #243a74;
  --accent: #fc3d21;
  --accent-t: #ffffff;
  --accent2: #4aa3ff;
  --heading-color: #fc3d21;
  --menupath-bg: #fc3d21;
  --menupath-text: #ffffff;
  --menupath-border: #cf270e;
  --head: #14265a;
  --hover: #1a3170;
  --alt: #0e1b3c;
  --good: #2fbf71;
  --warn: #f0a020;
  --bad: #fc3d21;
  --toolbar-bg: #14265a;
  --toolbar-text: #eaf0ff;
  --toolbar-border: #243a74;
  --topbar-bg: #101e42;
  --topbar-text: #eaf0ff;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --hfont: var(--font);
  --upper: none;
  --track: 0.01em;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  --brk: none;
  color-scheme: dark;
  --bg-img: radial-gradient(circle at 85% -10%, rgba(74, 163, 255, 0.18), transparent 45%);

  /* TRYERP Mappings */
  --primary: #fc3d21;
  --primary-dark: #cf270e;
  --primary-soft: #241d3b;
  --primary-soft-hover: #312650;
  --primary-400: #fd6850;
  --primary-50: #161c38;
  --primary-100: #382c4f;
  --primary-700: #aa1e09;
  --primary-border: #6d2f35;
  --sidebar-bg: #060c1d;
  --sidebar-bg-2: #0d1a3c;
  --sidebar-text: #eaf0ff;
  --sidebar-active: #14265a;
}

/* Stark HUD — Futuristic Arc Reactor Cyan & Red Glow (Dark) */
:root[data-theme="stark"],
[data-theme="stark"] {
  --bg: #05090f;
  --panel: #0a1722;
  --panel2: #0c2030;
  --text: #d8f6ff;
  --muted: #6fa3b8;
  --line: #0e4a63;
  --accent: #19d3ff;
  --accent-t: #021017;
  --accent2: #ff3b4e;
  --heading-color: #19d3ff;
  --menupath-bg: #19d3ff;
  --menupath-text: #021017;
  --menupath-border: #0fa3c7;
  --head: #0a2233;
  --hover: #0d3249;
  --alt: #07131d;
  --good: #2fbf71;
  --warn: #f0a020;
  --bad: #ff3b4e;
  --toolbar-bg: #0a2233;
  --toolbar-text: #d8f6ff;
  --toolbar-border: #0e4a63;
  --topbar-bg: #0a1722;
  --topbar-text: #d8f6ff;
  --font: "Rajdhani", system-ui, sans-serif;
  --hfont: "Orbitron", "Rajdhani", sans-serif;
  --upper: uppercase;
  --track: 0.06em;
  --shadow: 0 0 0 1px rgba(25, 211, 255, 0.22), 0 0 24px rgba(25, 211, 255, 0.12);
  --brk: block;
  color-scheme: dark;
  --bg-img: radial-gradient(circle at 15% 0%, rgba(25, 211, 255, 0.16), transparent 40%),
            radial-gradient(circle at 90% 100%, rgba(255, 59, 78, 0.10), transparent 40%);

  /* TRYERP Mappings */
  --primary: #19d3ff;
  --primary-dark: #0fa3c7;
  --primary-soft: #0c2738;
  --primary-soft-hover: #10344d;
  --primary-400: #4ee0ff;
  --primary-50: #071926;
  --primary-100: #123d57;
  --primary-700: #0a7b96;
  --primary-border: #16647f;
  --sidebar-bg: #03060a;
  --sidebar-bg-2: #07131d;
  --sidebar-text: #d8f6ff;
  --sidebar-active: #0a2233;
}

/* --------------------------------------------------------------------------
   2. National & Cricket Jersey Inspired Palettes
   -------------------------------------------------------------------------- */

/* India — Bleed Blue & Saffron */
[data-theme="india"] {
  --primary: #0066cc;
  --primary-dark: #004c99;
  --primary-soft: #e6f0fa;
  --primary-soft-hover: #d9e7f7;
  --primary-400: #3385d6;
  --primary-50: #f0f6fc;
  --primary-100: #cce0f5;
  --primary-700: #004080;
  --primary-border: #b3d1f0;
  --accent: #0066cc;
  --accent-t: #ffffff;
  --accent2: #ff7722;
  --heading-color: #0066cc;
  --menupath-bg: #0066cc;
  --menupath-text: #ffffff;
  --menupath-border: #004c99;
  --sidebar-bg: #081d3a;
  --sidebar-bg-2: #0e294d;
  --sidebar-text: #c4d5ea;
  --sidebar-active: #143d73;
  --panel: #ffffff;
  --panel2: #f6f8fb;
  --line: #dde3ee;
  --head: #eef5fc;
  --hover: #eaf1ff;
  --alt: #fafbfd;
  --toolbar-bg: #eef5fc;
  --toolbar-text: #081d3a;
  --toolbar-border: #b3d1f0;
  --topbar-bg: #ffffff;
  --topbar-text: #081d3a;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;
}

/* Australia — Baggy Green & Canary Gold */
[data-theme="australia"] {
  --primary: #006a4e;
  --primary-dark: #004835;
  --primary-soft: #e6f4ee;
  --primary-soft-hover: #d6eee2;
  --primary-400: #1e8568;
  --primary-50: #f0f9f5;
  --primary-100: #bce4d4;
  --primary-700: #003829;
  --primary-border: #a3dac3;
  --accent: #006a4e;
  --accent-t: #ffffff;
  --accent2: #f5b700;
  --heading-color: #006a4e;
  --menupath-bg: #006a4e;
  --menupath-text: #ffffff;
  --menupath-border: #004835;
  --sidebar-bg: #023020;
  --sidebar-bg-2: #04432c;
  --sidebar-text: #d0e6dc;
  --sidebar-active: #075c3d;
  --panel: #ffffff;
  --panel2: #f6f8fb;
  --line: #dde3ee;
  --head: #edf7f2;
  --hover: #e6f4ee;
  --alt: #fafbfd;
  --toolbar-bg: #edf7f2;
  --toolbar-text: #023020;
  --toolbar-border: #a3dac3;
  --topbar-bg: #ffffff;
  --topbar-text: #023020;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;
}

/* USA — Stars & Stripes (Crimson Red, White & Navy) */
[data-theme="usa"] {
  --primary: #b31942;
  --primary-dark: #8c1032;
  --primary-soft: #fae8ec;
  --primary-soft-hover: #f6d6de;
  --primary-400: #c9365c;
  --primary-50: #fdf2f4;
  --primary-100: #f2bcc9;
  --primary-700: #730925;
  --primary-border: #e89fb0;
  --accent: #b31942;
  --accent-t: #ffffff;
  --accent2: #0a3161;
  --heading-color: #b31942;
  --menupath-bg: #b31942;
  --menupath-text: #ffffff;
  --menupath-border: #8c1032;
  --sidebar-bg: #0a1c36;
  --sidebar-bg-2: #122a4f;
  --sidebar-text: #d3dbe8;
  --sidebar-active: #1c3e73;
  --panel: #ffffff;
  --panel2: #f6f8fb;
  --line: #dde3ee;
  --head: #fcf0f2;
  --hover: #fae8ec;
  --alt: #fafbfd;
  --toolbar-bg: #fcf0f2;
  --toolbar-text: #0a1c36;
  --toolbar-border: #e89fb0;
  --topbar-bg: #ffffff;
  --topbar-text: #0a1c36;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;
}

/* Britain / England — Union Jack (Royal Navy, Crimson & White) */
[data-theme="britain"],
[data-theme="uk"] {
  --primary: #00247d;
  --primary-dark: #00164d;
  --primary-soft: #e6ebf7;
  --primary-soft-hover: #d5def2;
  --primary-400: #1f45a6;
  --primary-50: #f2f5fb;
  --primary-100: #b8c8ee;
  --primary-700: #00164d;
  --primary-border: #9cb3e6;
  --accent: #00247d;
  --accent-t: #ffffff;
  --accent2: #cf142b;
  --heading-color: #00247d;
  --menupath-bg: #00247d;
  --menupath-text: #ffffff;
  --menupath-border: #00164d;
  --sidebar-bg: #081636;
  --sidebar-bg-2: #0e2252;
  --sidebar-text: #cad5ed;
  --sidebar-active: #17347a;
  --panel: #ffffff;
  --panel2: #f6f8fb;
  --line: #dde3ee;
  --head: #eff3fa;
  --hover: #e6ebf7;
  --alt: #fafbfd;
  --toolbar-bg: #eff3fa;
  --toolbar-text: #081636;
  --toolbar-border: #9cb3e6;
  --topbar-bg: #ffffff;
  --topbar-text: #081636;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;
}

/* New Zealand — Black Caps (Black, Slate Grey & Pure White) */
[data-theme="newzealand"],
[data-theme="nz"] {
  --primary: #262a33;
  --primary-dark: #15181e;
  --primary-soft: #eceef1;
  --primary-soft-hover: #dee1e6;
  --primary-400: #454b59;
  --primary-50: #f5f6f8;
  --primary-100: #cbcfd7;
  --primary-700: #111317;
  --primary-border: #b3b9c4;
  --accent: #262a33;
  --accent-t: #ffffff;
  --accent2: #5a6578;
  --heading-color: #262a33;
  --menupath-bg: #262a33;
  --menupath-text: #ffffff;
  --menupath-border: #15181e;
  --sidebar-bg: #111418;
  --sidebar-bg-2: #1b1f24;
  --sidebar-text: #cdd2d8;
  --sidebar-active: #2b313a;
  --panel: #ffffff;
  --panel2: #f6f8fb;
  --line: #dde3ee;
  --head: #f0f1f4;
  --hover: #eceef1;
  --alt: #fafbfd;
  --toolbar-bg: #f0f1f4;
  --toolbar-text: #111418;
  --toolbar-border: #b3b9c4;
  --topbar-bg: #ffffff;
  --topbar-text: #111418;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;
}

/* South Africa — Proteas (Emerald Green & Sun Gold) */
[data-theme="southafrica"],
[data-theme="sa"] {
  --primary: #007749;
  --primary-dark: #005735;
  --primary-soft: #e6f5ee;
  --primary-soft-hover: #d4efdf;
  --primary-400: #1f9464;
  --primary-50: #f0faf4;
  --primary-100: #bde7d1;
  --primary-700: #004228;
  --primary-border: #a1ddbd;
  --accent: #007749;
  --accent-t: #ffffff;
  --accent2: #f9a825;
  --heading-color: #007749;
  --menupath-bg: #007749;
  --menupath-text: #ffffff;
  --menupath-border: #005735;
  --sidebar-bg: #032e1d;
  --sidebar-bg-2: #074029;
  --sidebar-text: #cee8dc;
  --sidebar-active: #0b5738;
  --panel: #ffffff;
  --panel2: #f6f8fb;
  --line: #dde3ee;
  --head: #edf7f3;
  --hover: #e6f5ee;
  --alt: #fafbfd;
  --toolbar-bg: #edf7f3;
  --toolbar-text: #032e1d;
  --toolbar-border: #a1ddbd;
  --topbar-bg: #ffffff;
  --topbar-text: #032e1d;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;
}

/* West Indies — Windies (Maroon & Caribbean Gold) */
[data-theme="westindies"],
[data-theme="wi"] {
  --primary: #7b1129;
  --primary-dark: #56091a;
  --primary-soft: #f5e6ea;
  --primary-soft-hover: #edd0d7;
  --primary-400: #9c1b39;
  --primary-50: #fbf1f3;
  --primary-100: #e4b4bf;
  --primary-700: #420512;
  --primary-border: #d697a6;
  --accent: #7b1129;
  --accent-t: #ffffff;
  --accent2: #f4b400;
  --heading-color: #7b1129;
  --menupath-bg: #7b1129;
  --menupath-text: #ffffff;
  --menupath-border: #56091a;
  --sidebar-bg: #330410;
  --sidebar-bg-2: #470818;
  --sidebar-text: #ead0d6;
  --sidebar-active: #611024;
  --panel: #ffffff;
  --panel2: #f6f8fb;
  --line: #dde3ee;
  --head: #faedf0;
  --hover: #f5e6ea;
  --alt: #fafbfd;
  --toolbar-bg: #faedf0;
  --toolbar-text: #330410;
  --toolbar-border: #d697a6;
  --topbar-bg: #ffffff;
  --topbar-text: #330410;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;
}

/* Pakistan — Shaheens (Star Emerald & Moon Lime) */
[data-theme="pakistan"],
[data-theme="pak"] {
  --primary: #006633;
  --primary-dark: #004724;
  --primary-soft: #e6f5ec;
  --primary-soft-hover: #d4eedd;
  --primary-400: #1f854e;
  --primary-50: #f0faf3;
  --primary-100: #bce4cc;
  --primary-700: #00381c;
  --primary-border: #a1dab7;
  --accent: #006633;
  --accent-t: #ffffff;
  --accent2: #8ec03f;
  --heading-color: #006633;
  --menupath-bg: #006633;
  --menupath-text: #ffffff;
  --menupath-border: #004724;
  --sidebar-bg: #062b16;
  --sidebar-bg-2: #0b3b20;
  --sidebar-text: #cee8d8;
  --sidebar-active: #10522c;
  --panel: #ffffff;
  --panel2: #f6f8fb;
  --line: #dde3ee;
  --head: #edf8f1;
  --hover: #e6f5ec;
  --alt: #fafbfd;
  --toolbar-bg: #edf8f1;
  --toolbar-text: #062b16;
  --toolbar-border: #a1dab7;
  --topbar-bg: #ffffff;
  --topbar-text: #062b16;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;
}

/* Sri Lanka — Lions (Royal Blue & Golden Ochre) */
[data-theme="srilanka"],
[data-theme="sl"] {
  --primary: #003580;
  --primary-dark: #002254;
  --primary-soft: #e6effa;
  --primary-soft-hover: #d4e4f7;
  --primary-400: #1f54a1;
  --primary-50: #f0f5fc;
  --primary-100: #b8d2f2;
  --primary-700: #001b42;
  --primary-border: #9ec2ed;
  --accent: #003580;
  --accent-t: #ffffff;
  --accent2: #e6a100;
  --heading-color: #003580;
  --menupath-bg: #003580;
  --menupath-text: #ffffff;
  --menupath-border: #002254;
  --sidebar-bg: #041c3d;
  --sidebar-bg-2: #082854;
  --sidebar-text: #c8d9ee;
  --sidebar-active: #0f3a75;
  --panel: #ffffff;
  --panel2: #f6f8fb;
  --line: #dde3ee;
  --head: #eef3fb;
  --hover: #e6effa;
  --alt: #fafbfd;
  --toolbar-bg: #eef3fb;
  --toolbar-text: #041c3d;
  --toolbar-border: #9ec2ed;
  --topbar-bg: #ffffff;
  --topbar-text: #041c3d;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;
}

/* Default Corporate — Enterprise Blue (Classic TRYERP) */
[data-theme="default"],
:root:not([data-theme]) {
  --primary: #1f5fbf;
  --primary-dark: #17488f;
  --primary-soft: #e8f0fc;
  --primary-soft-hover: #d9e7f9;
  --primary-400: #4b83e0;
  --primary-50: #f2f7ff;
  --primary-100: #dce8fb;
  --primary-700: #17488f;
  --primary-border: #bfdbfe;
  --accent: #1f5fbf;
  --accent-t: #ffffff;
  --accent2: #0f9d8f;
  --heading-color: #1f5fbf;
  --menupath-bg: #1f5fbf;
  --menupath-text: #ffffff;
  --menupath-border: #17488f;
  --sidebar-bg: #16233a;
  --sidebar-bg-2: #1d2d49;
  --sidebar-text: #c3cede;
  --sidebar-active: #27406b;
  --panel: #ffffff;
  --panel2: #f8fafc;
  --line: #dfe5ee;
  --head: #eef3fb;
  --hover: #e8f0fc;
  --alt: #fafbfd;
  --toolbar-bg: #eef2fa;
  --toolbar-text: #18212f;
  --toolbar-border: #dde3ee;
  --topbar-bg: #ffffff;
  --topbar-text: #18212f;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.08);
  --bg-img: none;
  --brk: none;
  color-scheme: light;
}

/* --------------------------------------------------------------------------
   2.5 Toolbar Color Styles ([data-toolbar="..."])
   Supports:
     - matched (default): Matches grid header (--head)
     - panel: Clean surface panel (--panel)
     - accent: Vibrant brand accent banner (--accent, --accent-t)
     - soft: Gentle highlight tint (--hover)
     - dark: High-contrast command bar (--sidebar-bg, --sidebar-text)
   -------------------------------------------------------------------------- */
:root[data-toolbar="matched"],
[data-toolbar="matched"] {
  --toolbar-bg: var(--head);
  --toolbar-text: var(--text);
  --toolbar-border: var(--line);
}

:root[data-toolbar="panel"],
[data-toolbar="panel"] {
  --toolbar-bg: var(--panel);
  --toolbar-text: var(--text);
  --toolbar-border: var(--line);
}

:root[data-toolbar="accent"],
[data-toolbar="accent"] {
  --toolbar-bg: var(--accent);
  --toolbar-text: var(--accent-t);
  --toolbar-border: color-mix(in srgb, var(--accent) 70%, black);
}

:root[data-toolbar="soft"],
[data-toolbar="soft"] {
  --toolbar-bg: var(--hover);
  --toolbar-text: var(--text);
  --toolbar-border: var(--line);
}

:root[data-toolbar="dark"],
[data-toolbar="dark"] {
  --toolbar-bg: var(--sidebar-bg);
  --toolbar-text: var(--sidebar-text);
  --toolbar-border: color-mix(in srgb, var(--sidebar-bg) 75%, white);
}

/* Contrast adjustments for buttons & controls inside accent/dark toolbars */
:root[data-toolbar="accent"] .toolbar .btn:not(.btn--primary):not(.pri),
:root[data-toolbar="accent"] .gtool .btn:not(.btn--primary):not(.pri),
:root[data-toolbar="accent"] .erp-ribbon-btn:not(.erp-ribbon-btn--primary) {
  background: color-mix(in srgb, var(--toolbar-text) 14%, transparent);
  border-color: color-mix(in srgb, var(--toolbar-text) 28%, transparent);
  color: var(--toolbar-text);
}
:root[data-toolbar="accent"] .toolbar .btn:not(.btn--primary):not(.pri):hover,
:root[data-toolbar="accent"] .gtool .btn:not(.btn--primary):not(.pri):hover,
:root[data-toolbar="accent"] .erp-ribbon-btn:not(.erp-ribbon-btn--primary):hover {
  background: color-mix(in srgb, var(--toolbar-text) 24%, transparent);
  color: var(--toolbar-text);
}

:root[data-toolbar="dark"] .toolbar .btn:not(.btn--primary):not(.pri),
:root[data-toolbar="dark"] .gtool .btn:not(.btn--primary):not(.pri),
:root[data-toolbar="dark"] .erp-ribbon-btn:not(.erp-ribbon-btn--primary) {
  background: color-mix(in srgb, var(--toolbar-text) 12%, transparent);
  border-color: color-mix(in srgb, var(--toolbar-text) 22%, transparent);
  color: var(--toolbar-text);
}
:root[data-toolbar="dark"] .toolbar .btn:not(.btn--primary):not(.pri):hover,
:root[data-toolbar="dark"] .gtool .btn:not(.btn--primary):not(.pri):hover,
:root[data-toolbar="dark"] .erp-ribbon-btn:not(.erp-ribbon-btn--primary):hover {
  background: color-mix(in srgb, var(--toolbar-text) 20%, transparent);
  color: var(--toolbar-text);
}

/* --------------------------------------------------------------------------
   3. Corner Brackets (Tactical & Stark HUD Theme Effect)
   -------------------------------------------------------------------------- */
.panel,
.card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.panel::before,
.panel::after,
.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  display: var(--brk, none);
  pointer-events: none;
  border: 0 solid var(--accent);
}

.panel::before,
.card::before {
  top: -1px;
  left: -1px;
  border-top-width: 2px;
  border-left-width: 2px;
}

.panel::after,
.card::after {
  bottom: -1px;
  right: -1px;
  border-bottom-width: 2px;
  border-right-width: 2px;
}

/* --------------------------------------------------------------------------
   4. Form Controls, Text Inputs, and Dropdowns
   -------------------------------------------------------------------------- */
label.l {
  display: block;
  font-size: 0.85em;
  color: var(--muted);
  text-transform: var(--upper);
  letter-spacing: var(--track);
  margin-bottom: 4px;
  font-weight: 600;
}

.in,
.input,
.select,
.textarea {
  width: 100%;
  font: inherit;
  font-size: var(--fs);
  letter-spacing: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: calc(var(--py) + 3px) var(--px);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.in:focus,
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent);
}

.in[disabled],
.input:disabled,
.select:disabled,
.textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--head);
}

/* --------------------------------------------------------------------------
   5. Buttons & Actions
   -------------------------------------------------------------------------- */
.btn {
  font: inherit;
  letter-spacing: inherit;
  text-transform: var(--upper);
  cursor: pointer;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: calc(var(--py) + 3px) calc(var(--px) + 2px);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.08s ease;
  user-select: none;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn:active {
  transform: translateY(1px);
}

.btn.pri,
.btn--primary {
  background: var(--accent);
  color: var(--accent-t);
  border-color: var(--accent);
}

.btn.pri:hover,
.btn--primary:hover {
  filter: brightness(1.1);
  color: var(--accent-t);
  border-color: var(--accent);
}

.btn.dng,
.btn--danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 50%, var(--line));
  background: var(--panel2);
}

.btn.dng:hover,
.btn--danger:hover {
  background: var(--bad);
  color: #ffffff;
  border-color: var(--bad);
}

.btn[disabled],
.btn:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   6. Data Grid System (Applied to both table.grid and .table)
   -------------------------------------------------------------------------- */
.gridbox,
.table-wrap {
  padding: 0;
  overflow: auto;
  max-height: 70vh;
  border-radius: var(--r);
  background: var(--panel);
}

.gtool,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: var(--gap);
  border-bottom: 1px solid var(--toolbar-border, var(--line));
  background: var(--toolbar-bg, var(--head));
  color: var(--toolbar-text, var(--text));
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.gtool h2,
.gtool h3,
.toolbar h2,
.toolbar h3,
.toolbar__title,
.toolbar .label,
.gtool .label {
  color: var(--toolbar-text, var(--text));
}

.gtool .in,
.toolbar .in {
  width: auto;
  min-width: 150px;
}

.gscroll {
  overflow: auto;
  max-height: 52vh;
}

table.grid,
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  font-size: var(--fs);
  color: var(--text);
  letter-spacing: var(--track);
}

.grid thead,
.table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

table th,
.grid th,
.table th,
.tax-table th,
.wizard-table th,
.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--head);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: calc(var(--fs) * 0.92);
  text-transform: var(--upper);
  letter-spacing: var(--track);
  color: var(--muted);
  border-bottom: 2px solid var(--accent);
  padding: var(--py) var(--px);
  line-height: 1.35;
  transition: color 0.14s ease, background 0.14s ease;
}

.grid th:hover,
.table th:hover {
  color: var(--text);
}

.grid td,
.table td {
  padding: var(--py) var(--px);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
  color: var(--text);
  font-size: var(--fs);
}

.grid tbody tr:nth-child(even),
.table tbody tr:nth-child(even) {
  background: var(--alt);
}

.grid tbody tr:hover,
.table tbody tr:hover {
  background: var(--hover);
}

.table tbody tr.is-pinned {
  background: var(--hover);
  box-shadow: inset 3px 0 0 var(--accent);
}

.grid .n,
.table .n,
.table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.grid th.s::after {
  content: attr(data-d);
  color: var(--accent);
  margin-left: 4px;
}

/* Filter Row */
.frow th,
.table-filter-row th {
  cursor: default;
  border-bottom: 1px solid var(--line);
  padding: calc(var(--py) * 0.6) var(--px);
  background: var(--head);
}

.grid .fin,
.grid-col-filter {
  padding: 2px 6px;
  font-size: 0.9em;
  min-width: 70px;
  width: 100%;
  box-sizing: border-box;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: calc(var(--r) * 0.5);
  color: var(--text);
}

/* Grid Footer & Pagination */
.gfoot,
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  padding: calc(var(--gap) * 0.6) var(--gap);
  border-top: 1px solid var(--line);
  background: var(--head);
  font-size: 0.92em;
  color: var(--muted);
}

.gfoot .in,
.pagination .in,
.pagination select {
  width: auto;
  padding: 2px 6px;
  font-size: 0.9em;
  border-radius: var(--r);
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
}

.pg {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.pg .btn,
.pagination .btn {
  padding: 2px 9px;
  min-width: 30px;
  font-size: 0.9em;
}

.pg .btn.on,
.pagination .btn.is-active,
.pagination .btn.on {
  background: var(--accent);
  color: var(--accent-t);
  border-color: var(--accent);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   7. Segmented Buttons & Badges
   -------------------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: calc(var(--r) * 0.6);
  font-size: 0.85em;
  font-weight: 600;
  text-transform: var(--upper);
  letter-spacing: var(--track);
  color: var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 40%, transparent);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--panel2);
}

.seg button {
  font: inherit;
  font-size: var(--fs);
  letter-spacing: inherit;
  text-transform: var(--upper);
  background: var(--panel2);
  color: var(--muted);
  border: 0;
  border-right: 1px solid var(--line);
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.seg button:last-child {
  border-right: 0;
}

.seg button:hover:not(.on) {
  color: var(--text);
  background: var(--hover);
}

.seg button.on {
  background: var(--accent);
  color: var(--accent-t);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   8. Choice Controls (Checkboxes, Radios, Switches, Chips, Option Cards)
   -------------------------------------------------------------------------- */
.chk,
.rad,
.sw,
.chip,
.ocard {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: var(--fs);
}

.chk input,
.rad input,
.sw input,
.chip input,
.ocard input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.chk i,
.rad i {
  flex: none;
  width: 1.15em;
  height: 1.15em;
  display: inline-grid;
  place-items: center;
  border: 1.5px solid var(--muted);
  background: var(--panel2);
  transition: all 0.12s ease;
}

.chk i {
  border-radius: calc(var(--r) * 0.35);
}

.rad i {
  border-radius: 50%;
}

.chk input:checked + i,
.rad input:checked + i,
.sw input:checked + i {
  background: var(--accent);
  border-color: var(--accent);
}

.chk input:checked + i::after {
  content: '';
  width: 0.3em;
  height: 0.6em;
  border: solid var(--accent-t);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.rad input:checked + i::after {
  content: '';
  width: 0.45em;
  height: 0.45em;
  border-radius: 50%;
  background: var(--accent-t);
}

.sw i {
  flex: none;
  width: 2.4em;
  height: 1.3em;
  position: relative;
  border-radius: calc(var(--r) * 3);
  border: 1.5px solid var(--muted);
  background: var(--panel2);
  transition: 0.15s;
}

.sw i::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.3em - 7px);
  height: calc(1.3em - 7px);
  border-radius: 50%;
  background: var(--muted);
  transition: 0.15s;
}

.sw input:checked + i::after {
  left: calc(1.1em + 2px);
  background: var(--accent-t);
}

input:focus-visible + i,
input:focus-visible + span,
.btn:focus-visible,
.seg button:focus-visible,
.tabs button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.opts {
  display: grid;
  gap: 9px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip span {
  padding: 3px 12px;
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: calc(var(--r) * 2.5);
  transition: 0.12s;
  font-size: var(--fs);
}

.chip:hover span {
  border-color: var(--accent);
}

.chip input:checked + span {
  background: var(--accent);
  color: var(--accent-t);
  border-color: var(--accent);
  font-weight: 600;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}

.ocard {
  display: block;
}

.ocard span {
  display: block;
  padding: var(--py) var(--px);
  border: 1px solid var(--line);
  background: var(--panel2);
  border-radius: var(--r);
  transition: 0.12s;
}

.ocard input:checked + span {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--panel2));
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.fs {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.fs legend {
  padding: 0;
}

/* --------------------------------------------------------------------------
   9. Dropdowns & Multi-select
   -------------------------------------------------------------------------- */
.menu {
  position: relative;
}

.menu summary {
  list-style: none;
  cursor: pointer;
}

.menu summary::-webkit-details-marker {
  display: none;
}

summary.in::after {
  content: ' ▾';
  float: right;
  color: var(--muted);
}

.pop {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 190px;
  display: grid;
  gap: 8px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow), 0 12px 30px rgba(0, 0, 0, 0.35);
}

.menu.ms .pop {
  left: 0;
  right: auto;
}

/* --------------------------------------------------------------------------
   10. Tabs
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--gap);
  overflow-x: auto;
}

.tabs button {
  font: inherit;
  font-size: var(--fs);
  letter-spacing: inherit;
  text-transform: var(--upper);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  padding: calc(var(--py) + 4px) calc(var(--px) + 4px);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s ease;
}

.tabs button:hover {
  color: var(--text);
}

.tabs button[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   11. Modal Dialog & Toasts
   -------------------------------------------------------------------------- */
.modal {
  padding: 0;
  width: min(520px, 92vw);
  color: var(--text);
  background: var(--panel);
  font: inherit;
  letter-spacing: inherit;
  border: 1px solid var(--accent);
  border-radius: var(--r);
  box-shadow: var(--shadow), 0 24px 70px rgba(0, 0, 0, 0.55);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
}

.modal header,
.modal footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: var(--gap);
  background: var(--head);
}

.modal header {
  border-bottom: 1px solid var(--line);
}

.modal footer {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.modal .bd {
  padding: var(--gap);
  display: grid;
  gap: var(--gap);
}

.toasts {
  position: fixed;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 8px;
  z-index: 500;
  width: min(360px, 92vw);
}

.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--c, var(--accent));
  border-radius: var(--r);
  padding: 10px 12px;
  box-shadow: var(--shadow), 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: tin 0.2s ease-out;
  color: var(--text);
}

.toast .x {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.3em;
  line-height: 1;
  cursor: pointer;
}

@keyframes tin {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* --------------------------------------------------------------------------
   12. SVG Charts (Themed per theme attributes)
   -------------------------------------------------------------------------- */
.cht {
  width: 100%;
  height: auto;
  display: block;
}

.cht text {
  fill: var(--muted);
  font: 10px var(--font);
}

.cht .gl {
  stroke: var(--line);
  stroke-width: 1;
}

.cht .bar {
  fill: var(--accent);
  rx: calc(var(--r) / 3);
}

.cht .ln {
  fill: none;
  stroke: var(--accent2, var(--accent));
  stroke-width: 2;
  stroke-linejoin: round;
}

.cht .ar {
  fill: var(--accent2, var(--accent));
  opacity: 0.16;
}

.cht .dot {
  fill: var(--panel);
  stroke: var(--accent2, var(--accent));
  stroke-width: 2;
}

:root[data-theme='tactical'] .cht .gl {
  stroke-dasharray: 2 4;
}

:root[data-theme='tactical'] .cht .bar {
  fill: color-mix(in srgb, var(--accent) 20%, transparent);
  stroke: var(--accent);
  stroke-width: 1.5;
  rx: 0;
}

:root[data-theme='tactical'] .cht .ln {
  stroke-dasharray: 6 3;
}

:root[data-theme='nasa'] .cht .bar {
  fill: var(--accent2);
}

:root[data-theme='nasa'] .cht .ln {
  stroke: var(--accent);
}

:root[data-theme='nasa'] .cht .ar {
  fill: var(--accent);
}

:root[data-theme='nasa'] .cht .dot {
  stroke: var(--accent);
}

:root[data-theme='stark'] .cht .bar {
  fill: color-mix(in srgb, var(--accent) 40%, transparent);
  stroke: var(--accent);
  filter: drop-shadow(0 0 4px var(--accent));
}

:root[data-theme='stark'] .cht .ln {
  filter: drop-shadow(0 0 5px var(--accent2));
}

/* --------------------------------------------------------------------------
   13. Appearance UI Management Cards & Layout
   -------------------------------------------------------------------------- */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.theme-card {
  position: relative;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  user-select: none;
}

.theme-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.theme-card.is-active {
  border-color: var(--accent);
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 14px rgba(0, 0, 0, 0.15);
}

.theme-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.theme-card__identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-card__flag {
  font-size: 24px;
  line-height: 1;
}

.theme-card__title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.theme-card__jersey {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 2px;
}

.theme-card__active-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--accent);
  color: var(--accent-t);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.theme-card__swatches {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel2);
  border-radius: var(--r);
  border: 1px solid var(--line);
}

.theme-swatch-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.theme-swatch-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--panel);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}

.theme-swatch-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.theme-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.theme-card__btn {
  width: 100%;
}

/* Custom Color Token Editor in Appearance */
.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.token-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  gap: 8px;
}

.token-item__info {
  display: flex;
  flex-direction: column;
}

.token-item__name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.token-item__var {
  font-size: 10.5px;
  color: var(--muted);
  font-family: var(--font-mono, monospace);
}

.token-item__input {
  width: 38px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: calc(var(--r) * 0.5);
  cursor: pointer;
  background: transparent;
}

/* Studio Section Container */
.studio-section {
  margin-bottom: 24px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--gap);
}

.kpi b {
  display: block;
  font-family: var(--hfont);
  font-size: 1.7em;
  color: var(--accent);
  margin-top: 2px;
}
