/*
 * theme.css — Brand Design System for Monitoring Portal
 *
 * Palette extracted from Gold_Theme.php / brand-colour-documentation.html
 * Primary: Gold #B5852E on Navy #122A43, over warm Cream #F6F2E9 paper.
 * Typography: Fraunces (headings), IBM Plex Sans (body), IBM Plex Mono (data).
 */

/* ── Google Fonts ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ── CSS Custom Properties ────────────────────────────────────────────────── */
:root {
  /* Gold family */
  --gold:         #B5852E;
  --gold-deep:    #946A1E;
  --gold-amber:   #A9791F;
  --gold-highlight:#E9C878;
  --gold-tint:    #F6EFDC;

  /* Navy family */
  --navy:         #122A43;
  --navy-mid:     #2E4C6B;
  --navy-dark:    #0C1E30;
  --slate:        #3A506B;
  --slate-soft:   #6E7A86;

  /* Cream surfaces */
  --cream:        #F6F2E9;
  --panel:        #FCFAF3;
  --wash:         #F3EEE0;
  --hover:        #FBF8F0;
  --card:         #FFFFFF;

  /* Lines */
  --line:         #E4DCC9;
  --line-strong:  #D6CCB4;

  /* Semantic colours */
  --red:          #B23A2E;
  --red-light:    #F9E4E2;
  --green:        #1F7A52;
  --green-deep:   #175E40;
  --green-light:  #E2F5EC;
  --purple:       #6a1b9a;
  --violet:       #6d28d9;
  --blue:         #1565c0;
  --cyan:         #0e7490;

  /* Typography */
  --font-display: 'Fraunces', serif;
  --font-body:    'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', monospace;

  /* Sidebar */
  --sb-w: 210px;

  /* Shadows */
  --shadow-sm:   0 1px 0 rgba(18,42,67,.04), 0 4px 12px -4px rgba(18,42,67,.08);
  --shadow-card: 0 1px 0 rgba(18,42,67,.04), 0 10px 34px -24px rgba(18,42,67,.18);
  --shadow-lg:   0 20px 60px rgba(18,42,67,.22);

  /* Radii */
  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 14px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--navy);
  line-height: 1.55;
  min-height: 100vh;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--navy);
}

/* ── Sidebar layout ───────────────────────────────────────────────────────── */
body.has-sidebar { padding-left: var(--sb-w); }

#sbToggle {
  position: fixed; top: 12px; left: 12px; z-index: 1100;
  display: none; width: 40px; height: 40px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 1.2rem; color: var(--navy); line-height: 1;
}
#sbBackdrop {
  position: fixed; inset: 0; background: rgba(18,42,67,.45);
  z-index: 1000; display: none;
}

.app-sidebar {
  position: fixed; top: 0; left: 0; z-index: 1050;
  width: var(--sb-w); height: 100vh;
  background: var(--navy); border-right: none;
  display: flex; flex-direction: column;
  font-family: var(--font-body);
}
.app-sidebar::after {
  content: ""; position: absolute; right: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-deep) 50%, var(--gold-amber) 100%);
}
.app-sidebar .sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.app-sidebar .sb-brand img { width: 30px; height: 30px; object-fit: contain; }
.app-sidebar .sb-brand span {
  font-family: var(--font-display);
  font-weight: 600; font-size: 1rem; color: #fff;
}

.app-sidebar .sb-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.app-sidebar .sb-nav a {
  display: block; text-decoration: none;
  padding: 8px 14px; margin-bottom: 3px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.68); font-size: .82rem; font-weight: 500;
  border-left: 3px solid transparent; transition: all .15s;
}
.app-sidebar .sb-nav a:hover {
  background: rgba(255,255,255,.06); color: #fff;
}
.app-sidebar .sb-nav a.active {
  background: rgba(181,133,46,.15);
  color: var(--gold-highlight);
  border-left-color: var(--gold);
}
.app-sidebar .sb-nav a.super::after {
  content: "SUPER"; float: right; font-size: .6rem; font-weight: 700;
  background: rgba(233,200,120,.18); color: var(--gold-highlight);
  padding: 1px 6px; border-radius: 999px; margin-top: 2px;
}
.app-sidebar .sb-nav a.super.active {
  border-left-color: var(--gold-amber);
}

.app-sidebar .sb-foot {
  border-top: 1px solid rgba(255,255,255,.08); padding: 14px 18px; font-size: .82rem;
}
.app-sidebar .sb-foot .who { color: rgba(255,255,255,.55); margin-bottom: 8px; word-break: break-word; }
.app-sidebar .sb-foot .who b { color: #fff; }
.app-sidebar .sb-foot a.logout {
  color: var(--gold-highlight); text-decoration: none; font-weight: 700;
}
.app-sidebar .sb-foot a.logout:hover { text-decoration: underline; color: var(--gold); }

@media (max-width: 768px) {
  body.has-sidebar { padding-left: 0; }
  #sbToggle { display: block; }
  .app-sidebar {
    transform: translateX(-100%); transition: transform .2s ease;
  }
  body.sb-open .app-sidebar { transform: translateX(0); }
  body.sb-open #sbBackdrop { display: block; }
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px 28px;
  margin-bottom: 18px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  padding: 10px 22px; border: none; border-radius: var(--radius-sm);
  font-size: .93rem; font-weight: 600; cursor: pointer;
  font-family: var(--font-body);
  transition: background .15s, transform .1s, box-shadow .15s;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--navy); color: #fff;
}
.btn-primary:hover {
  background: var(--navy-mid);
  box-shadow: 0 4px 12px rgba(18,42,67,.2);
}
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.btn-gold {
  background: var(--gold); color: #fff;
}
.btn-gold:hover {
  background: var(--gold-deep);
  box-shadow: 0 4px 12px rgba(181,133,46,.25);
}

.btn-outline {
  background: transparent; color: var(--slate);
  border: 2px solid var(--line);
}
.btn-outline:hover { background: var(--hover); border-color: var(--line-strong); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: var(--green-deep); }
.btn-success:disabled { opacity: .55; cursor: not-allowed; }

.btn-danger { background: var(--red); color: #fff; border: none; }
.btn-danger:hover { background: #8F2E24; }
.btn-danger:disabled { opacity: .55; cursor: not-allowed; }

.btn-warning { background: var(--gold-amber); color: #fff; border: none; }
.btn-warning:hover { background: var(--gold-deep); }

.btn-muted { background: var(--wash); color: var(--slate); border: none; }
.btn-muted:hover { background: var(--line); }

.btn-excel { background: var(--green); color: #fff; }
.btn-excel:hover { background: var(--green-deep); }
.btn-excel-sm {
  background: var(--green-light); color: var(--green-deep);
  border: 2px solid #BBE5D1; font-size: .78rem; padding: 5px 11px;
}
.btn-excel-sm:hover { background: #D0F0E0; }

.btn-sm { padding: 6px 12px; font-size: .82rem; }

/* ── Form controls ────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: .85rem; font-weight: 600; color: var(--slate);
}
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 2px solid var(--line); border-radius: var(--radius-sm);
  font-size: .95rem; font-family: var(--font-body); color: var(--navy);
  transition: border-color .15s; background: var(--card);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(181,133,46,.12);
}
.field input[readonly] { background: var(--panel); color: var(--slate-soft); cursor: default; }
.field textarea { resize: vertical; min-height: 105px; }
.field .hint { font-size: .78rem; color: var(--slate-soft); }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.tbl-wrap {
  overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 14px;
  position: relative;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; background: var(--panel); border-bottom: 1.5px solid var(--line-strong);
  padding: 10px 12px; font-size: .78rem; font-weight: 700; color: var(--slate);
  text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
  font-family: var(--font-mono);
  position: sticky; top: 0; z-index: 10;
}
tbody td {
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  font-size: .88rem; vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--hover); }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: .9rem; margin-bottom: 18px;
  border-left: 4px solid transparent;
}
.alert-ok  { background: var(--green-light); color: var(--green-deep); border: 1px solid #A7DCBF; border-left-color: var(--green); }
.alert-err { background: var(--red-light); color: var(--red); border: 1px solid #E8B4B0; border-left-color: var(--red); }
.alert-info { background: #E8F0FE; color: var(--blue); border: 1px solid #B1CCEE; border-left-color: var(--blue); }
.hidden { display: none !important; }

/* ── Status badges ────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .73rem; font-weight: 700;
  white-space: nowrap; letter-spacing: .02em;
  font-family: var(--font-mono);
}
.status-submitted  { background: #DAE8F8; color: var(--blue); }
.status-inprogress { background: var(--gold-tint); color: var(--gold-deep); }
.status-awaiting   { background: #EDE0F5; color: var(--purple); }
.status-closed     { background: var(--green-light); color: var(--green-deep); }

/* ── Rating pills ─────────────────────────────────────────────────────────── */
.rating-pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; font-family: var(--font-mono);
}
.rating-poor { background: var(--red-light); color: var(--red); }
.rating-sat  { background: var(--gold-tint); color: var(--gold-deep); }
.rating-good { background: var(--green-light); color: var(--green-deep); }

/* ── Role chips ───────────────────────────────────────────────────────────── */
.role-chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  font-family: var(--font-mono);
}
.chip-super  { background: var(--gold-tint); color: var(--gold-deep); }
.chip-admin  { background: #DAE8F8; color: var(--navy-mid); }
.chip-viewer { background: var(--wash); color: var(--slate); }

.role-badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  font-family: var(--font-mono);
}
.role-SUPER_ADMIN { background: var(--gold-tint); color: var(--gold-deep); border: 1px solid var(--gold-highlight); }
.role-ADMIN       { background: #DAE8F8; color: var(--navy-mid); border: 1px solid #B1CCEE; }
.role-VIEWER      { background: var(--wash); color: var(--slate); border: 1px solid var(--line); }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: var(--wash); color: var(--slate);
  font-family: var(--font-mono);
}
.badge-ignored { background: var(--gold-tint); color: var(--gold-deep); }

/* ── Modals ───────────────────────────────────────────────────────────────── */
.backdrop {
  position: fixed; inset: 0; background: rgba(18,42,67,.5);
  display: none; align-items: center; justify-content: center; z-index: 999;
}
.backdrop.open { display: flex; }
.modal {
  width: 95%; max-width: 680px; background: var(--card);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-head {
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel);
}
.modal-head h3 {
  margin: 0; font-size: 1rem; font-family: var(--font-display); font-weight: 600;
}
.modal-body { padding: 16px 20px; max-height: 60vh; overflow-y: auto; }
.modal-foot {
  padding: 12px 20px; border-top: 1px solid var(--line);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--panel);
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagin { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pagin .info { color: var(--slate-soft); font-size: .85rem; margin-right: auto; }
.pagin .pages { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pagin .pg-btn {
  min-width: 32px; height: 32px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--slate);
  border-radius: 6px; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .15s; font-family: var(--font-mono);
}
.pagin .pg-btn:hover:not(:disabled):not(.active) { background: var(--hover); border-color: var(--line-strong); }
.pagin .pg-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); cursor: default; }
.pagin .pg-btn:disabled { opacity: .45; cursor: not-allowed; }
.pagin .pg-ellipsis { padding: 0 4px; color: var(--slate-soft); font-weight: 600; user-select: none; }

/* ── Toolbar (filter row) ─────────────────────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { display: flex; flex-direction: column; gap: 4px; }
.toolbar .field label { font-size: .78rem; font-weight: 600; color: var(--slate-soft); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .04em; }
.toolbar input, .toolbar select {
  padding: 8px 10px; border: 2px solid var(--line); border-radius: 7px; font-size: .88rem; min-width: 130px;
  font-family: var(--font-body); background: var(--card); color: var(--navy);
}
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(181,133,46,.12); }

/* ── Toggle switch ────────────────────────────────────────────────────────── */
.toggle-label {
  display: flex; align-items: center; gap: 7px;
  font-size: .82rem; font-weight: 600; color: var(--slate);
  cursor: pointer; user-select: none; white-space: nowrap;
}
.toggle-label input[type=checkbox] { display: none; }
.toggle-track {
  width: 36px; height: 20px; background: var(--line); border-radius: 999px;
  position: relative; transition: background .15s; flex-shrink: 0;
}
.toggle-label input:checked ~ .toggle-track { background: var(--gold); }
.toggle-thumb {
  position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
  background: #fff; border-radius: 999px; transition: left .15s;
}
.toggle-label input:checked ~ .toggle-track .toggle-thumb { left: 19px; }

/* ── Icon action buttons ──────────────────────────────────────────────────── */
.icon-btn {
  width: 24px; height: 24px; padding: 0; border: none; border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .72rem; transition: all .15s; position: relative;
  flex-shrink: 0;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(18,42,67,.15); }
.icon-btn:active { transform: translateY(0); }
.icon-btn[title]:hover::after {
  content: attr(title); position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%); background: var(--navy); color: #fff; font-size: .7rem;
  padding: 3px 8px; border-radius: 5px; white-space: nowrap; pointer-events: none;
  font-weight: 600; letter-spacing: .02em; z-index: 20;
}
.icon-btn-view   { background: var(--navy-mid); color: #fff; }
.icon-btn-action { background: var(--gold); color: #fff; }
.icon-btn-edit   { background: var(--slate); color: #fff; }
.icon-btn-ignore { background: var(--gold-amber); color: #fff; }
.icon-btn-unignore { background: var(--slate-soft); color: #fff; }
.icon-btn-disabled { background: var(--wash); color: var(--slate-soft); cursor: default; }
.icon-btn-disabled:hover { transform: none; box-shadow: none; }
.actions-cell { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: 54px; }

/* ── Custom value indicator ───────────────────────────────────────────────── */
.custom-value-indicator {
  display: inline-block; margin-left: 6px; padding: 2px 8px;
  background: var(--gold-tint); color: var(--gold-deep);
  border: 1px solid var(--gold-highlight); border-radius: 4px;
  font-size: .7rem; font-weight: 600; letter-spacing: .02em;
  font-family: var(--font-mono);
}

/* ── File drop zone ───────────────────────────────────────────────────────── */
.file-drop {
  border: 2px dashed var(--line-strong); border-radius: var(--radius-sm);
  padding: 20px; text-align: center; background: var(--panel);
  cursor: pointer; color: var(--slate-soft); font-size: .88rem;
  transition: border-color .15s, background .15s;
}
.file-drop:hover { border-color: var(--gold); background: var(--gold-tint); }

/* ── Top row (page header) ────────────────────────────────────────────────── */
.top-row {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 18px;
}
.top-row h2 {
  font-size: 1.15rem; font-family: var(--font-display); font-weight: 600;
}
.top-row .right-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.top-row .sub { color: var(--slate-soft); font-size: .85rem; margin-top: 2px; }

/* ── KPI tiles ────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 14px; margin-bottom: 20px;
}
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
.kpi {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--gold);
  display: flex; flex-direction: column; gap: 4px;
}
.kpi .lbl {
  font-size: .76rem; font-weight: 700; color: var(--slate-soft);
  text-transform: uppercase; letter-spacing: .04em;
  font-family: var(--font-mono);
}
.kpi .val {
  font-size: 1.7rem; font-weight: 700; color: var(--navy); line-height: 1.1;
  font-family: var(--font-mono);
}
.kpi .sub { font-size: .75rem; color: var(--slate-soft); }
.kpi.k-open    { border-left-color: var(--blue); }
.kpi.k-prog    { border-left-color: var(--gold-amber); }
.kpi.k-await   { border-left-color: var(--purple); }
.kpi.k-closed  { border-left-color: var(--green); }
.kpi.k-time    { border-left-color: var(--cyan); }
.kpi.k-ignored { border-left-color: var(--slate-soft); }

/* ── Stacked bar (dept distribution) ──────────────────────────────────────── */
.stack {
  display: flex; height: 8px; border-radius: 4px; overflow: hidden;
  background: var(--wash); min-width: 110px;
}
.stack > span { display: block; height: 100%; }
.stack .s-sub  { background: var(--blue); opacity: .6; }
.stack .s-prog { background: var(--gold); }
.stack .s-awt  { background: var(--purple); opacity: .6; }
.stack .s-cls  { background: var(--green); opacity: .6; }

.stack-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: .75rem; color: var(--slate); }
.stack-legend .key { display: inline-flex; align-items: center; gap: 5px; }
.stack-legend .dot { width: 10px; height: 10px; border-radius: 3px; }

/* ── Grid utility ─────────────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.span2 { grid-column: span 2; }
@media(max-width:600px){
  .grid { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
}

/* ── Page wrapper ─────────────────────────────────────────────────────────── */
.page { max-width: 1400px; margin: 28px auto; padding: 0 16px 48px; }
.page.narrow { max-width: 820px; }
.page.xs { max-width: 480px; margin-top: 48px; }

/* ── Chart panels ─────────────────────────────────────────────────────────── */
.panels {
  display: grid; grid-template-columns: 2fr 1fr; gap: 18px; margin-bottom: 20px;
}
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 20px 24px;
}
.panel h3 { font-size: .98rem; font-weight: 700; margin-bottom: 4px; }
.panel .panel-sub { color: var(--slate); font-size: .82rem; margin-bottom: 14px; }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 320px; }
@media (max-width: 980px) { .panels { grid-template-columns: 1fr; } }

/* ── Filter card ──────────────────────────────────────────────────────────── */
.filter-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.filter-form .field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.filter-form label {
  font-size: .72rem; font-weight: 600; color: var(--slate-soft);
  text-transform: uppercase; letter-spacing: .04em; font-family: var(--font-mono);
}
.filter-form input, .filter-form select {
  padding: 8px 10px; border: 2px solid var(--line); border-radius: 7px;
  font-size: .85rem; min-width: 120px; background: var(--card);
  font-family: var(--font-body); color: var(--navy); height: 38px;
}
.filter-form input:focus, .filter-form select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(181,133,46,.12); }
.filter-form .toggle { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--slate); }
@media(max-width:700px) {
  .filter-form { flex-direction: column; align-items: stretch; }
  .filter-form .field { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
}

/* ── Drill-down ───────────────────────────────────────────────────────────── */
.drill {
  cursor: pointer; text-decoration: none;
  border-bottom: 1px dashed transparent; transition: border-color .12s, color .12s;
}
.drill:hover { color: var(--gold); border-bottom-color: var(--gold-highlight); }
tr.drill-row { cursor: pointer; }
tr.drill-row:hover td { background: var(--gold-tint); }
.kpi.drill-card { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.kpi.drill-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(18,42,67,.12); }

/* ── Drill modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(18,42,67,.55);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 1200; padding: 40px 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.sum-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr));
  gap: 10px; margin-bottom: 16px;
}
.sum-tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px;
}
.sum-tile .s-lbl { font-size: .68rem; font-weight: 700; color: var(--slate-soft); text-transform: uppercase; letter-spacing: .04em; font-family: var(--font-mono); }
.sum-tile .s-val { font-size: 1.3rem; font-weight: 700; color: var(--navy); font-family: var(--font-mono); }
.sum-tile.clk { cursor: pointer; }
.sum-tile.clk:hover { border-color: var(--gold); background: var(--gold-tint); }

/* ── Sortable table headers ───────────────────────────────────────────────── */
table.sortable thead th { cursor: pointer; user-select: none; }
table.sortable thead th .arr { font-size: .7em; opacity: .35; margin-left: 4px; }
table.sortable thead th.sort-asc .arr,
table.sortable thead th.sort-desc .arr { opacity: 1; color: var(--gold); }

/* Centre-align table values, except left-aligned columns */
.tbl-wrap th, .tbl-wrap td, .tbl-wrap td.num { text-align: center; }
.tbl-wrap th.lft, .tbl-wrap td.lft { text-align: left; }

/* ── Ignored rows ─────────────────────────────────────────────────────────── */
tbody tr.ignored-row td { opacity: .45; }
tbody tr.ignored-row {
  background: repeating-linear-gradient(135deg, var(--gold-tint), var(--gold-tint) 6px, var(--panel) 6px, var(--panel) 12px);
}
tbody tr.ignored-row:hover td { opacity: .65; }

/* ── Spinner animation ────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: none; width: 18px; height: 18px;
  border: 2px solid #fff; border-top-color: transparent;
  border-radius: 50%; animation: spin .65s linear infinite; margin-left: 4px;
}

/* ── Print ────────────────────────────────────────────────────────────────── */
@media print {
  body.has-sidebar { padding-left: 0; }
  .app-sidebar, #sbToggle, #sbBackdrop { display: none !important; }
  .btn, .toolbar, .filter-form { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 28px; color: var(--slate-soft); font-size: .9rem;
}

/* ── Misc helpers ─────────────────────────────────────────────────────────── */
.issue-trunc, .issue-cell p, .content-cell {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; text-overflow: ellipsis;
}
.issue-cell { max-width: 260px; }
.content-cell { max-width: 360px; -webkit-line-clamp: 2; }

.mono { font-family: var(--font-mono); }