/* HRM — ledger aesthetic
   Palette derived from paper-and-ink accounting tradition, not SaaS defaults. */

:root {
  --paper:     #EEF2F8;
  --surface:   #FFFFFF;
  --ink:       #374151;
  --ink-soft:  #4B5563;
  --muted:     #6B7280;
  --rule:      #E5E7EB;
  --rule-soft: #F3F4F6;
  --accent:    #2563EB;
  --accent-tint:#EFF6FF;
  --accent-ink:#1D4ED8;
  --ok:        #3B6D3E;
  --ok-tint:   #E4EEE0;
  --warn:      #B8752D;
  --warn-tint: #F3E8D4;
  --bad:       #A63838;
  --bad-tint:  #F1DBDB;
  --info:      #2D5F7A;
  --info-tint: #DDE7EE;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --nav-width: 232px;
  --radius: 4px;

  /* v12_L: deep navy sidebar (from the HUBAAL brand blue) over light content */
  --nav-bg:        #1B2559;
  --nav-fg:        #A9B4D4;
  --nav-strong:    #FFFFFF;
  --nav-muted:     #7580AC;
  --nav-rule:      rgba(255,255,255,.10);
  --nav-hover-bg:  rgba(255,255,255,.06);
  --nav-active-bg: rgba(97,141,255,.18);
  --nav-active-fg: #FFFFFF;
  --primary-bg:    #2563EB;
  --primary-fg:    #FFFFFF;
  --primary-hover: #1D4ED8;
  --focus-bg:      #FFFFFF;
  --card-head-bg:  #F8FAFC;
}

/* ----- DARK THEME (v12.1) ----- */
[data-theme="dark"] {
  --paper:     #0F172A;
  --surface:   #1E293B;
  --ink:       #E2E8F0;
  --ink-soft:  #CBD5E1;
  --muted:     #94A3B8;
  --rule:      #334155;
  --rule-soft: #263349;
  --accent:    #60A5FA;
  --accent-tint:#1E3050;
  --accent-ink:#93C5FD;
  --ok:        #7FB584;
  --ok-tint:   #1F2E20;
  --warn:      #D9A05B;
  --warn-tint: #33270F;
  --bad:       #D97C7C;
  --bad-tint:  #331B1B;
  --info:      #7FAEC9;
  --info-tint: #16242E;

  --nav-bg:        #0F172A;
  --nav-fg:        #94A3B8;
  --nav-strong:    #E2E8F0;
  --nav-muted:     #64748B;
  --nav-rule:      #1E293B;
  --nav-hover-bg:  rgba(255,255,255,.04);
  --nav-active-bg: rgba(96,165,250,.12);
  --nav-active-fg: #93C5FD;
  --primary-bg:    #3B82F6;
  --primary-fg:    #FFFFFF;
  --primary-hover: #2563EB;
  --focus-bg:      #263349;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

button, input, select, textarea { font: inherit; color: inherit; }

/* v12_P: data tables keep every row on a single line; wide tables scroll
   horizontally inside their card instead of wrapping cell content */
table.data th, table.data td { white-space: nowrap; }

/* Numerals — tabular figures everywhere they matter */
.num, td.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ----- LOGIN ----- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 0%, rgba(37,99,235,.05), transparent 40%),
    radial-gradient(circle at 80% 100%, rgba(15,23,42,.04), transparent 40%),
    var(--paper);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 40px 36px 32px;
}
.login-card { text-align: center; }
.login-card .form-grid, .login-card .field, .login-card label { text-align: left; }
.login-brand {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 34px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.login-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 24px;
}
.login-card h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 26px;
  margin: 0 0 22px;
}

/* ----- SHELL ----- */
.shell { display: grid; grid-template-columns: var(--nav-width) 1fr; min-height: 100vh; }
.nav {
  background: var(--nav-bg);
  color: var(--nav-fg);
  padding: 24px 0 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--nav-rule);
}
.nav-brand {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
  padding: 0 24px 4px;
  color: var(--nav-strong);
}
.nav-branch {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--nav-muted);
  padding: 0 24px 24px;
}
/* v12: each sidebar section sits in its own visually separated group */
.nav-group {
  padding: 10px 0 14px;
  border-top: 1px solid var(--nav-rule);
}
.nav-group:first-of-type { border-top: none; padding-top: 0; }
.nav-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nav-muted);
  padding: 8px 24px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.nav-section-label::after {
  content: '▾';
  font-size: 9px;
  color: var(--nav-muted);
  transition: transform .15s ease;
}
.nav-group.collapsed .nav-section-label::after { transform: rotate(-90deg); }
.nav a {
  display: block;
  padding: 8px 24px;
  color: var(--nav-fg);
  text-decoration: none;
  border-left: 2px solid transparent;
  font-size: 14px;
}
.nav a:hover { color: var(--nav-strong); background: var(--nav-hover-bg); text-decoration: none; }
.nav a.active {
  color: var(--nav-active-fg, var(--accent));
  font-weight: 500;
  border-left-color: #618DFF;
  background: var(--nav-active-bg);
}
.nav-foot {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 24px;
  border-top: 1px solid var(--nav-rule);
  background: var(--nav-bg);
}
.nav-user { font-size: 13px; color: var(--nav-strong); }
.nav-role { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--nav-muted); margin-top: 2px; }
.nav-logout {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--nav-muted);
  cursor: pointer;
}
.nav-logout:hover { color: var(--nav-strong); }

/* ----- MAIN ----- */
.main { padding: 14px 32px 60px; max-width: none; }
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.page-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 32px;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
}
.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.page-actions { display: flex; gap: 8px; }

/* ----- CARDS / STATS ----- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 28px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.stat-value {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ----- TABLES ----- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  overflow-x: auto;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.05);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--card-head-bg, var(--rule-soft));
}
.card-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
}
.card-body { padding: 20px; }

table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
  padding: 12px 20px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}
table.data th {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--rule-soft);
  border-bottom: 1px solid var(--rule);
}
table.data tbody tr:hover td { background: rgba(37,99,235,.04); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
table.data a { color: var(--ink); font-weight: 500; }
table.data a:hover { color: var(--accent); text-decoration: underline; }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ----- BADGES ----- */
.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 3px;
  border: 1px solid transparent;
  line-height: 1.4;
}
.badge.b-active,    .badge.b-present,  .badge.b-approved, .badge.b-paid { color: var(--ok);   background: var(--ok-tint);   border-color: rgba(59,109,62,.2); }
.badge.b-inactive,  .badge.b-draft                                     { color: var(--muted); background: var(--rule-soft); border-color: var(--rule); }
.badge.b-suspended, .badge.b-late, .badge.b-half_day, .badge.b-review, .badge.b-processing { color: var(--warn); background: var(--warn-tint); border-color: rgba(184,117,45,.2); }
.badge.b-terminated,.badge.b-absent                                    { color: var(--bad);   background: var(--bad-tint);  border-color: rgba(166,56,56,.2); }
.badge.b-leave,     .badge.b-holiday                                   { color: var(--info);  background: var(--info-tint); border-color: rgba(45,95,122,.2); }
/* v12: loan workflow + type badges */
.badge.b-pending                                                       { color: var(--warn);  background: var(--warn-tint); border-color: rgba(184,117,45,.2); }
.badge.b-rejected,  .badge.b-cancelled                                 { color: var(--bad);   background: var(--bad-tint);  border-color: rgba(166,56,56,.2); }
.badge.b-completed                                                     { color: var(--ok);    background: var(--ok-tint);   border-color: rgba(59,109,62,.2); }
.badge.b-loan                                                          { color: var(--info);  background: var(--info-tint); border-color: rgba(45,95,122,.2); }
.badge.b-advance                                                       { color: var(--warn);  background: var(--warn-tint); border-color: rgba(184,117,45,.2); }
.badge.b-online                                                        { color: var(--ok);    background: var(--ok-tint);   border-color: rgba(59,109,62,.2); }
.badge.b-offline                                                       { color: var(--muted); background: var(--rule-soft); border-color: var(--rule); }

/* ----- TOPBAR (v12.1: profile moved out of the sidebar) ----- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 6px 0 10px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.theme-toggle {
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  width: 34px; height: 34px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: grid; place-items: center;
}
.theme-toggle:hover { border-color: var(--ink-soft); }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  position: relative;
}
.user-chip:hover { border-color: var(--ink-soft); }
.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #FFF;
  font-size: 12px;
  font-weight: 600;
  display: grid; place-items: center;
  letter-spacing: 0.02em;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta .user-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.user-meta .user-role { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.user-chip .chev { font-size: 9px; color: var(--muted); }
.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 40;
  overflow: hidden;
}
.user-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}
.user-menu button:hover { background: var(--rule-soft); }
/* Brand logo sits on a light chip so it reads on the dark sidebar */
.nav-brand img { background: #FFFFFF; border: 1px solid var(--nav-rule); border-radius: 8px; padding: 8px 12px; }

/* ----- FORMS ----- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.form-grid.single { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: 1 / -1; }
.field label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input, .field select, .field textarea {
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
  transition: border-color .12s, background .12s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--focus-bg);
}
.field textarea { min-height: 90px; resize: vertical; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--rule); }

/* ----- BUTTONS ----- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--ink-soft); text-decoration: none; }
.btn.primary {
  background: var(--primary-bg);
  color: var(--primary-fg);
  border-color: var(--primary-bg);
}
.btn.primary:hover { background: var(--primary-hover); }
.btn.accent {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}
.btn.accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: var(--surface); }
.btn.danger:hover { background: var(--bad-tint); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----- FILTER BAR ----- */
.filter-bar {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--card-head-bg, var(--rule-soft));
  align-items: end;
  flex-wrap: wrap;
}
.filter-bar .field { flex: 1; min-width: 140px; gap: 4px; }
.filter-bar .field input, .filter-bar .field select { padding: 6px 10px; font-size: 13px; }

/* ----- ATTENDANCE STRIP (signature element) -----
   A month rendered as small colored blocks: real information in visual form. */
.strip {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 4px;
  background: var(--rule-soft);
  border-radius: 3px;
}
.strip .cell {
  width: 8px; height: 20px;
  border-radius: 1px;
  background: var(--rule);
  cursor: help;
}
.strip .cell.present { background: var(--ok); }
.strip .cell.late    { background: var(--warn); }
.strip .cell.absent  { background: var(--bad); }
.strip .cell.leave   { background: var(--info); }
.strip .cell.holiday { background: transparent; border: 1px solid var(--rule); }
.strip .cell.half_day{ background: linear-gradient(180deg, var(--ok) 0 50%, var(--rule) 50% 100%); }

.strip-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
}
.strip-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 1px; margin-right: 4px; vertical-align: middle; }

/* ----- DETAIL LAYOUT ----- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--muted); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; padding-top: 3px; }
.kv dd { margin: 0; }

/* ----- TOAST ----- */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1F2937;
  color: #F9FAFB;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  max-width: 380px;
  animation: slideIn .18s ease-out;
  pointer-events: auto;
}
.toast.err { background: var(--bad); }
.toast.ok  { background: var(--ok); }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ----- MODAL ----- */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(26,35,50,.35);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fadeIn .12s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-family: var(--font-display); font-weight: 500; font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.modal-close { cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; padding: 4px 8px; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 24px; }

/* ----- PAGINATION ----- */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; }

/* ----- LOADING ----- */
.loading { padding: 60px 20px; text-align: center; color: var(--muted); font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.10em; text-transform: uppercase; }

/* Errors */
.err-msg {
  padding: 10px 12px;
  background: var(--bad-tint);
  border: 1px solid rgba(166,56,56,.2);
  border-radius: var(--radius);
  color: var(--bad);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ----- REPORT LAYOUT ----- */
.report-layout { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.report-nav {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 6px 0 14px;
  position: sticky; top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.report-cat {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-soft);
  padding: 12px 16px;
  background: none; border: none; border-top: 1px solid var(--rule-soft);
  cursor: pointer;
}
.report-group:first-child .report-cat { border-top: none; }
.report-cat:hover { color: var(--ink); background: var(--rule-soft); }
.report-cat span:first-child { flex: 1; }
.report-cat-arrow {
  color: var(--muted); font-size: 14px; line-height: 1;
  transition: transform .15s ease;
}
.report-group.open .report-cat-arrow { transform: rotate(90deg); }
.report-cat-count {
  font-size: 9px; color: var(--muted);
  background: var(--rule-soft); border: 1px solid var(--rule);
  border-radius: 8px; padding: 1px 6px;
}
.report-group-items { display: none; padding-bottom: 6px; }
.report-group.open .report-group-items { display: block; }
.report-link {
  display: block; padding: 6px 16px; font-size: 13px; color: var(--ink-soft);
  text-decoration: none; border-left: 2px solid transparent;
}
.report-link:hover { color: var(--ink); background: var(--rule-soft); text-decoration: none; }
.report-link.active { color: var(--accent-ink); border-left-color: var(--accent); background: var(--accent-tint); }
@media (max-width: 900px) { .report-layout { grid-template-columns: 1fr; } .report-nav { position: static; max-height: none; } }
@media print { .report-nav { display: none !important; } .report-layout { grid-template-columns: 1fr; } }

/* ----- AVATARS ----- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid var(--rule);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 56px; height: 56px; font-size: 17px; }

/* ----- CHART GRIDS ----- */
.chart-grid { display: grid; gap: 20px; margin-bottom: 20px; align-items: start; }
.chart-grid.one-one { grid-template-columns: 1fr 1fr; }
.chart-grid.two-one { grid-template-columns: 2fr 1fr; }

/* Horizontal bars */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 130px 1fr 90px; align-items: center; gap: 12px; }
.hbar-label {
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hbar-track {
  height: 14px;
  background: var(--rule-soft);
  border-radius: 2px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #C97646 100%);
  border-radius: 2px;
  transition: width .3s ease-out;
}
.hbar-value {
  font-size: 12px;
  text-align: right;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* SVG line/area chart */
.svg-chart .grid line { stroke: var(--rule); stroke-dasharray: 2 3; }
.svg-chart .grid text { font-family: var(--font-mono); font-size: 10px; fill: var(--muted); }
.svg-chart .axis text { font-family: var(--font-mono); font-size: 10px; fill: var(--muted); }
.svg-chart .area-present { fill: var(--ok); fill-opacity: 0.12; }
.svg-chart .line-present { fill: none; stroke: var(--ok); stroke-width: 1.8; }
.svg-chart .line-absent  { fill: none; stroke: var(--bad); stroke-width: 1.4; stroke-dasharray: 4 3; }

/* ----- TABS (Reports) ----- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}
.tab {
  padding: 10px 18px;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ----- PRINT ----- */
@media print {
  .nav, .page-actions, .filter-bar, .tabs, #toast { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .main { padding: 20px !important; max-width: none; }
  .card { break-inside: avoid; page-break-inside: avoid; box-shadow: none; }
  body { background: white; }
}

/* Responsive */
/* ----- RESPONSIVE (v12_J: off-canvas drawer on mobile) ----- */
/* v12_M: burger is visible on desktop too — it collapses the sidebar */
.nav-burger {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  font-size: 18px; cursor: pointer;
}
.nav-burger:hover { border-color: var(--ink-soft); }
.topbar { justify-content: flex-start; }
.topbar .topbar-spacer { flex: 1; }
.shell.nav-hidden { grid-template-columns: 1fr; }
.shell.nav-hidden .nav { display: none; }
.nav-backdrop { display: none; }
.nav-group.collapsed a { display: none; }

@media (max-width: 900px) {
  .shell { display: block; }

  /* Sidebar becomes a slide-in drawer */
  .nav {
    position: fixed; left: -280px; top: 0; bottom: 0;
    width: 260px; height: 100vh; z-index: 120;
    transition: left .2s ease;
    box-shadow: none;
  }
  .nav.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 110;
    background: rgba(15,23,42,.45);
    opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .nav-backdrop.show { opacity: 1; pointer-events: auto; }

  /* Burger lives inside the topbar, left side */
  .nav-burger {
    display: grid; place-items: center;
    width: 38px; height: 38px;
    border: 1px solid var(--rule); border-radius: 8px;
    background: var(--surface); color: var(--ink);
    font-size: 18px; cursor: pointer;
  }
  .main { padding: 10px 14px 40px; max-width: none; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-title { font-size: 24px; }
  .page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

  .chart-grid.one-one, .chart-grid.two-one { grid-template-columns: 1fr; }
  .hbar-row { grid-template-columns: 100px 1fr 70px; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr !important; }
  .stat-row { grid-template-columns: 1fr 1fr !important; }
  .report-layout { grid-template-columns: 1fr !important; }

  table.data { font-size: 12px; }
  .card { overflow-x: auto; }
  .filter-bar { flex-wrap: wrap; }

  .modal { width: 94vw !important; max-width: 94vw !important; max-height: 90vh; overflow-y: auto; }
  .user-meta { display: none; }   /* chip shows just the avatar on phones */
}
@media (max-width: 480px) { .stat-row { grid-template-columns: 1fr !important; } }
