/* ============================================================================
   MIZAN EA — Enterprise Design System
   by Next Tech Corporation
   Tokens use rgb channels so Tailwind /<alpha> works. Class names are stable;
   styles are elevated for a premium, government-grade enterprise look.
   ========================================================================== */

:root {
  /* Brand */
  --brand: 37 99 235;          /* blue-600 */
  --brand-700: 29 78 216;      /* blue-700 (gradients/hover) */
  --brand-soft: 224 235 255;   /* tinted brand surface */
  /* Neutrals (cool slate ramp) */
  --surface: 244 246 249;      /* app background */
  --surface-2: 237 240 245;    /* sunken */
  --panel: 255 255 255;        /* card/panel */
  --panel-2: 250 251 253;      /* subtle panel */
  --ink: 15 23 42;             /* slate-900 */
  --ink-2: 51 65 85;           /* slate-700 secondary text */
  --muted: 100 116 139;        /* slate-500 */
  --line: 226 232 240;         /* slate-200 borders */
  --line-strong: 203 213 225;
  /* Status */
  --success: 22 163 74;
  --warning: 217 119 6;
  --error: 220 38 38;
  --info: 2 132 199;
  /* Semantic aliases for management UIs (R3 design-system): stable names that resolve
     to the status ramp so destructive/positive affordances stay consistent. */
  --danger: 220 38 38;
  --ok: 22 163 74;
  --warn: 217 119 6;
  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12), 0 4px 8px rgba(15, 23, 42, .06);
  --shadow-xl: 0 24px 60px rgba(15, 23, 42, .18);
  /* Geometry */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --ring: 37 99 235;
}
html.dark {
  --brand: 96 165 250;
  --brand-700: 59 130 246;
  --brand-soft: 30 47 84;
  --surface: 11 15 22;
  --surface-2: 16 21 30;
  --panel: 22 27 37;
  --panel-2: 26 32 43;
  --ink: 237 240 244;
  --ink-2: 197 205 217;
  --muted: 148 160 176;
  --line: 38 45 58;
  --line-strong: 52 62 78;
  --success: 34 197 94;
  --warning: 245 158 11;
  --error: 248 113 113;
  --info: 56 189 248;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  --shadow-xl: 0 28px 70px rgba(0, 0, 0, .6);
}
html[data-theme="saudi"] {
  --brand: 21 128 61;          /* Saudi green */
  --brand-700: 22 101 52;
  --brand-soft: 220 245 228;
  --navy: 15 33 62;
  --surface: 244 248 245;
  --surface-2: 236 243 238;
  --panel: 255 255 255;
  --panel-2: 250 252 251;
  --ink: 13 30 24;
  --ink-2: 40 64 52;
  --muted: 82 104 92;
  --line: 213 230 219;
  --line-strong: 190 214 198;
}
html[data-theme="saudi"] aside#sidebar { background: rgb(248 250 249); }
html.dark[data-theme="saudi"] {
  --brand: 74 222 128;
  --brand-700: 34 197 94;
  --brand-soft: 18 52 34;
  --surface: 10 16 12;
  --surface-2: 14 22 17;
  --panel: 17 26 20;
  --panel-2: 20 30 23;
  --ink: 230 240 233;
  --ink-2: 190 210 196;
  --muted: 140 160 146;
  --line: 34 50 40;
  --line-strong: 48 66 54;
}

/* ============================================================================
   PERSONALIZATION (user-customizable: accent color, fonts EN/AR, text size,
   density). Driven by prefs.js via data-accent / html font vars / classes.
   ========================================================================== */
:root {
  /* Typography — overridable per user; separate Latin & Arabic stacks. */
  --font-latin: 'Source Sans 3', system-ui, 'Segoe UI', Tahoma, sans-serif;
  --font-arabic: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --font-display: 'Lexend', 'Tajawal', system-ui, sans-serif;
  --app-font: var(--font-latin);          /* active UI font (lang-resolved) */
  --app-font-display: var(--font-display); /* active heading font */
  --app-scale: 1;                          /* text size multiplier */
}
/* In Arabic, headings should also use the Arabic font (Lexend lacks Arabic glyphs). */
html[lang="ar"] { --app-font: var(--font-arabic); --app-font-display: var(--font-arabic); }
/* Root font-size scaling → all rem/Tailwind sizes scale together (dynamic type). */
html { font-size: calc(16px * var(--app-scale)); }
body.font-sans { font-family: var(--app-font); }

/* ---- Accent palettes (brand tokens only; orthogonal to light/dark mode) ---- */
html[data-accent="green"]  { --brand: 21 128 61;  --brand-700: 22 101 52;  --brand-soft: 220 245 228; --ring: 21 128 61; }
html[data-accent="teal"]   { --brand: 13 148 136; --brand-700: 15 118 110; --brand-soft: 204 240 236; --ring: 13 148 136; }
html[data-accent="indigo"] { --brand: 79 70 229;  --brand-700: 67 56 202;  --brand-soft: 224 226 254; --ring: 79 70 229; }
html[data-accent="violet"] { --brand: 124 58 237; --brand-700: 109 40 217; --brand-soft: 233 224 255; --ring: 124 58 237; }
html[data-accent="gold"]   { --brand: 176 124 19; --brand-700: 146 105 20; --brand-soft: 245 235 210; --ring: 176 124 19; }
html[data-accent="rose"]   { --brand: 225 29 72;  --brand-700: 190 18 60;  --brand-soft: 255 222 230; --ring: 225 29 72; }
html[data-accent="slate"]  { --brand: 71 85 105;  --brand-700: 51 65 85;   --brand-soft: 226 232 240; --ring: 71 85 105; }
html.dark[data-accent="green"]  { --brand: 74 222 128;  --brand-700: 34 197 94;  --brand-soft: 18 52 34; }
html.dark[data-accent="teal"]   { --brand: 45 212 191;  --brand-700: 20 184 166; --brand-soft: 12 51 47; }
html.dark[data-accent="indigo"] { --brand: 129 140 248; --brand-700: 99 102 241; --brand-soft: 30 33 74; }
html.dark[data-accent="violet"] { --brand: 167 139 250; --brand-700: 139 92 246; --brand-soft: 44 30 74; }
html.dark[data-accent="gold"]   { --brand: 224 179 80;  --brand-700: 202 138 4;  --brand-soft: 60 48 18; }
html.dark[data-accent="rose"]   { --brand: 251 113 133; --brand-700: 244 63 94;  --brand-soft: 70 22 33; }
html.dark[data-accent="slate"]  { --brand: 148 163 184; --brand-700: 100 116 139; --brand-soft: 40 48 62; }

/* ---- Density: compact tightens cards, table rows and nav ---- */
html.density-compact .card { padding: .85rem 1rem; }
html.density-compact table.dataTable td,
html.density-compact table.dataTable th,
html.density-compact .ea-table td,
html.density-compact .ea-table th { padding-top: .3rem; padding-bottom: .3rem; }
html.density-compact .kpi-value { line-height: 1.1; }
html.density-compact .nav-item { padding-top: .4rem; padding-bottom: .4rem; }

/* ---- Base ---------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  transition: background .25s ease, color .25s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  letter-spacing: -0.006em;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgb(var(--brand) / .05), transparent 60%),
    rgb(var(--surface));
}
.rgb-ink { color: rgb(var(--ink)); }
/* Display font (Lexend) for headings, KPI numerals and section titles. */
h1, h2, h3, .kpi-value, .section-title h2,
#pageTitle, .chart-box h3 {
  font-family: var(--app-font-display);
  letter-spacing: -0.018em;
}

/* Respect reduced-motion: neutralize transitions/animations (WCAG). */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  #view > * { animation: none !important; }
}

/* Accessible focus ring across interactive elements. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid rgb(var(--ring) / .7);
  outline-offset: 2px;
  border-radius: 6px;
}
#view:focus-visible { outline: none; }   /* programmatic focus target — no ring on the page region */

/* Skip-to-content link (WCAG 2.4.1) — visible only on keyboard focus. */
.skip-link {
  position: fixed; top: 10px; inset-inline-start: 10px; z-index: 2000;
  background: rgb(var(--brand)); color: #fff; padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600; text-decoration: none;
  transform: translateY(-200%); transition: transform .15s ease;
}
.skip-link:focus { transform: translateY(0); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgb(var(--line-strong)); border-radius: 999px;
  border: 2px solid rgb(var(--panel)); }
::-webkit-scrollbar-thumb:hover { background: rgb(var(--muted)); }
::-webkit-scrollbar-track { background: transparent; }

/* ---- Surfaces / cards ---------------------------------------------------- */
.card {
  background: rgb(var(--panel));
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}
.card.chart-box:hover { box-shadow: var(--shadow-md); }
.card.hoverable:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

/* ---- Section header (page intro band) ----------------------------------- */
.section-title { display: flex; flex-direction: column; gap: .15rem; margin-bottom: .25rem; }
.section-title h2 { font-size: 1.15rem; font-weight: 700; color: rgb(var(--ink)); margin: 0; }
.section-title p { font-size: .82rem; color: rgb(var(--muted)); margin: 0; }

/* ---- KPI cards ----------------------------------------------------------- */
.kpi {
  padding: 1.1rem 1.15rem; display: flex; flex-direction: column; gap: .3rem;
  position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(rgb(var(--brand)), rgb(var(--brand-700)));
  opacity: 0; transition: opacity .18s ease;
}
.kpi:hover::before { opacity: 1; }
.kpi-value { font-size: 1.7rem; font-weight: 720; font-variant-numeric: tabular-nums;
  line-height: 1.08; color: rgb(var(--ink)); letter-spacing: -0.02em; }
.kpi-label { font-size: .72rem; color: rgb(var(--muted)); font-weight: 500;
  text-transform: uppercase; letter-spacing: .04em; }
.kpi-delta { font-size: .72rem; font-weight: 600; display: inline-flex; align-items: center; gap: .15rem; }
.kpi-delta.good { color: rgb(var(--success)); }
.kpi-delta.bad { color: rgb(var(--error)); }

.chart-box { padding: 1.15rem 1.25rem; }
.chart-box h3 { font-size: .9rem; font-weight: 650; margin: 0 0 .85rem; color: rgb(var(--ink)); }
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 420px; }

/* ---- Navigation ---------------------------------------------------------- */
.nav-item {
  display: flex; align-items: center; gap: .7rem; position: relative;
  padding: .5rem .7rem; border-radius: var(--radius-sm);
  color: rgb(var(--ink-2)); cursor: pointer; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: rgb(var(--surface-2)); color: rgb(var(--ink)); }
.nav-item.active { background: rgb(var(--brand-soft)); color: rgb(var(--brand)); font-weight: 650; }
.nav-item.active::before {
  content: ""; position: absolute; inset-inline-start: -3px; top: 18%; bottom: 18%;
  width: 3px; border-radius: 999px; background: rgb(var(--brand));
}
/* ---- Collapsible nav groups (accordion) --------------------------------- */
.nav-section { display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: .8rem .7rem .35rem; font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: rgb(var(--muted)); font-weight: 700;
  background: none; border: 0; cursor: pointer; text-align: start;
  transition: color .15s ease; }
.nav-section:hover { color: rgb(var(--ink-2)); }
.nav-chev { flex: none; opacity: .65; transition: transform .18s ease; }
.nav-group.collapsed .nav-chev { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-items { display: none; }
.nav-group-items { display: flex; flex-direction: column; gap: .12rem; }

/* ---- Rail (icon-only) collapse ------------------------------------------- */
#sidebar { transition: width .18s ease; }
#sidebar.sidebar-rail { width: 4.25rem; }
#sidebar.sidebar-rail .sidebar-title,
#sidebar.sidebar-rail .sidebar-foot-text,
#sidebar.sidebar-rail .nav-label,
#sidebar.sidebar-rail .nav-section { display: none; }
#sidebar.sidebar-rail .nav-group.collapsed .nav-group-items { display: flex; }
#sidebar.sidebar-rail .nav-group { margin-bottom: .3rem; }
#sidebar.sidebar-rail .nav-item { justify-content: center; padding: .55rem; }
#sidebar.sidebar-rail .nav-item.active::before { inset-inline-start: 0; }
#sidebar.sidebar-rail > div:first-child { padding-inline: 0; justify-content: center; }
#sidebar.sidebar-rail .p-3 > .flex { justify-content: center; }

/* ---- Pills / badges / status -------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem;
  border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; }
.pill-high { background: rgb(var(--error) / .12); color: rgb(var(--error)); }
.pill-medium { background: rgb(var(--warning) / .14); color: rgb(var(--warning)); }
.pill-low { background: rgb(var(--muted) / .14); color: rgb(var(--ink-2)); }
.pill-success { background: rgb(var(--success) / .13); color: rgb(var(--success)); }
.pill-info { background: rgb(var(--info) / .13); color: rgb(var(--info)); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .85; }

.badge { font-size: 10px; padding: 2px 7px; border-radius: 6px;
  background: rgb(var(--brand-soft)); color: rgb(var(--brand)); font-weight: 600;
  border: 1px solid rgb(var(--brand) / .14); }

/* ---- Buttons (utility classes; opt-in) ----------------------------------- */
.btn { display: inline-flex; align-items: center; gap: .45rem; height: 2.25rem;
  padding: 0 .95rem; border-radius: var(--radius-sm); font-size: .85rem; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: all .15s ease; }
.btn-primary { background: linear-gradient(135deg, rgb(var(--brand)), rgb(var(--brand-700)));
  color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { filter: brightness(1.06); box-shadow: var(--shadow-md); }
.btn-ghost { background: rgb(var(--panel)); border-color: rgb(var(--line)); color: rgb(var(--ink)); }
.btn-ghost:hover { background: rgb(var(--surface-2)); border-color: rgb(var(--line-strong)); }

/* ---- Grids --------------------------------------------------------------- */
.grid-kpi { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0,1fr)); }
@media (min-width: 768px) { .grid-kpi { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (min-width: 1280px) { .grid-kpi { grid-template-columns: repeat(6, minmax(0,1fr)); } }
.grid-charts { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .grid-charts { grid-template-columns: 1fr 1fr; } }
.col-span-2 { grid-column: span 2; }
@media (max-width: 1023px) { .col-span-2 { grid-column: span 1; } }

canvas { max-width: 100%; }

/* ---- Toast --------------------------------------------------------------- */
.toast-item { background: rgb(var(--panel)); border: 1px solid rgb(var(--line));
  border-radius: var(--radius); padding: .8rem 1.05rem; box-shadow: var(--shadow-lg);
  font-size: .85rem; border-inline-start: 4px solid rgb(var(--brand));
  animation: toastIn .22s cubic-bezier(.2,.8,.2,1); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---- Search / command --------------------------------------------------- */
.search-row { padding: .55rem .8rem; cursor: pointer; font-size: .85rem;
  border-bottom: 1px solid rgb(var(--line)); transition: background .12s ease; }
.search-row:hover { background: rgb(var(--surface-2)); }
.search-row:last-child { border-bottom: 0; }
.cmdk-on { background: rgb(var(--brand-soft)); }
.cmdk-row { display: flex; }

/* ---- Perspective switch -------------------------------------------------- */
.persp-btn { color: rgb(var(--muted)); background: rgb(var(--panel)); transition: all .15s ease; font-weight: 500; }
.persp-btn:hover { color: rgb(var(--ink)); background: rgb(var(--surface-2)); }
.persp-btn.active { background: linear-gradient(135deg, rgb(var(--brand)), rgb(var(--brand-700)));
  color: #fff; font-weight: 600; }

/* ---- Comparison / matrices ---------------------------------------------- */
.cmp-grid { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
.delta-up { color: rgb(var(--success)); } .delta-down { color: rgb(var(--error)); }
.sbs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem;
  padding: .6rem .75rem; border-bottom: 1px solid rgb(var(--line)); }
.sbs:last-child { border-bottom: 0; }
.matrix-cell { text-align: center; padding: .45rem .5rem; border: 1px solid rgb(var(--line));
  font-variant-numeric: tabular-nums; font-size: .82rem; }
thead th.matrix-cell { background: rgb(var(--panel-2)); color: rgb(var(--ink-2));
  font-weight: 650; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em;
  position: sticky; top: 0; z-index: 1; }
tbody tr:hover .matrix-cell { background: rgb(var(--surface-2)); }

/* ---- DataTables harmonization ------------------------------------------- */
.dataTables_wrapper { color: rgb(var(--ink)); font-size: .82rem; }
table.dataTable { width: 100% !important; }
table.dataTable thead th { color: rgb(var(--ink-2)); border-color: rgb(var(--line)) !important;
  font-weight: 650; text-transform: uppercase; font-size: .72rem; letter-spacing: .03em; }
table.dataTable tbody td { color: rgb(var(--ink)); border-color: rgb(var(--line)); }
table.dataTable tbody tr { background: rgb(var(--panel)); }
table.dataTable tbody tr:hover { background: rgb(var(--surface-2)); }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: rgb(var(--surface)); color: rgb(var(--ink));
  border: 1px solid rgb(var(--line)); border-radius: .5rem; padding: .25rem .55rem; }
.dataTables_wrapper .dataTables_paginate .paginate_button { color: rgb(var(--ink)) !important; }
.dataTables_wrapper .dataTables_info, .dataTables_wrapper .dataTables_paginate { color: rgb(var(--muted)); }

/* ---- Skeleton loader ----------------------------------------------------- */
.skeleton { background: linear-gradient(90deg, rgb(var(--surface-2)) 25%, rgb(var(--line)) 37%, rgb(var(--surface-2)) 63%);
  background-size: 400% 100%; animation: sk 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---- Landscape / capability heatmap (fully responsive) ------------------ */
.ls-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.ls-group { padding: 1rem 1.1rem; min-width: 0; }
.ls-group-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .6rem; }
.ls-group-head > .min-w-0 { min-width: 0; flex: 1; }
.ls-group-name { font-family: 'Lexend','Tajawal',sans-serif; font-weight: 650; font-size: .95rem; color: rgb(var(--ink)); }
.ls-group-sub { font-size: 11px; color: rgb(var(--muted)); margin-top: 1px; }
.ls-score { width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center;
  font-family: 'Lexend',sans-serif; font-weight: 800; font-size: 1.05rem; color: #fff; box-shadow: var(--shadow-sm); }
.ls-meter { height: 6px; border-radius: 999px; background: rgb(var(--surface-2)); overflow: hidden; margin-bottom: .85rem; }
.ls-meter > div { height: 100%; border-radius: 999px; transition: width .4s ease; }
.ls-tiles { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); }
.ls-tile { position: relative; min-width: 0; padding: .55rem .6rem .65rem; border-radius: 10px; border: 1px solid transparent;
  transition: transform .15s ease, box-shadow .15s ease; }
.ls-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.ls-tile-name { font-size: 12px; font-weight: 600; color: rgb(var(--ink)); line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ls-tile-foot { display: flex; align-items: center; justify-content: space-between; font-size: 10.5px;
  margin: .25rem 0 .35rem; }
.ls-tile-foot b { font-variant-numeric: tabular-nums; color: rgb(var(--ink)); }
.ls-tile-meter { height: 4px; border-radius: 999px; background: rgb(var(--surface-2)); overflow: hidden; }
.ls-tile-meter > div { height: 100%; border-radius: 999px; }

/* ---- Enterprise heatmap grid -------------------------------------------- */
.hx-table { border-collapse: separate; border-spacing: 4px; width: 100%; }
.hx-cell { padding: 0; }
.hx-head { font-size: 11px; font-weight: 650; color: rgb(var(--muted)); text-transform: uppercase;
  letter-spacing: .03em; text-align: center; padding: 4px 6px; white-space: nowrap; }
.hx-rowhead { font-size: 12px; font-weight: 600; color: rgb(var(--ink)); text-align: start;
  padding-inline-end: 10px; white-space: nowrap; }
.hx-chip { min-width: 44px; height: 36px; border-radius: 8px; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); transition: transform .12s ease; cursor: default; }
.hx-chip:hover { transform: scale(1.07); box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(255,255,255,.2); }

/* ---- GRC risk matrix ----------------------------------------------------- */
.grc-matrix { border-collapse: separate; border-spacing: 3px; }
.grc-cell { width: 52px; height: 40px; border-radius: 7px; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; transition: transform .12s ease; cursor: default; }
.grc-cell:hover { transform: scale(1.08); box-shadow: var(--shadow-md); }
.grc-axis { font-size: 10px; color: rgb(var(--muted)); text-align: end; padding-inline-end: 6px; white-space: nowrap; }
.grc-axis-corner { width: 60px; }
.grc-axis-col { font-size: 11px; font-weight: 600; color: rgb(var(--muted)); text-align: center; padding-top: 4px; }

/* ---- View enter animation ----------------------------------------------- */
#view > * { animation: viewIn .26s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Print / PDF export -------------------------------------------------- */
@media print {
  #sidebar, header, #copilotBtn, #copilot, #notifMenu, #userMenu, #cmdk,
  .persp-btn, #perspSwitch, #langBtn, #themeSel, #navToggle, #phTour,
  #tourOverlay, #tourPop, .no-print { display: none !important; }
  body, .bg-surface, .bg-panel { background: #fff !important; }
  main, #view, .flex-1 { margin: 0 !important; max-width: 100% !important; }
  .card { box-shadow: none !important; border: 1px solid #e5e7eb !important; break-inside: avoid; }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  @page { margin: 14mm; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ============================================================
   Dynamic Dashboards — customizer chrome (DD-2)
   ============================================================ */
.dash-toolbar { display: flex; justify-content: flex-end; gap: .5rem; margin: 0 0 .5rem; }
.dash-ctl {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 32px; padding: .3rem .6rem; border-radius: .55rem;
  border: 1px solid rgb(var(--line)); background: rgb(var(--surface)); color: rgb(var(--ink));
  font-size: .78rem; font-weight: 600; cursor: pointer; transition: background .15s ease, border-color .15s ease;
}
.dash-ctl:hover { background: rgb(var(--panel)); border-color: rgb(var(--brand)); }
.dash-ctl:focus-visible { outline: 2px solid rgb(var(--brand)); outline-offset: 2px; }
.dash-edit { color: rgb(var(--brand)); }
.dash-reset { color: #dc2626; border-color: #dc262644; }
select.dash-ctl { padding-block: .25rem; }

/* hidden widgets (saved pref) — removed from layout flow */
.card.dash-hidden { display: none !important; }
/* wide span (works in grid-kpi / grid-charts) */
.card.dash-wide { grid-column: span 2; }
@media (max-width: 1023px) { .card.dash-wide { grid-column: span 1; } }

/* edit mode: outline widgets + reveal per-widget control bar */
.dash-editing .card { position: relative; outline: 1px dashed rgb(var(--brand) / .5); outline-offset: 2px; }
.dash-editing .card.dash-hidden { display: flex !important; opacity: .45; }  /* show ghosts while editing */
.dash-widget-bar {
  position: absolute; top: 4px; inset-inline-end: 4px; z-index: 5;
  display: flex; align-items: center; gap: 2px; padding: 2px;
  background: rgb(var(--surface) / .92); border: 1px solid rgb(var(--line)); border-radius: .5rem;
  box-shadow: 0 2px 8px rgb(0 0 0 / .12);
}
.dash-widget-bar .dash-ctl { min-height: 28px; min-width: 28px; padding: .2rem .3rem; }
.dash-grip { display: inline-flex; padding: 2px; cursor: grab; color: rgb(var(--muted)); }
.dash-editing .card[draggable="true"] { cursor: grab; }
.card.dash-dragging { opacity: .55; outline: 2px solid rgb(var(--brand)); }

/* hidden tray */
.dash-tray { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; width: 100%; margin-top: .4rem; }
.dash-tray-label { font-size: .75rem; color: rgb(var(--muted)); }
.dash-chip {
  font-size: .75rem; padding: .25rem .55rem; border-radius: 999px; cursor: pointer;
  border: 1px dashed rgb(var(--line)); background: rgb(var(--panel)); color: rgb(var(--ink));
}
.dash-chip:hover { border-color: rgb(var(--brand)); color: rgb(var(--brand)); }
.dash-chip:focus-visible { outline: 2px solid rgb(var(--brand)); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) { .dash-ctl { transition: none; } }

/* Dynamic Dashboards — single page-level toolbar (DD-4) */
.dash-page-toolbar { display: flex; justify-content: flex-end; gap: .5rem; margin: 0 0 .75rem; flex-wrap: wrap; }
.dash-page-toolbar .dash-edit span { margin-inline-start: .35rem; }
.dash-grip:focus-visible { outline: 2px solid rgb(var(--brand)); outline-offset: 2px; border-radius: 4px; }

/* ============================================================================
   PERSONALIZATION PANEL (prefs.js)
   ========================================================================== */
.prefs-overlay { position: fixed; inset: 0; z-index: 240; background: rgba(15,23,42,.45);
  opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s ease; }
.prefs-overlay.open { opacity: 1; visibility: visible; }
.prefs-panel { position: absolute; inset-block: 0; inset-inline-end: 0; width: min(380px, 92vw);
  background: rgb(var(--panel)); color: rgb(var(--ink)); box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column; transform: translateX(8%); opacity: .6;
  transition: transform .22s ease, opacity .22s ease; }
html[dir="rtl"] .prefs-panel { transform: translateX(-8%); }
.prefs-overlay.open .prefs-panel { transform: none; opacity: 1; }
.prefs-head { display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.1rem; border-bottom: 1px solid rgb(var(--line)); }
.prefs-body { flex: 1; overflow-y: auto; padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 1.15rem; }
.prefs-sec { display: flex; flex-direction: column; gap: .5rem; }
.prefs-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: rgb(var(--muted)); }
.prefs-foot { display: flex; gap: .6rem; padding: .85rem 1.1rem; border-top: 1px solid rgb(var(--line)); }
.prefs-foot .ea-btn-primary { margin-inline-start: auto; }
.prefs-hint { font-size: .72rem; color: rgb(var(--muted)); line-height: 1.45; margin-top: .15rem; }
.prefs-sample { font-size: .9rem; color: rgb(var(--ink-2)); padding: .5rem .65rem;
  background: rgb(var(--surface)); border: 1px solid rgb(var(--line)); border-radius: var(--radius-sm); }
/* segmented control */
.ea-seg { display: inline-flex; background: rgb(var(--surface)); border: 1px solid rgb(var(--line));
  border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.ea-seg-btn { flex: 1; padding: .4rem .7rem; font-size: .85rem; font-weight: 600; border-radius: 6px;
  color: rgb(var(--ink-2)); cursor: pointer; transition: background .15s, color .15s; }
.ea-seg-btn.active { background: rgb(var(--brand)); color: #fff; box-shadow: var(--shadow-sm); }
/* accent swatches */
.ea-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: .45rem; }
.ea-swatch { aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  border: 2px solid transparent; padding: 0; background: transparent; }
.ea-swatch span { display: block; width: 70%; height: 70%; border-radius: 50%; box-shadow: var(--shadow-sm); }
.ea-swatch.active { border-color: rgb(var(--ink)); }
.ea-swatch:focus-visible { outline: 2px solid rgb(var(--brand)); outline-offset: 2px; }
/* select + buttons */
.ea-select { width: 100%; height: 38px; padding: 0 .65rem; border-radius: var(--radius-sm);
  border: 1px solid rgb(var(--line)); background: rgb(var(--panel)); color: rgb(var(--ink)); font-size: .9rem; }
.prefs-toggle { display: flex; align-items: center; gap: .55rem; font-size: .9rem; cursor: pointer; }
.prefs-toggle input { width: 16px; height: 16px; accent-color: rgb(var(--brand)); }
.ea-btn-soft { padding: .5rem .85rem; border-radius: var(--radius-sm); border: 1px solid rgb(var(--line));
  background: rgb(var(--surface)); color: rgb(var(--ink)); font-size: .85rem; font-weight: 600; cursor: pointer; }
.ea-btn-soft:hover { border-color: rgb(var(--brand)); }
.ea-btn-primary { padding: .5rem 1.1rem; border-radius: var(--radius-sm); background: rgb(var(--brand));
  color: #fff; font-size: .85rem; font-weight: 700; cursor: pointer; border: none; }

/* ============================================================================
   RESPONSIVE SHELL (desktop / tablet / mobile) — ui-ux-pro-max pass
   Breakpoints: phone <640, tablet 640–1023, desktop ≥1024. The fixed sidebar
   becomes an off-canvas drawer below 1024px; content goes full-width.
   ========================================================================== */
.nav-scrim { display: none; }

@media (max-width: 1023px) {
  /* The off-canvas drawer is parked outside the viewport; clip horizontal overflow so it
     never creates a page-level horizontal scrollbar. `clip` keeps the sticky header working. */
  html, body { overflow-x: clip; }
  /* Sidebar → off-canvas drawer */
  #sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 60;
    width: 17rem; max-width: 86vw;
    transform: translateX(-100%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--shadow-xl);
  }
  html[dir="rtl"] #sidebar { transform: translateX(100%); }
  body.nav-open #sidebar { transform: none; }
  /* In the drawer, always show full labels even if rail was set on desktop */
  #sidebar.sidebar-rail { width: 17rem; }
  #sidebar.sidebar-rail .sidebar-title,
  #sidebar.sidebar-rail .nav-label,
  #sidebar.sidebar-rail .sidebar-foot-text { display: revert; }
  /* Scrim */
  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(15, 23, 42, .5);
    opacity: 0; visibility: hidden; transition: opacity .22s ease;
  }
  body.nav-open .nav-scrim { opacity: 1; visibility: visible; }
  body.nav-open { overflow: hidden; }   /* lock background scroll while drawer open */
  /* Header: tighter and wrap-safe on small screens */
  #app > div > header { gap: .5rem; padding-inline: .75rem; }
}

/* Phone: hide the inline search (still reachable via ⌘K / command palette),
   give KPI cards two-up, charts single-column, comfortable tap density. */
@media (max-width: 767px) {
  #app > div > header .max-w-md { display: none; }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
  .grid-charts { grid-template-columns: 1fr; }
  .persp-btn { padding-inline: .6rem; }
  /* Data tables scroll horizontally inside their card instead of overflowing the page */
  .dataTables_wrapper, .ea-scroll-x, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Section padding a touch tighter for small screens */
  #view { padding: .85rem !important; }
}

/* Tablet: 3-up KPIs, dual charts, balanced gutters */
@media (min-width: 768px) and (max-width: 1023px) {
  .grid-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dataTables_wrapper, .ea-scroll-x, .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Main column must be allowed to shrink (min-width:0) so wide children scroll internally
   rather than pushing the page wider. The fixed off-canvas sidebar is out of flow, so the
   main column already fills 100% below 1024px. */
#app > div { min-width: 0; }
