/* HR CoPilot design system — self-contained, low-bandwidth, WCAG-conscious. */
:root {
  --ink: #17211f;
  --ink-soft: #4b5a56;
  --ink-faint: #74827e;
  --paper: #f5f7f6;
  --card: #ffffff;
  --line: #dde5e2;
  --brand: #0f5c4d;
  --brand-strong: #0a4237;
  --brand-soft: #e3efec;
  --accent: #d99a2b;
  --accent-soft: #faf1de;
  --danger: #b23a3a;
  --danger-soft: #f9e9e9;
  --ok: #2e7d4f;
  --ok-soft: #e6f2ea;
  --info: #2f5fa8;
  --info-soft: #e8eef8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(23, 33, 31, 0.06), 0 4px 14px rgba(23, 33, 31, 0.05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; font-family: var(--font); background: var(--paper); color: var(--ink);
  line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
small, .muted { color: var(--ink-faint); }

/* Layout ------------------------------------------------------------------ */
.topbar {
  background: var(--brand-strong); color: #fff; display: flex; align-items: center;
  gap: 1rem; padding: 0 1.2rem; height: 54px; position: sticky; top: 0; z-index: 40;
}
.topbar .logo { font-weight: 700; font-size: 1.05rem; color: #fff; letter-spacing: .2px;
  display: inline-flex; align-items: center; gap: .5rem; }
.topbar .logo:hover { text-decoration: none; }
.topbar .logo .logo-mark { height: 32px; width: auto; display: block; }
.topbar .logo span { color: #f0c36c; }
.topbar nav { display: flex; gap: .15rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a {
  color: #d7e5e1; padding: .42rem .68rem; border-radius: 7px; font-size: .88rem;
  white-space: nowrap;
}
.topbar nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; color: #fff; }
.topbar nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.topbar .user-chip { color: #d7e5e1; font-size: .85rem; display: flex; align-items: center; gap: .6rem; }
.topbar .user-chip a { color: #f0c36c; }
.badge-dot {
  background: var(--accent); color: #2a1e05; border-radius: 999px; font-size: .72rem;
  font-weight: 700; padding: .05rem .45rem;
}
.page { max-width: 1180px; margin: 0 auto; padding: 1.3rem 1.2rem 3rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-head .crumbs { font-size: .8rem; color: var(--ink-faint); margin-bottom: .25rem; }

/* Cards & grids ----------------------------------------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem;
}
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.grid { display: grid; gap: 1.1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .page { padding: 1rem .8rem 2.5rem; }
}

/* KPI tiles --------------------------------------------------------------- */
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; box-shadow: var(--shadow); }
.kpi .kpi-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink-faint); font-weight: 600; }
.kpi .kpi-value { font-size: 1.7rem; font-weight: 700; margin-top: .1rem; }
.kpi .kpi-note { font-size: .8rem; color: var(--ink-soft); }
.kpi.alert { border-left: 4px solid var(--danger); }
.kpi.good { border-left: 4px solid var(--ok); }
.kpi.warn { border-left: 4px solid var(--accent); }

/* Tables ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink-faint); padding: .5rem .6rem; border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:hover td { background: #fafcfb; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Badges ------------------------------------------------------------------ */
.badge {
  display: inline-block; font-size: .74rem; font-weight: 600; border-radius: 999px;
  padding: .12rem .6rem; white-space: nowrap; background: var(--brand-soft); color: var(--brand-strong);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--accent-soft); color: #8a5d10; }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.neutral { background: #eef1f0; color: var(--ink-soft); }

/* Notification list — circular category icon (colour + glyph carry the meaning) */
.notif-row { display: flex; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line);
  align-items: flex-start; }
.notif-row:last-child { border-bottom: none; }
.notif-row.read { opacity: .55; }
.notif-icon { width: 34px; height: 34px; border-radius: 50%; flex: none; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.05rem; line-height: 1; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.notif-icon.info { background: var(--info); }
.notif-icon.alert { background: var(--danger); }
.notif-icon.approval { background: #b57d17; }
.notif-icon.task { background: var(--brand); }
.notif-icon.legal { background: #6d4bb0; }
.notif-cat { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-faint); font-weight: 600; margin-bottom: .05rem; }

/* Forms ------------------------------------------------------------------- */
form.stack label { display: block; font-size: .82rem; font-weight: 600; margin: .8rem 0 .25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], input[type="time"], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--font); font-size: .92rem; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand);
}
textarea { min-height: 110px; resize: vertical; }
.btn {
  display: inline-block; background: var(--brand); color: #fff; border: none;
  padding: .55rem 1.05rem; border-radius: 8px; font-size: .9rem; font-weight: 600;
  cursor: pointer; font-family: var(--font);
}
.btn:hover { background: var(--brand-strong); text-decoration: none; color: #fff; }
.btn.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line); }
.btn.small { padding: .3rem .7rem; font-size: .8rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

/* Messages / alerts ------------------------------------------------------- */
.messages { margin-bottom: 1rem; }
.flash { border-radius: 8px; padding: .65rem .9rem; margin-bottom: .5rem; font-size: .9rem;
  border: 1px solid transparent; }
.flash.success { background: var(--ok-soft); color: var(--ok); border-color: #c4e2cf; }
.flash.error { background: var(--danger-soft); color: var(--danger); border-color: #ecc9c9; }
.flash.warning { background: var(--accent-soft); color: #8a5d10; border-color: #eed9ac; }
.flash.info { background: var(--info-soft); color: var(--info); border-color: #c8d7ee; }
.callout { border-left: 4px solid var(--info); background: var(--info-soft); border-radius: 8px;
  padding: .7rem .9rem; margin: .8rem 0; font-size: .88rem; }
.callout.legal { border-color: var(--brand); background: var(--brand-soft); }
.callout.danger { border-color: var(--danger); background: var(--danger-soft); }
.callout .src { display: block; margin-top: .3rem; font-size: .78rem; color: var(--ink-faint); }

/* Charts ------------------------------------------------------------------ */
.chart { width: 100%; height: auto; }
.chart-label { font-size: 12px; fill: var(--ink-soft); font-family: var(--font); }
.chart-value { font-size: 12px; fill: var(--ink); font-weight: 600; font-family: var(--font); }
.chart-hole { fill: var(--card); }
.chart-bar-link { cursor: pointer; }
.chart-bar-link:hover rect, .chart-bar-link:focus rect { opacity: 1; }
.chart-bar-link:hover path, .chart-bar-link:focus path,
.chart-bar-link:hover circle, .chart-bar-link:focus circle { opacity: 1; }
.chart-bar-link:hover .chart-label, .chart-bar-link:hover .chart-value { fill: var(--brand); font-weight: 700; }
.legend { list-style: none; margin: .6rem 0 0; padding: 0; font-size: .84rem; }
.legend li { display: flex; align-items: center; gap: .5rem; padding: .12rem 0; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }

/* Misc -------------------------------------------------------------------- */
.progress { background: #e8edeb; border-radius: 999px; height: 10px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--line); }
.timeline li { margin: 0 0 .8rem; padding-left: .9rem; position: relative; font-size: .9rem; }
.timeline li::before {
  content: ""; width: 9px; height: 9px; background: var(--brand); border-radius: 50%;
  position: absolute; left: -1.45rem; top: .42rem;
}
.timeline .date { font-size: .78rem; color: var(--ink-faint); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-strong); font-weight: 700; display: inline-flex; align-items: center;
  justify-content: center; font-size: .85rem; flex: none;
}
.person-row { display: flex; align-items: center; gap: .7rem; }
.filter-bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filter-bar input, .filter-bar select { width: auto; }
.empty { text-align: center; color: var(--ink-faint); padding: 2rem 1rem; font-size: .92rem; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: 1rem;
  font-size: .88rem; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: linear-gradient(160deg, #0a4237 0%, #0f5c4d 55%, #17715f 100%); }
.login-card { width: min(430px, 100%); background: #fff; border-radius: 14px; padding: 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.login-card { text-align: center; }
.login-card form.stack { text-align: left; }
.login-mark { height: 84px; width: auto; margin: 0 auto .4rem; display: block; }
.login-card .logo { font-size: 1.5rem; font-weight: 800; color: var(--brand-strong); }
.login-card .logo span { color: var(--accent); }
.spark { vertical-align: middle; }

/* Password unmask toggle ---------------------------------------------------- */
.pw-field { position: relative; display: block; }
.pw-field input { width: 100%; padding-right: 2.6rem; }
.pw-toggle { position: absolute; top: 50%; right: .5rem; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; font-size: 1.05rem; line-height: 1;
  padding: .25rem; border-radius: 6px; opacity: .75; }
.pw-toggle:hover { opacity: 1; }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Payslip calculation steps -------------------------------------------------- */
.calc-steps { list-style: none; margin: 0; padding: 0; counter-reset: calcstep; }
.calc-step { counter-increment: calcstep; position: relative; padding: .7rem .8rem .7rem 2.6rem;
  border: 1px solid var(--line); border-radius: 10px; margin-bottom: .5rem; background: #fff; }
.calc-step::before { content: counter(calcstep); position: absolute; left: .75rem; top: .8rem;
  width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-strong); font-size: .74rem; font-weight: 700;
  display: grid; place-items: center; }
.calc-step.calc-warn { border-color: #d9534f; background: #fff7f7; }
.calc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.calc-label { font-weight: 600; }
.calc-amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.calc-detail { color: var(--muted); font-size: .84rem; margin-top: .15rem; }
.calc-source { color: var(--muted); font-size: .74rem; margin-top: .35rem; font-style: italic; }

/* Pay movement against the previous run ------------------------------------- */
tr.pay-up > td { background: #fdf8e7; }             /* increase — worth a look */
tr.pay-up > td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.delta-up { color: #8a6d1a; font-weight: 700; text-decoration: none; }
.delta-down { color: #7a3b3b; font-weight: 600; text-decoration: none; }
.delta-up:hover, .delta-down:hover { text-decoration: underline; }

/* Pinned column-totals row (sits under the headings, never sorted) ----------- */
tr.totals-row > td { background: var(--brand-soft); border-bottom: 2px solid var(--line); }
tr.totals-row { position: sticky; top: 0; }

/* Sortable table headings --------------------------------------------------- */
th.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; position: relative; }
th.sortable-th:hover { color: var(--brand-strong); }
th.sortable-th::after { content: "\2195"; opacity: .3; margin-left: .35em; font-size: .8em; }
th.sortable-th[aria-sort="ascending"]::after { content: "\2191"; opacity: .9; }
th.sortable-th[aria-sort="descending"]::after { content: "\2193"; opacity: .9; }
th.sortable-th:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Clock terminal method chips ----------------------------------------------- */
.method-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-top: .3rem; }
.method-chip { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--line);
  border-radius: 8px; padding: .55rem .7rem; cursor: pointer; font-size: .9rem; }
.method-chip:has(input:checked) { border-color: var(--accent); background: var(--brand-soft); font-weight: 600; }
.method-chip input { accent-color: var(--accent); }

/* Team leave calendar (Gantt / who's-away timeline) -------------------------- */
.gantt-wrap { overflow-x: auto; }
.gantt { min-width: 720px; }
.gantt-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.gantt-row:last-child { border-bottom: none; }
.gantt-head { border-bottom: 2px solid var(--line); }
.gantt-name { flex: 0 0 190px; display: flex; align-items: center; gap: .55rem;
  padding: .5rem .6rem; font-size: .85rem; }
.gantt-head .gantt-name { font-size: .74rem; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink-faint); font-weight: 600; }
.gantt-name-text { line-height: 1.15; }
.gantt-track { position: relative; flex: 1; min-height: 26px; }
.gantt-head .gantt-track { min-height: 30px; }
.gantt-week-label { position: absolute; top: 6px; font-size: .74rem; color: var(--ink-soft);
  padding-left: 4px; border-left: 1px solid var(--line); box-sizing: border-box; }
.gantt-band { position: absolute; top: 0; bottom: 0; }
.gantt-band.weekend { background: #eef1f0; }
.gantt-band.holiday { background: var(--accent-soft); }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger);
  z-index: 3; }
.gantt-bar { position: absolute; top: 3px; height: 20px; border-radius: 5px; color: #fff;
  font-size: .74rem; font-weight: 600; line-height: 20px; padding: 0 6px; overflow: hidden;
  white-space: nowrap; z-index: 2; box-shadow: 0 1px 2px rgba(0,0,0,.12);
  display: flex; align-items: center; gap: 2px; }
.gantt-bar-label { overflow: hidden; text-overflow: ellipsis; }
.gantt-legend { display: flex; flex-wrap: wrap; gap: 1.1rem; margin-top: .9rem;
  font-size: .8rem; color: var(--ink-soft); }
.gantt-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.gantt-swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.gantt-swatch.weekend { background: #eef1f0; border: 1px solid var(--line); }
.gantt-swatch.holiday { background: var(--accent-soft); border: 1px solid #eed9ac; }
.gantt-today-key { width: 2px; height: 14px; background: var(--danger); display: inline-block; }

/* Drill-down trail bar (JS-driven "path back") ------------------------------ */
.drill-trail { position: sticky; top: 54px; z-index: 30; background: #eef4f2;
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  flex-wrap: wrap; gap: .35rem; padding: .4rem 1.2rem; font-size: .82rem;
  color: var(--ink-soft); }
.drill-trail .dt-tag { font-size: .68rem; text-transform: uppercase; letter-spacing: .5px;
  font-weight: 700; color: var(--ink-faint); margin-right: .2rem; }
.drill-trail a { color: var(--brand); text-decoration: none; }
.drill-trail a:hover { text-decoration: underline; }
.drill-trail .dt-up { font-weight: 600; background: var(--brand-soft); border-radius: 6px;
  padding: .08rem .5rem; }
.drill-trail .dt-sep { color: var(--ink-faint); }
.drill-trail .dt-cur { font-weight: 600; color: var(--ink); }
@media (max-width: 620px) { .drill-trail { padding: .4rem .8rem; } }

/* Drill-down breadcrumb + linkable aggregates ------------------------------- */
.drill-link { cursor: pointer; }
a.kpi, a.kpi:hover { text-decoration: none; color: inherit; display: block; }
a.kpi:hover { box-shadow: 0 2px 6px rgba(23,33,31,.12); transform: translateY(-1px);
  transition: all .12s; }
.drill-crumbs { font-size: .82rem; color: var(--ink-faint); margin-bottom: .4rem; }
.drill-crumbs a { color: var(--brand); }
.chip-filter { display: inline-flex; align-items: center; gap: .35rem; background: var(--brand-soft);
  color: var(--brand-strong); border-radius: 999px; padding: .12rem .6rem; font-size: .78rem;
  font-weight: 600; }
.chip-filter a { color: var(--brand-strong); text-decoration: none; }
table.data td a.rowlink { font-weight: 600; }
.trace { background: #101817; color: #cfe3dd; border-radius: 8px; padding: .9rem; font-size: .78rem;
  overflow-x: auto; white-space: pre-wrap; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.pill-row { display: flex; flex-wrap: wrap; gap: .4rem; }
footer.site { text-align: center; color: var(--ink-faint); font-size: .78rem; padding: 1.5rem 0 2rem; }
@media print {
  .topbar, .actions, .filter-bar, footer.site, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #bbb; }
  body { background: #fff; }
}
