/* Rajco HRMS — "HR Command Center"
   Layout: glowing navy rail on the left, filter header, KPI tiles, then a grid of chart panels.
   Dark is the default look; the moon button switches to light. */
:root {
  --bg: #060C1A;
  --bg-glow-1: rgba(34, 211, 238, .10);
  --bg-glow-2: rgba(168, 85, 247, .08);
  --panel: #0C1630;
  --panel-top: #10204A;
  --panel-2: #0F1C3D;
  --ink: #E7EFFF;
  --muted: #8EA2C8;
  --line: rgba(96, 150, 255, .18);
  --line-strong: rgba(96, 190, 255, .38);
  --accent: #22D3EE;
  --accent-2: #3B82F6;
  --accent-ink: #04121F;
  --accent-soft: rgba(34, 211, 238, .14);
  --rail: #071027;
  --rail-ink: #B9C8E6;
  --rail-active: rgba(34, 211, 238, .14);
  --present: #22C55E;
  --leave: #F59E0B;
  --absent: #F43F5E;
  --none: rgba(142, 162, 200, .22);
  --ok: #34D399;
  --warn: #FBBF24;
  --bad: #FB7185;
  --c1: #22D3EE; --c2: #3B82F6; --c3: #A855F7; --c4: #EC4899; --c5: #F59E0B; --c6: #22C55E; --c7: #F43F5E; --c8: #14B8A6; --c9: #94A3B8;
  --shadow: 0 0 0 1px rgba(96, 150, 255, .06), 0 10px 30px rgba(0, 0, 0, .35);
  --glow: 0 0 18px rgba(34, 211, 238, .25);
  --radius: 14px;
  --font: "Barlow", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-head: "Barlow Semi Condensed", "Barlow", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #EDF2FA; --bg-glow-1: rgba(8, 145, 178, .08); --bg-glow-2: rgba(124, 58, 237, .05);
  --panel: #FFFFFF; --panel-top: #F6F9FF; --panel-2: #F3F7FD;
  --ink: #0B1530; --muted: #5A6B8D; --line: #D9E2F0; --line-strong: #9CC8E8;
  --accent: #0891B2; --accent-2: #2563EB; --accent-ink: #FFFFFF; --accent-soft: rgba(8, 145, 178, .10);
  --rail: #0B1736; --rail-ink: #C3D0EA; --rail-active: rgba(34, 211, 238, .16);
  --present: #16A34A; --leave: #D97706; --absent: #E11D48; --none: #DCE4F0;
  --ok: #059669; --warn: #B45309; --bad: #E11D48;
  --c1: #0891B2; --c2: #2563EB; --c3: #7C3AED; --c4: #DB2777; --c5: #D97706; --c6: #16A34A; --c7: #E11D48; --c8: #0D9488; --c9: #64748B;
  --shadow: 0 1px 2px rgba(11, 21, 48, .06), 0 6px 18px rgba(11, 21, 48, .06);
  --glow: none;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 85% -10%, var(--bg-glow-1), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, var(--bg-glow-2), transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, .tile-value, .brand-name, .kpi-value { font-family: var(--font-head); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.boot { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* ---------- sign in ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: linear-gradient(180deg, var(--panel-top), var(--panel)); border: 1px solid var(--line-strong); border-radius: 18px; padding: 30px; box-shadow: var(--shadow), var(--glow); }
.auth h1 { font-size: 24px; margin: 24px 0 4px; }
.auth p { margin: 0 0 18px; color: var(--muted); }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--c1), var(--c3)); color: #fff; display: grid; place-items: center; font-weight: 800; font-family: var(--font-head); font-size: 18px; letter-spacing: .02em; box-shadow: var(--glow); }
.brand-name { font-weight: 700; font-size: 20px; letter-spacing: .06em; line-height: 1; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .28em; text-transform: uppercase; margin-top: 3px; }

.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.input, select.input { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); min-height: 40px; }
.input:focus, .btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--line-strong); }
.btn.primary { background: linear-gradient(135deg, var(--c1), var(--c2)); border-color: transparent; color: #fff; box-shadow: var(--glow); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { min-height: 32px; padding: 4px 11px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.msg { padding: 10px 12px; border-radius: 10px; font-size: 13.5px; margin-bottom: 14px; }
.msg.err { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.msg.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100%; }
.rail { background: linear-gradient(180deg, var(--rail), #050B1C); color: var(--rail-ink); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; border-right: 1px solid rgba(96, 150, 255, .14); }
.rail .brand-name { color: #fff; }
.brand-link { text-decoration: none; color: inherit; display: block; border-radius: 10px; padding: 2px; }
.brand-link:hover .brand-mark { filter: brightness(1.15); }
.nav { display: grid; gap: 3px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; opacity: .55; padding: 14px 12px 4px; }
.nav a { color: var(--rail-ink); text-decoration: none; padding: 9px 12px; border-radius: 10px; display: flex; align-items: center; gap: 11px; border: 1px solid transparent; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav a.active { background: var(--rail-active); color: #fff; font-weight: 700; border-color: rgba(34, 211, 238, .55); box-shadow: 0 0 16px rgba(34, 211, 238, .25), inset 0 0 12px rgba(34, 211, 238, .10); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.copilot { margin-top: auto; border-radius: 14px; padding: 14px; text-align: center; background: linear-gradient(160deg, rgba(59, 130, 246, .22), rgba(168, 85, 247, .18)); border: 1px solid rgba(96, 150, 255, .35); }
.copilot-orb { width: 52px; height: 52px; margin: 0 auto 8px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, var(--c1) 30%, var(--c2) 60%, #1E1B4B 100%); box-shadow: 0 0 22px rgba(34, 211, 238, .55); }
.copilot b { color: #fff; font-family: var(--font-head); font-size: 17px; display: block; }
.copilot p { font-size: 12.5px; margin: 4px 0 10px; }
.copilot .soon { display: inline-block; font-size: 12px; font-weight: 700; padding: 5px 14px; border-radius: 999px; border: 1px solid rgba(34, 211, 238, .5); color: var(--c1); }
.rail-foot { font-size: 12.5px; display: grid; gap: 8px; }
.rail-foot .btn { background: transparent; color: var(--rail-ink); border-color: rgba(255, 255, 255, .16); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px max(20px, env(safe-area-inset-right, 0px)) 14px max(26px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 22px; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .01em; }
.top h1 em { font-style: normal; background: linear-gradient(90deg, var(--c1), var(--c2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-search { margin-left: auto; position: relative; width: min(340px, 34vw); }
.top-search input { width: 100%; padding: 9px 12px 9px 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); min-height: 40px; }
.top-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); }
.user-chip .avatar { width: 32px; height: 32px; font-size: 12px; }
.user-chip b { font-family: var(--font-head); font-size: 15px; display: block; line-height: 1.1; }
.user-chip small { display: inline-block; font-size: 11px; color: var(--c5); border: 1px solid color-mix(in srgb, var(--c5) 60%, transparent); padding: 0 6px; border-radius: 6px; margin-top: 2px; }
.menu-btn { display: none; }
.content { padding: 22px max(20px, env(safe-area-inset-right, 0px)) 44px max(26px, env(safe-area-inset-left, 0px)); display: grid; gap: 18px; max-width: 1600px; width: 100%; }

/* ---------- panels ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.card { background: linear-gradient(180deg, var(--panel-top), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 18px; margin: 0; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card h2 svg { width: 19px; height: 19px; color: var(--c1); }
.card .note { color: var(--muted); font-size: 12.5px; margin: 2px 0 12px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.toolbar .field { margin: 0; min-width: 150px; }

.tiles { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
.tile { position: relative; overflow: hidden; background: linear-gradient(160deg, var(--panel-top), var(--panel)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 4px; }
.tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 2px; background: var(--tc, var(--c1)); opacity: .9; }
.tile-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile-value { font-size: 32px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12.5px; color: var(--muted); }
.tile.alert .tile-value { color: var(--bad); }
.kpi { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; }
.kpi-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--tc, var(--c1)), color-mix(in srgb, var(--tc, var(--c1)) 55%, #000)); box-shadow: 0 0 16px color-mix(in srgb, var(--tc, var(--c1)) 45%, transparent); }
.kpi-icon svg { width: 24px; height: 24px; }
.up-bad, .down-good { color: var(--bad); }
.down-bad, .up-good { color: var(--ok); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 3px 11px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; }
.chip b { font-variant-numeric: tabular-nums; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.pill.mute { background: var(--panel-2); color: var(--muted); }
.pill.info { background: color-mix(in srgb, var(--c2) 18%, transparent); color: var(--c1); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 9px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--accent-soft); }
.scroll-box { max-height: 540px; overflow: auto; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }
.who { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.who small { display: block; color: var(--muted); font-size: 12px; }
td.nowrap, .nowrap { white-space: nowrap; }

/* ---------- bars ---------- */
.stack { display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: var(--none); min-width: 90px; }
.stack span { display: block; height: 100%; }
.s-present { background: var(--present); }
.s-leave { background: var(--leave); }
.s-absent { background: var(--absent); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 5px 0; font-size: 13.5px; }
.hbar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .bar { height: 9px; border-radius: 5px; background: linear-gradient(90deg, var(--c2), var(--c1)); min-width: 2px; }
.hbar .val { font-variant-numeric: tabular-nums; color: var(--muted); }

.cols { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding: 18px 0 0; border-bottom: 1px solid var(--line); }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; min-width: 0; }
.col .v { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col .b { width: 100%; max-width: 38px; background: linear-gradient(180deg, var(--c1), var(--c2)); border-radius: 5px 5px 0 0; min-height: 2px; }
.col .pair { display: flex; gap: 3px; align-items: flex-end; width: 100%; justify-content: center; height: 100%; }
.col .pair .b { max-width: 18px; }
.col .pair .b.alt { background: linear-gradient(180deg, var(--c4), var(--c7)); }
.col-labels { display: flex; gap: 10px; margin-top: 6px; }
.col-labels span { flex: 1; text-align: center; font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col.today .b { background: linear-gradient(180deg, var(--c3), var(--c4)); }

/* ---------- command center ---------- */
.cc-head { display: flex; align-items: end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.cc-head .sub { color: var(--muted); font-size: 14px; }
.cc-grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; } .span-12 { grid-column: span 12; }
.cc-main { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: start; }
.cc-main .card { min-height: 280px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-family: var(--font); font-size: 11px; }
.chart .val { font-size: 11.5px; }
.chart .val { fill: var(--ink); font-weight: 600; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.donut-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 14px; align-items: center; }
.donut-legend { display: grid; gap: 5px; font-size: 13px; min-width: 0; }
.donut-legend div { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; }
.donut-legend i { width: 10px; height: 10px; border-radius: 50%; }
.donut-legend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend b { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); }
.rate-row { display: grid; grid-template-columns: minmax(90px, 40%) 1fr 52px; gap: 10px; align-items: center; padding: 6px 0; font-size: 14px; }
.rate-row .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rate-row .track { height: 12px; border-radius: 6px; background: var(--none); overflow: hidden; }
.rate-row .fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--c6), var(--c1)); }
.rate-row .fill.mid { background: linear-gradient(90deg, var(--c5), var(--c1)); }
.rate-row .fill.low { background: linear-gradient(90deg, var(--c7), var(--c4)); }
.rate-row b { text-align: right; font-variant-numeric: tabular-nums; }
.insights { display: grid; gap: 12px; align-content: start; }
.insight { border-radius: 12px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--ic, var(--c1)) 55%, transparent); background: linear-gradient(160deg, color-mix(in srgb, var(--ic, var(--c1)) 14%, transparent), transparent); }
.insight-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.insight-top h3 { margin: 0; font-size: 16px; display: flex; gap: 7px; align-items: center; }
.insight-top h3 svg { width: 18px; height: 18px; color: var(--ic, var(--c1)); }
.badge { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--ic, var(--c1)); color: #fff; white-space: nowrap; }
.insight .big { font-family: var(--font-head); font-size: 26px; font-weight: 700; margin: 4px 0 2px; }
.insight p { margin: 0; font-size: 12.5px; color: var(--muted); }
.alerts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }
.alert { border-radius: 12px; padding: 11px 13px; border: 1px solid color-mix(in srgb, var(--ac, var(--c5)) 50%, transparent); background: color-mix(in srgb, var(--ac, var(--c5)) 10%, transparent); text-decoration: none; color: inherit; display: block; }
.alert b { display: flex; gap: 7px; align-items: center; font-size: 14.5px; }
.alert b svg { width: 17px; height: 17px; color: var(--ac, var(--c5)); flex: none; }
.alert span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.quick { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.quick a { display: flex; align-items: center; gap: 11px; padding: 13px 14px; border-radius: 12px; text-decoration: none; color: var(--ink); font-weight: 600; border: 1px solid color-mix(in srgb, var(--qc, var(--c1)) 55%, transparent); background: linear-gradient(160deg, color-mix(in srgb, var(--qc, var(--c1)) 18%, transparent), transparent); }
.quick a:hover { box-shadow: 0 0 16px color-mix(in srgb, var(--qc, var(--c1)) 40%, transparent); }
.quick svg { width: 26px; height: 26px; color: var(--qc, var(--c1)); flex: none; }
.quick small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

/* ---------- profile ---------- */
.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; overflow: hidden; flex: none; border: 1px solid var(--line); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 96px; height: 96px; font-size: 28px; border-radius: 16px; }
.avatar[data-emp] { cursor: zoom-in; }
.profile-head h2 { font-size: 24px; margin: 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px 20px; margin-top: 14px; }
.kv div { min-width: 0; }
.kv dt { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.kv dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal .dow { font-size: 11px; color: var(--muted); text-align: center; padding-bottom: 2px; }
.cal .day { border-radius: 8px; padding: 5px 5px; min-height: 54px; background: var(--panel-2); border: 1px solid var(--line); font-size: 11px; display: grid; align-content: space-between; }
.cal .day b { font-size: 12.5px; }
.cal .day.p { border-color: color-mix(in srgb, var(--present) 55%, transparent); background: color-mix(in srgb, var(--present) 14%, transparent); }
.cal .day.a { border-color: color-mix(in srgb, var(--absent) 60%, transparent); background: color-mix(in srgb, var(--absent) 15%, transparent); }
.cal .day.l { border-color: color-mix(in srgb, var(--leave) 60%, transparent); background: color-mix(in srgb, var(--leave) 15%, transparent); }
.cal .day.blank { background: transparent; border: 0; }
.cal .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { height: 9px; border-radius: 5px; background: var(--none); overflow: hidden; }
.meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--c2), var(--c1)); }

/* ---------- users ---------- */
.rights { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 6px 16px; }
.check { display: flex; gap: 8px; align-items: center; padding: 4px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 0 16px; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 16px 0 8px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 13px; }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }

/* ---------- hover card ---------- */
.hovercard { position: fixed; z-index: 50; width: 330px; max-width: calc(100vw - 16px); background: linear-gradient(170deg, var(--panel-top), var(--panel)); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 14px 40px rgba(0, 0, 0, .45), var(--glow); padding: 14px 16px; pointer-events: none; }
.hc-head { display: flex; gap: 12px; align-items: center; }
.hc-head .avatar.lg { width: 76px; height: 76px; font-size: 22px; }
.hc-name { font-weight: 700; font-size: 16px; line-height: 1.25; font-family: var(--font-head); }
.hc-sub { color: var(--muted); font-size: 12.5px; margin: 2px 0 5px; }
.hc-kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 12px 0 0; font-size: 13px; }
.hc-kv dt { color: var(--muted); }
.hc-kv dd { margin: 0; overflow-wrap: anywhere; }
.hc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 6px; margin-top: 12px; }
.hc-stats div { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 6px 4px; text-align: center; }
.hc-stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; font-family: var(--font-head); }
.hc-stats b.bad { color: var(--bad); }
.hc-stats span { font-size: 11px; color: var(--muted); }
.hc-stats b.good { color: var(--ok); }
.hc-lvbox { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line); }
.hc-lv { display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; margin-top: 6px; }
.hc-lv span { color: var(--muted); }
.hc-lv .ln-bar { margin-top: 0; }
.hc-lv b { font-family: var(--font-head); font-variant-numeric: tabular-nums; }
.hc-lv b small { color: var(--muted); font-weight: 500; }
.tipcard {width: 300px; z-index: 70; }
.seg { cursor: pointer; transition: stroke-width .15s; }
.seg:hover { stroke-width: 24; }
.seg-row { cursor: default; border-radius: 6px; }
.seg-row:hover { background: var(--panel-2); }
.ln-block { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.ln-block .hc-kv { margin-top: 6px; }
.ln-block .hc-kv small { color: var(--muted); }
.ln-block b.bad { color: var(--bad); }
.ln-title { font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.ln-bar { height: 6px; border-radius: 99px; background: var(--panel-2); margin-top: 9px; overflow: hidden; }
.ln-bar span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--c6), var(--c1)); }
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(2, 6, 18, .62); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; }
.modal { width: 100%; max-width: 900px; max-height: 86vh; display: flex; flex-direction: column; background: linear-gradient(170deg, var(--panel-top), var(--panel)); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5), var(--glow); padding: 18px 20px; }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.modal-head h2 { margin: 0; }
.modal-head .note { margin: 4px 0 0; }
.modal #mdbody { min-height: 0; display: flex; flex-direction: column; }
.modal-scroll { max-height: none !important; overflow: auto; }
.hc-note {font-size: 11px; color: var(--muted); margin-top: 6px; text-align: right; }

/* ---------- responsive ---------- */
@media (max-width: 1400px) { .cc-main { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1180px) {
  .span-3, .span-4, .span-5, .span-6, .span-8, .span-9 { grid-column: span 12; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; z-index: 20; left: 0; top: 0; bottom: 0; width: 270px; transform: translateX(-100%); transition: transform .2s ease; padding-top: max(18px, env(safe-area-inset-top, 0px)); }
  .shell.menu-open .rail { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .5); }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 15; }
  .menu-btn { display: inline-flex; }
  .top { padding-left: max(12px, env(safe-area-inset-left, 0px)); top: env(safe-area-inset-top, 0px); flex-wrap: wrap; }
  .top-search { order: 5; width: 100%; margin-left: 0; }
  .user-chip .who-text { display: none; }
  .content { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .cc-main { grid-template-columns: 1fr; }
  .tile-value { font-size: 26px; }
  .hide-sm { display: none; }
  .donut-wrap { grid-template-columns: 120px 1fr; }
}
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }
/* bottom sheet used on touch screens for donut and loan summaries */
.tipcard.sheet { left: 8px !important; right: 8px; top: auto !important; bottom: max(8px, env(safe-area-inset-bottom, 0px)); width: auto; max-width: 560px; margin: 0 auto; max-height: 78vh; overflow: auto; pointer-events: auto; padding-top: 16px; }
.sheet-x { position: sticky; top: 0; float: right; margin: -6px -6px 0 8px; z-index: 1; }
.sheet-open { width: 100%; margin-top: 14px; }
@media (max-width: 600px) {
  .top { gap: 6px; padding-top: 8px; padding-bottom: 8px; padding-right: max(10px, env(safe-area-inset-right, 0px)); }
  .top h1 { flex: 1 1 0; font-size: 17px; }
  .top .btn.ghost { padding: 6px 8px; min-height: 36px; }
  .user-chip { padding: 2px; }
  .kpi { grid-template-columns: 1fr; gap: 8px; align-items: start; }
  .kpi-icon { width: 36px; height: 36px; border-radius: 10px; }
  .kpi-icon svg { width: 19px; height: 19px; }
  .top-search input { min-height: 38px; }
  .modal-back { padding: max(10px, env(safe-area-inset-top, 0px)) 8px 8px; }
  .modal { max-height: calc(100vh - 20px); padding: 14px; border-radius: 14px; }
  .modal-head h2 { font-size: 18px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile-value { font-size: 22px; }
  .card { padding: 14px; }
  .toolbar { gap: 8px; }
  .toolbar .field { flex: 1 1 140px; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut-wrap .chart { max-width: 190px; }
  .donut-legend { width: 100%; }
  .seg-row { padding: 4px 6px; }
}

/* ---------- employee spotlight ---------- */
.spot-hero { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.spot-photo { width: 168px; height: 168px; border-radius: 22px; font-size: 44px; border: 2px solid var(--line-strong); box-shadow: var(--glow); }
.spot-id { display: grid; gap: 8px; min-width: 0; flex: 1 1 280px; }
@media (max-width: 600px) {
  .spot-hero { gap: 14px; align-items: flex-start; }
  .spot-photo { width: 104px !important; height: 104px !important; border-radius: 18px; }
  .spot-id { flex-basis: 100%; }
  .spot-name { font-size: 26px !important; overflow-wrap: anywhere; }
  .spot-role { font-size: 14px; }
  .spot .chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .spot .chip { white-space: nowrap; }
  .salary-box .btn { width: 100%; }
  .salary-reveal b { font-size: 22px; }
}
.spot-name { font-family: var(--font-head); font-size: 34px; font-weight: 700; line-height: 1.05; }
.spot-role { color: var(--muted); font-size: 15px; }
.salary-box { margin-top: 4px; }
.salary-box .btn svg { width: 18px; height: 18px; }
.salary-reveal { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; padding: 10px 14px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--c1) 50%, transparent); background: var(--accent-soft); }
.salary-reveal span { color: var(--muted); font-size: 13px; }
.salary-reveal b { font-family: var(--font-head); font-size: 26px; color: var(--ink); }
.salary-reveal b.small { font-size: 16px; }
.salary-reveal small { flex-basis: 100%; color: var(--muted); font-size: 11.5px; }
.spot-bars { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding-top: 18px; }
.sb { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; position: relative; min-width: 0; }
.sb-stack { width: 100%; max-width: 28px; display: flex; flex-direction: column; border-radius: 5px; overflow: hidden; min-height: 2px; }
.sb-stack span { display: block; min-height: 0; }
.sb small { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.sb em { position: absolute; top: 0; font-style: normal; font-size: 11px; font-weight: 700; color: var(--bad); }

/* ---------- AI panel ---------- */
.copilot .btn { margin-top: 2px; }
.copilot-orb.small { width: 34px; height: 34px; margin: 0; flex: none; }
.ai-panel { position: fixed; z-index: 60; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); width: min(440px, calc(100vw - 32px)); height: min(640px, calc(100vh - 32px)); display: flex; flex-direction: column; background: linear-gradient(170deg, var(--panel-top), var(--panel)); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .55), var(--glow); overflow: hidden; }
.ai-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ai-head b { font-family: var(--font-head); font-size: 17px; display: block; }
.ai-head small { color: var(--muted); font-size: 12px; }
.ai-head .btn { margin-left: auto; }
.ai-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 92%; padding: 10px 12px; border-radius: 14px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; font-family: var(--font), "Noto Naskh Arabic", "Segoe UI", sans-serif; }
.ai-msg.bot { background: var(--panel-2); border: 1px solid var(--line); align-self: flex-start; }
.ai-msg.me { background: linear-gradient(135deg, var(--c2), var(--c3)); color: #fff; align-self: flex-end; }
.ai-msg.err { border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: var(--bad); }
.ai-msg.thinking { color: var(--muted); animation: aipulse 1.2s ease-in-out infinite; }
.ai-msg .btn { margin-top: 8px; }
.ai-li { padding-inline-start: 4px; }
.ai-gap { height: 6px; }
.ai-examples { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-ex { cursor: pointer; font-size: 12.5px; }
.ai-ex:hover { border-color: var(--line-strong); }
.ai-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.ai-form textarea { flex: 1; resize: none; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); font-family: var(--font), "Noto Naskh Arabic", sans-serif; }
@keyframes aipulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .ai-msg.thinking { animation: none; } }
@media (max-width: 900px) { .spot-photo { width: 120px; height: 120px; } .spot-name { font-size: 26px; } }
.stack-form { display: grid; gap: 12px; }
.stack-form .field { display: grid; gap: 5px; }
.stack-form .btn { justify-self: start; }
.ai-table { overflow-x: auto; margin: 6px 0; border: 1px solid var(--line); border-radius: 10px; }
.ai-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ai-table th { text-align: left; font-weight: 700; color: var(--muted); background: var(--panel); padding: 6px 8px; white-space: nowrap; }
.ai-table td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.ai-table tr td:first-child { white-space: nowrap; }
.ai-h { font-weight: 700; margin: 4px 0 2px; }
.ai-msg code { font-size: 12.5px; background: var(--panel); padding: 0 4px; border-radius: 4px; }
.ai-head .ai-clear { margin-left: auto; font-size: 12px; min-height: 30px; padding: 3px 10px; }
.ai-head .ai-clear + .btn { margin-left: 4px; }
.ai-panel { position: fixed; }
.ai-confirm { position: absolute; inset: 0; z-index: 3; background: rgba(2, 6, 18, .6); display: grid; place-items: center; padding: 16px; border-radius: inherit; }
.ai-confirm[hidden] { display: none; }
.ai-confirm-box { background: linear-gradient(170deg, var(--panel-top), var(--panel)); border: 1px solid var(--line-strong); border-radius: 14px; padding: 18px; width: min(320px, 100%); box-shadow: 0 14px 40px rgba(0, 0, 0, .45); }
.ai-confirm-box p { margin: 0 0 16px; font-weight: 600; font-size: 15px; }
.ai-confirm-btns { display: flex; gap: 10px; justify-content: flex-end; }
.ai-confirm-btns .btn { min-width: 76px; }
