/* ————————————————————————————————————————————————————————————————
   HRintel — owner desktop dashboard
   Same "digital ledger" language as the phone console (public/styles.css):
   paper + ruled lines, ink green chrome, amber accent, hairline rules.
   Divergences from that file are deliberate and desktop-specific:
     · Fraunces is chrome only (headings, section titles). Every FIGURE is
       Instrument Sans — a serif on data reads as decoration, and tabular
       figures need to align in columns.
     · The chart series colours are their own validated set (see --s-*), not
       the chip pastels: chip backgrounds are washes behind text, chart fills
       have to clear 3:1 on the card and stay separable under colour-vision
       deficiency. Both modes were validated; do not hand-tweak these.
   ———————————————————————————————————————————————————————————————— */

:root {
  /* brand — carried over from styles.css so the two surfaces agree */
  --paper: #f7f2e7;
  --paper-2: #efe7d5;
  --card: #fffdf7;
  --card-2: #fbf7ec;
  --ink: #16281f;
  --ink-2: #46584d;
  --ink-3: #7d8b80;
  --green: #12352b;
  --green-2: #1d5c48;
  --green-soft: #dcead9;
  --amber: #d98a1f;
  --amber-soft: #f6e3c2;
  --red: #b03a2e;
  --red-soft: #f3d7d1;
  --blue: #2b5f8a;
  --blue-soft: #d7e5ef;
  --line: #d9cfb8;
  --line-2: #ece4d2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(22, 40, 31, .07), 0 10px 28px -16px rgba(22, 40, 31, .22);
  --shadow-lift: 0 2px 6px rgba(22, 40, 31, .1), 0 18px 40px -20px rgba(22, 40, 31, .3);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* ---- chart roles (validated: see admin.js CHART_PALETTE note) ---- */
  --surface: var(--card);           /* the plane marks are drawn on */
  --s-present: #0b785b;
  --s-half: #cb8325;
  --s-leave: #0465a2;
  --s-absent: #a3362b;
  --s-off: #b3ab97;                 /* neutral: week-offs, holidays, unmarked */
  --s-1: var(--s-present);          /* slot 1 for single-series/nominal bars */
  --grid: #e8dfc9;                  /* hairline gridline, one step off surface */
  --axis: #cdc2a8;
  --dim: #cfc7b4;                   /* de-emphasis (sparkline track) */

  --sidebar-w: 252px;
  --topbar-h: 61px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --paper: #0e1210;
    --paper-2: #131816;
    --card: #161a18;
    --card-2: #1b201d;
    --ink: #f1ece0;
    --ink-2: #bcc4bd;
    --ink-3: #8a948c;
    --green: #0b1c16;
    --green-2: #174a3a;
    --green-soft: #16302a;
    --amber: #e0a04b;
    --amber-soft: #35291a;
    --red: #d2584a;
    --red-soft: #35201d;
    --blue: #5d93bd;
    --blue-soft: #1a2831;
    --line: #2b332e;
    --line-2: #222a25;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 28px -16px rgba(0, 0, 0, .7);
    --shadow-lift: 0 2px 6px rgba(0, 0, 0, .55), 0 18px 40px -20px rgba(0, 0, 0, .8);
    /* dark steps: same four hues re-stepped for the dark card, validated as a set */
    --s-present: #41a483;
    --s-half: #9f661f;
    --s-leave: #2e6b9c;
    --s-absent: #bc3328;
    --s-off: #5c6560;
    --grid: #252d28;
    --axis: #38423b;
    --dim: #3a423d;
  }
}
/* the viewer's explicit toggle must win in both directions */
:root[data-theme="dark"] {
  --paper: #0e1210; --paper-2: #131816; --card: #161a18; --card-2: #1b201d;
  --ink: #f1ece0; --ink-2: #bcc4bd; --ink-3: #8a948c;
  --green: #0b1c16; --green-2: #174a3a; --green-soft: #16302a;
  --amber: #e0a04b; --amber-soft: #35291a; --red: #d2584a; --red-soft: #35201d;
  --blue: #5d93bd; --blue-soft: #1a2831;
  --line: #2b332e; --line-2: #222a25;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 28px -16px rgba(0,0,0,.7);
  --shadow-lift: 0 2px 6px rgba(0,0,0,.55), 0 18px 40px -20px rgba(0,0,0,.8);
  --s-present: #41a483; --s-half: #9f661f; --s-leave: #2e6b9c; --s-absent: #bc3328;
  --s-off: #5c6560; --grid: #252d28; --axis: #38423b; --dim: #3a423d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  /* the ruled-paper texture, same 32px rhythm as the phone console */
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, color-mix(in srgb, var(--ink) 3.5%, transparent) 31px 32px),
    var(--paper);
  color: var(--ink);
  min-height: 100dvh;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }

/* figures: tabular where they must align, proportional where they're display-size */
.num { font-variant-numeric: tabular-nums; }

/* ————————————————————— shell ————————————————————— */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }

.side {
  background: linear-gradient(168deg, var(--green-2) 0%, var(--green) 62%);
  border-right: 1px solid var(--line);
  border-top: 3px solid var(--amber);
  color: #eee7d6;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 17px 18px 15px; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; background: #666EB8; display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 22px; height: 22px; display: block; }
.brand-name { font-family: var(--font-display); font-size: 18px; font-weight: 600; line-height: 1.1; letter-spacing: .01em; }
.brand-sub { font-size: 9.5px; letter-spacing: .15em; text-transform: uppercase; opacity: .6; }

.biz-pick { padding: 0 14px 14px; }
.biz-pick select {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .17);
  color: #f2ecdc; font-size: 13px; font-weight: 500;
}
.biz-pick select option { color: #16281f; }

.side-nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; }
.side-sec { font-size: 9.5px; letter-spacing: .15em; text-transform: uppercase; opacity: .45; padding: 15px 9px 6px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
  color: rgba(240, 234, 219, .78); transition: background .14s, color .14s;
  border-left: 2px solid transparent;
}
.side-nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side-nav a.on { background: rgba(255, 255, 255, .13); color: #fff; border-left-color: var(--amber); font-weight: 600; }
.side-nav .ico { width: 17px; text-align: center; font-size: 13px; opacity: .85; flex: none; }
.side-nav .tag {
  margin-left: auto; background: var(--amber); color: #3b2a08; font-size: 10px; font-weight: 700;
  border-radius: 999px; padding: 1px 6px; min-width: 18px; text-align: center;
}
.side-foot { border-top: 1px solid rgba(255, 255, 255, .11); padding: 12px 14px; font-size: 12px; }
.side-foot .who { opacity: .72; }
.side-foot button { color: #f0e9d8; opacity: .7; font-size: 12px; margin-top: 5px; text-decoration: underline; }
.side-foot button:hover { opacity: 1; }

/* ————————————————————— topbar + filters ————————————————————— */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 26px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(9px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.topbar .crumb { color: var(--ink-3); font-size: 12.5px; }

/* One filter row, above everything it scopes — never per-card. */
.filters { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.filters label { font-size: 11.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.ctrl {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--card); font-size: 13px; font-weight: 500;
}
.ctrl:hover { border-color: var(--axis); }
button.ctrl:active { transform: translateY(1px); }

.view { padding: 22px 26px 60px; max-width: 1560px; width: 100%; }
.view.reloading { opacity: .55; transition: opacity .15s; }  /* hold the frame on refetch */

/* ————————————————————— grid + cards ————————————————————— */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c5 { grid-column: span 5; }
.c6 { grid-column: span 6; } .c7 { grid-column: span 7; } .c8 { grid-column: span 8; }
.c12 { grid-column: span 12; }
@media (max-width: 1240px) {
  .c3 { grid-column: span 6; } .c4 { grid-column: span 6; } .c5, .c7, .c8 { grid-column: span 12; }
}
@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .c3, .c4, .c6 { grid-column: span 12; }
  .view { padding: 16px 14px 48px; }
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; min-width: 0;
}
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 3px; }
.card h2 { font-family: var(--font-display); font-size: 15.5px; font-weight: 600; letter-spacing: -.005em; }
.card .sub { color: var(--ink-3); font-size: 12px; margin-bottom: 13px; }
.card-head .spacer { margin-left: auto; }

/* ————————————————————— hero figure (exactly one per view) ————————————————————— */
.hero {
  grid-column: span 4;
  background: linear-gradient(152deg, var(--green-2), var(--green));
  border: none; color: #f2ecdc; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
}
.hero::after {
  content: "₹"; position: absolute; right: -10px; bottom: -46px;
  font-family: var(--font-display); font-size: 158px; font-weight: 700; opacity: .07;
}
.hero .lbl { font-size: 10.5px; letter-spacing: .15em; text-transform: uppercase; opacity: .72; }
.hero .fig {
  /* hero figure: sans, proportional figures — tabular makes big numbers look loose */
  font-size: 50px; font-weight: 600; letter-spacing: -.025em; line-height: 1.05; margin: 4px 0 2px;
}
.hero .note { font-size: 12.5px; opacity: .78; position: relative; }
.hero .hero-row { display: flex; gap: 22px; margin-top: 15px; position: relative; }
.hero .hero-row .k { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; opacity: .66; }
.hero .hero-row .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ————————————————————— stat tiles ————————————————————— */
.tile { display: flex; flex-direction: column; gap: 2px; }
.tile .lbl { font-size: 11.5px; color: var(--ink-3); letter-spacing: .02em; }
.tile .val { font-size: 25px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.tile .row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.tile .delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.tile .delta.up { color: #0b785b; } .tile .delta.down { color: var(--red); } .tile .delta.flat { color: var(--ink-3); }
:root[data-theme="dark"] .tile .delta.up { color: #41a483; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .tile .delta.up { color: #41a483; } }
.tile .spark { flex: none; }
.tile .foot { font-size: 11.5px; color: var(--ink-3); }

/* ————————————————————— charts ————————————————————— */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.axis-lbl { font-size: 10.5px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.dlabel { font-size: 10.5px; font-weight: 600; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.hit { fill: transparent; cursor: pointer; }
.seg { transition: filter .12s; }

/* legend — always present for two or more series */
.legend { display: flex; flex-wrap: wrap; gap: 6px 15px; margin: 11px 0 2px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.legend i { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend i.line { height: 3px; border-radius: 2px; width: 15px; }

/* tooltip: values lead, series names follow */
.tip {
  position: fixed; z-index: 90; pointer-events: none; opacity: 0;
  transform: translate(-50%, -100%); transition: opacity .1s;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift); padding: 9px 11px; min-width: 132px;
}
.tip.on { opacity: 1; }
.tip .t-head { font-size: 11.5px; color: var(--ink-3); margin-bottom: 5px; letter-spacing: .02em; }
.tip .t-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 1.5px 0; }
.tip .t-row i { width: 13px; height: 3px; border-radius: 2px; flex: none; }
.tip .t-row .t-v { font-weight: 700; font-variant-numeric: tabular-nums; margin-left: auto; }
.tip .t-row .t-n { color: var(--ink-2); }

/* table-view twin — every chart has one */
.tbl-toggle { font-size: 11.5px; color: var(--ink-3); text-decoration: underline; }
.tbl-toggle:hover { color: var(--ink); }
.tv { display: none; margin-top: 12px; max-height: 260px; overflow: auto; }
.tv.on { display: block; }

/* ————————————————————— tables ————————————————————— */
.tbl-scroll { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.t th {
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-3);
  font-weight: 600; position: sticky; top: 0; background: var(--card); z-index: 1;
}
table.t th.r, table.t td.r { text-align: right; font-variant-numeric: tabular-nums; }
table.t tbody tr:hover { background: var(--card-2); }
table.t tbody tr:last-child td { border-bottom: none; }
table.t td.strong { font-weight: 600; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--ink); }
table.t th .arrow { opacity: .5; font-size: 9px; }

/* meter — track is a lighter step of the fill's own ramp */
.meter { height: 7px; border-radius: 999px; background: color-mix(in srgb, var(--s-1) 16%, transparent); overflow: hidden; min-width: 70px; }
.meter i { display: block; height: 100%; border-radius: 999px; background: var(--s-1); }

/* pills / stamps */
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2.5px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; border: 1px solid var(--line); white-space: nowrap;
}
.pill.ok { background: var(--green-soft); border-color: color-mix(in srgb, var(--s-present) 34%, transparent); color: #16513c; }
.pill.warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--s-half) 34%, transparent); color: #7c5410; }
.pill.bad { background: var(--red-soft); border-color: color-mix(in srgb, var(--s-absent) 34%, transparent); color: #7c281f; }
.pill.info { background: var(--blue-soft); border-color: color-mix(in srgb, var(--s-leave) 34%, transparent); color: #234c6e; }
.pill.mute { color: var(--ink-3); }
:root[data-theme="dark"] .pill.ok { color: #8fd9bd; }
:root[data-theme="dark"] .pill.warn { color: #e3b775; }
:root[data-theme="dark"] .pill.bad { color: #eda199; }
:root[data-theme="dark"] .pill.info { color: #a6cbe6; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .pill.ok { color: #8fd9bd; }
  :root:where(:not([data-theme="light"])) .pill.warn { color: #e3b775; }
  :root:where(:not([data-theme="light"])) .pill.bad { color: #eda199; }
  :root:where(:not([data-theme="light"])) .pill.info { color: #a6cbe6; }
}

/* buttons */
.btn {
  padding: 7px 13px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--card); transition: background .14s, border-color .14s;
}
.btn:hover { background: var(--card-2); border-color: var(--axis); }
.btn.primary { background: var(--green-2); border-color: var(--green-2); color: #f2ecdc; }
.btn.primary:hover { background: var(--green); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 4px 9px; font-size: 11.5px; }

/* attendance month grid — the thing a phone genuinely can't show */
.mgrid-scroll { overflow: auto; max-height: 560px; }
table.mgrid { border-collapse: separate; border-spacing: 0; font-size: 12px; }
table.mgrid th, table.mgrid td { padding: 0; }
table.mgrid thead th {
  position: sticky; top: 0; z-index: 2; background: var(--card);
  font-size: 10px; font-weight: 600; color: var(--ink-3); width: 26px; height: 26px;
  text-align: center; border-bottom: 1px solid var(--line);
}
table.mgrid thead th.sun { color: var(--red); }
table.mgrid tbody th {
  position: sticky; left: 0; z-index: 1; background: var(--card);
  text-align: left; font-weight: 500; font-size: 12.5px; padding: 0 12px 0 2px;
  border-right: 1px solid var(--line-2); white-space: nowrap; min-width: 132px;
}
.cell { width: 26px; height: 26px; }
.cell i {
  display: block; width: 20px; height: 20px; margin: 3px; border-radius: 5px;
  border: 1px solid transparent; font-size: 0;
}
.cell i.present { background: var(--s-present); }
.cell i.half { background: var(--s-half); }
.cell i.paidleave { background: var(--s-leave); }
.cell i.absent { background: var(--s-absent); }
.cell i.off { background: var(--s-off); }
.cell i.pending { background: repeating-linear-gradient(135deg, var(--s-half) 0 3px, transparent 3px 6px); border-color: var(--s-half); }
.cell i.none { background: transparent; border: 1px dashed var(--line); }
.cell.lt i { box-shadow: inset -6px 6px 0 -3px var(--amber); }

/* misc */
.empty { padding: 26px 8px; text-align: center; color: var(--ink-3); font-size: 13px; }
.err { background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); color: #7c281f; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
:root[data-theme="dark"] .err { color: #eda199; }
.gate { max-width: 470px; margin: 90px auto; text-align: center; }
.gate h2 { font-family: var(--font-display); font-size: 21px; margin-bottom: 8px; }
.gate p { color: var(--ink-2); font-size: 13.5px; margin-bottom: 16px; }
.lead { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.lead:last-child { border-bottom: none; }
.lead .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(14px);
  background: var(--green); color: #f2ecdc; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lift);
  opacity: 0; transition: opacity .18s, transform .18s; z-index: 95; pointer-events: none;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media print { .side, .topbar, .tbl-toggle { display: none; } .view { padding: 0; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ═══════════════════════════════════════════════════════════════════
   EDITING LAYER — modal, forms, row actions
   Same ledger language: paper/card surfaces, hairline rules, amber focus.
   ═══════════════════════════════════════════════════════════════════ */

body.modal-open{overflow:hidden}

.modal-overlay{
  position:fixed;inset:0;z-index:100;
  display:grid;place-items:center;padding:24px;
  background:color-mix(in srgb, var(--green) 42%, transparent);
  backdrop-filter:blur(3px);
  opacity:0;transition:opacity .16s ease;
}
.modal-overlay.on{opacity:1}
.modal-panel{
  width:min(560px,100%);max-height:min(86vh,860px);
  display:flex;flex-direction:column;
  background:var(--card);border:1px solid var(--line);border-radius:var(--radius);
  box-shadow:var(--shadow-lift);
  transform:translateY(8px) scale(.99);transition:transform .18s cubic-bezier(.2,.8,.3,1);
}
.modal-panel.wide{width:min(880px,100%)}
.modal-overlay.on .modal-panel{transform:none}

.modal-head{
  display:flex;align-items:flex-start;gap:14px;
  padding:17px 20px 13px;border-bottom:1px solid var(--line);
}
.modal-head h2{font-family:var(--font-display);font-size:17px;font-weight:600;letter-spacing:-.005em}
.modal-sub{font-size:12.5px;color:var(--ink-3);margin-top:2px}
.modal-x{
  margin-left:auto;flex:none;width:32px;height:32px;border-radius:9px;
  color:var(--ink-3);font-size:14px;line-height:1;
  border:1px solid transparent;transition:background .14s,color .14s;
}
.modal-x:hover{background:var(--card-2);color:var(--ink);border-color:var(--line)}

.modal-body{padding:18px 20px;overflow-y:auto;flex:1;min-height:0}
.modal-foot{
  display:flex;justify-content:flex-end;gap:9px;
  padding:14px 20px;border-top:1px solid var(--line);
  background:var(--card-2);border-radius:0 0 var(--radius) var(--radius);
}
.confirm-body{font-size:14px;line-height:1.55;color:var(--ink-2)}

/* ─── forms: label above, hint below, error below that ─── */
.form-section{
  font-size:10.5px;letter-spacing:.11em;text-transform:uppercase;color:var(--ink-3);
  font-weight:600;padding:16px 0 9px;
  border-top:1px solid var(--line-2);margin-top:6px;
}
.form-grid:first-child+*,.form>.form-grid:first-child{margin-top:0}
.form>.form-section:first-child{border-top:none;padding-top:0;margin-top:0}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:13px 14px}
.fld{display:flex;flex-direction:column;gap:5px;min-width:0}
.fld.span-2,.fld.span-full{grid-column:1 / -1}
.fld-lbl{font-size:12px;font-weight:600;color:var(--ink-2);letter-spacing:.005em}
.fld-hint{font-size:11.5px;color:var(--ink-3);line-height:1.35}
.fld-err{font-size:11.5px;color:var(--red);min-height:0;line-height:1.35}
.fld-err:not(:empty){margin-top:1px}

.inp{
  width:100%;padding:9px 11px;font-size:14px;
  background:var(--card);color:var(--ink);
  border:1px solid var(--line);border-radius:var(--radius-sm);
  transition:border-color .14s, box-shadow .14s;
}
.inp:hover{border-color:var(--axis)}
.inp:focus{
  outline:none;border-color:var(--green-2);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--green-2) 16%, transparent);
}
.inp[aria-invalid="true"]{border-color:var(--red)}
.inp[aria-invalid="true"]:focus{box-shadow:0 0 0 3px color-mix(in srgb, var(--red) 18%, transparent)}
select.inp{cursor:pointer}
textarea.inp{resize:vertical;min-height:66px;line-height:1.5}

.fld-chk{flex-direction:row;align-items:center;gap:9px;padding-top:4px}
.fld-chk .fld-lbl{font-weight:500;cursor:pointer;margin:0}
.chk{width:18px;height:18px;flex:none;accent-color:var(--green-2);cursor:pointer}

/* ─── row actions in tables ─── */
.row-actions{display:flex;gap:6px;justify-content:flex-end;white-space:nowrap}
table.t td .btn.sm{padding:3px 9px;font-size:11.5px}
.card-head .head-actions{display:flex;gap:8px;align-items:center;margin-left:auto}

@media(max-width:640px){
  .modal-overlay{padding:0;align-items:flex-end}
  .modal-panel,.modal-panel.wide{width:100%;max-height:92vh;border-radius:var(--radius) var(--radius) 0 0}
  .form-grid{grid-template-columns:1fr}
  .fld.span-2{grid-column:auto}
}
@media(prefers-reduced-motion:reduce){
  .modal-overlay,.modal-panel{transition:none}
}

/* ─── attendance cells are now real buttons (keyboard-reachable, click to edit) ─── */
.cell-btn{
  display:block;width:26px;height:26px;padding:0;border:none;background:none;
  border-radius:6px;cursor:pointer;transition:transform .1s, box-shadow .12s;
}
.cell-btn:hover:not(:disabled){transform:scale(1.16);box-shadow:0 2px 8px -2px rgba(22,40,31,.35);z-index:2;position:relative}
.cell-btn:disabled{cursor:default}
.cell-btn:focus-visible{outline:2px solid var(--amber);outline-offset:1px;z-index:3;position:relative}
.cell-btn.lt i{box-shadow:inset -6px 6px 0 -3px var(--amber)}

/* ─── deliberate empty state for charts (was: an empty plot frame with invented ticks) ─── */
.plot-empty{
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;
  min-height:150px;padding:26px 16px;text-align:center;
  border:1px dashed var(--line);border-radius:var(--radius-sm);
  background:color-mix(in srgb, var(--card-2) 70%, transparent);
}
.plot-empty-mark{font-size:20px;color:var(--axis);line-height:1}
.plot-empty-text{font-size:13px;color:var(--ink-3);max-width:34ch;line-height:1.45}

/* hover highlight is driven from JS now (.hot); the old sibling selector could never match */
.seg.hot{filter:brightness(1.12) saturate(1.05)}

/* ═══════════════════════════════════════════════════════════════════════════
   POLISH PASS — every item here is a measured defect, with the number that
   motivated it. Appended so the originals stay readable and this is revertible.
   ═══════════════════════════════════════════════════════════════════════════ */

/* §21 native controls kept light-mode chrome on the dark topbar (month picker, selects) */
:root, :root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { color-scheme: dark; } }

/* §7 "HRintel" and "Owner console" were both inline inside one span, so the sub-label flowed
   after the name and broke as "HRintel OWNER / CONSOLE" on every single page. */
.brand-name, .brand-sub { display: block; }

/* §16 .view was max-width:1560px but never centred, so at 1920 the topbar and the whole
   filter row overhung the cards by 108px. Cap and centre BOTH so their right edges track. */
.view { margin-inline: auto; }
.topbar { padding: 0; }
.topbar-inner {
  display: flex; align-items: center; gap: 16px;
  width: 100%; max-width: 1560px; margin-inline: auto;
  padding: 0 24px; height: var(--topbar-h);
}

/* §13 spacing on one 4px scale. Card padding was asymmetric 16/18, and four different
   "block gap" values (11/12/12/13) were in play. */
.card { padding: 16px; }
.card .sub { margin-bottom: 12px; }
.legend { margin: 12px 0 0; }
.tv { margin-top: 12px; }
.view { padding: 24px 24px 60px; }

/* §2 + §3 ragged content bottoms: cards were equal height but content wasn't distributed, so
   paired cards showed 0px vs 76px of trailing space. Let content own the box. */
.card { display: flex; flex-direction: column; }
.card > .tbl-scroll, .card > .chart-wrap, .card > .mgrid-scroll { flex: 1 1 auto; min-height: 0; }
.tile { justify-content: space-between; }
/* §3 the hero was the only card with no border, so its content box sat 1px higher than its
   row-mates and the first-line baselines in that row disagreed. */
.hero { border: 1px solid transparent; }

/* §3 one label role, not four (10.5px uppercase / 11.5px sentence / 11px uppercase / 10px) */
.hero .lbl, .tile .lbl, .lead-lbl {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
}
.tile .lbl { color: var(--ink-3); }
.hero .note, .tile .foot, .lead-sub { font-size: 11.5px; }

/* §12 type scale: 15 sizes, 6 on half-pixels (which blur at DPR 1 on an external monitor).
   Collapse to whole-pixel steps. */
.card h2 { font-size: 15px; }
.btn { font-size: 13px; }
.btn.sm, .tbl-toggle, .filters label, .tip .t-head { font-size: 11px; }
.crumb, .tip .t-row, table.mgrid tbody th { font-size: 12px; }
.side-nav a { font-size: 13px; font-weight: 600; }   /* weight was 500→600 on .on, which also
                                                        re-bolded the glyph and shifted metrics */
.side-nav a.on { font-weight: 600; }
.brand-sub { font-size: 10px; }
.hero-row .v { font-size: 15px; }
.gate p { font-size: 13px; }

/* §14 radii: five untokenised one-offs. Add an xs token and stop the focus ring squaring off
   rounded controls. */
:root { --radius-xs: 4px; }
.brand-mark { border-radius: var(--radius-sm); }
.legend i, .legend i.line, .tip .t-row i { border-radius: 2px; }
.cell i { border-radius: var(--radius-xs); }
:focus-visible { border-radius: inherit; }

/* §8 the sticky table header never stuck: overflow-x:auto forces overflow-y to auto, making
   .tbl-scroll the containing block, and it had no max-height so it never scrolled. */
.tbl-scroll { overflow-x: auto; overflow-y: visible; scrollbar-gutter: stable; }
table.t th { top: var(--topbar-h); }

/* §15 Cashbook/Approvals tables overflowed their c6 card by up to 136px, silently, because
   every cell was nowrap and macOS uses overlay scrollbars. Let prose wrap. */
table.t td:not(.r), table.t th:not(.r) { white-space: normal; }
table.t td.r, table.t th.r, table.t td:first-child { white-space: nowrap; }
table.t td { min-width: 0; }

/* §19 the payroll Total row was styled exactly like a data row */
table.t tbody tr.total td {
  border-top: 1px solid var(--line); background: var(--card-2);
  font-weight: 600; color: var(--ink);
}
table.t tbody tr.total:hover td { background: var(--card-2); }

/* §10 structural hairlines and row hover were 1.05–1.24:1 — effectively invisible, and dense
   tables had no row-tracking aid at all. */
table.t tbody tr:nth-child(even):not(.total) td { background: color-mix(in srgb, var(--ink) 2.5%, transparent); }
table.t tbody tr:hover:not(.total) td { background: color-mix(in srgb, var(--ink) 6%, transparent); }
:root { --grid: #e2d8bf; --line-2: #e3d9c2; }
:root[data-theme="dark"] { --grid: #2e3832; --line-2: #2b332e; --card-2: #1f2521; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) { --grid: #2e3832; --line-2: #2b332e; --card-2: #1f2521; }
}
/* §10 light-mode muted ink measured 3.51:1 — under AA for the small text it is used on */
:root { --ink-3: #6c7a70; }

/* §9 in dark mode the hero gradient measured 1.07:1 against the page — the lower 60% of the
   card dissolved into the background, and .hero had no border to fall back on. */
:root[data-theme="dark"] { --green: #132b22; --green-2: #1c5643; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) { --green: #132b22; --green-2: #1c5643; }
}
:root[data-theme="dark"] .hero { border-color: var(--line); }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .hero { border-color: var(--line); }
}

/* §22 the sparkline was bottom-aligned to the value box, so it hung 6.87px below the value's
   baseline and its centre sat 1.37px off. */
.tile .row { align-items: center; }

/* §17 the attendance grid is a fixed 938px inside a full-width card, stranding up to 532px */
table.mgrid { width: 100%; }
table.mgrid thead th:not(:first-child) { width: auto; min-width: 26px; }
.cell, .cell-btn { width: auto; min-width: 26px; }
.cell-btn { margin-inline: auto; }

/* §20 Sundays were marked only in the header row, 26px above the first cell */
table.mgrid td.cell.sun { background: color-mix(in srgb, var(--red) 5%, transparent); }
.lead-box{margin-bottom:12px}
.lead-lbl{color:var(--ink-3);margin-bottom:4px}
.lead-sub{color:var(--ink-3)}

/* ─── correction to the §8 sticky-header fix ───
   Making .tbl-scroll overflow-y:visible promoted the page to the sticky containing block, so
   `th { top: var(--topbar-h) }` offset the header 61px DOWN inside short, non-scrolling cards
   and rendered it below the first row. Instead make the wrapper a real scroll container with a
   generous max-height: long tables now genuinely scroll under a pinned header, and short ones
   never reach the limit so nothing moves. */
.tbl-scroll { overflow: auto; max-height: 72vh; overscroll-behavior: contain; }
table.t th { top: 0; }

/* ─── the sidebar gradient stopped at 100dvh, leaving a hard edge on any page taller than the
   viewport. Paint the column on the shell so it reads full-height at any content length. ─── */
.shell {
  background: linear-gradient(168deg, var(--green-2) 0%, var(--green) 62%) left top / var(--sidebar-w) 100% no-repeat;
}
.side { background: none; }
@media (max-width: 780px) { .shell { background: none; } .side { background: linear-gradient(168deg, var(--green-2), var(--green) 62%); } }

/* charts now draw at the container's real pixel width (see responsiveChart) — the SVG must
   therefore NOT be rescaled, or we reintroduce the 8.5–14.3px type problem */
.chart-host{width:100%}
.chart-host>svg{display:block;width:100%;height:auto}
