/* ── MIS brand tokens ─────────────────────────────────────── */
:root {
  --mis-red: #F30000;
  --mis-red-dark: #C50000;
  --mis-navy: #09213C;
  --mis-text: #434D4C;
  --mis-muted: #5F6E6D;
  --mis-line: #E0E5E5;
  --mis-bg: #F6F8F8;
}

@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/fonts/nunito-v32-latin-regular.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/nunito-v32-latin-600.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/fonts/nunito-v32-latin-700.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("/fonts/nunito-v32-latin-800.woff2") format("woff2");
}

/* ── Base ─────────────────────────────────────────────────── */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--mis-text);
  background: var(--mis-bg);
  line-height: 1.5;
}
h1, h2, h3 { color: var(--mis-navy); font-weight: 800; }
a { color: var(--mis-navy); }
code { background: #eef1f1; padding: 2px 6px; border-radius: 4px; }
.muted { color: var(--mis-muted); }

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  background: var(--mis-navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
}
.site-header .logo img { height: 34px; display: block; }
.site-header nav { display: flex; gap: 18px; flex: 1; }
.site-header nav a {
  color: #cdd6df; text-decoration: none; font-weight: 600; font-size: 15px;
}
.site-header nav a:hover, .site-header nav a.active { color: #fff; }
.site-header .user { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.site-header .user form { margin: 0; }
.btn-link {
  background: none; border: none; color: #cdd6df; cursor: pointer;
  font: inherit; font-weight: 600; padding: 0;
}
.btn-link:hover { color: #fff; }
.btn-link:focus-visible, .site-header nav a:focus-visible {
  outline: 2px solid #fff; outline-offset: 2px;
}
.btn-primary:focus-visible {
  outline: 2px solid var(--mis-navy); outline-offset: 2px;
}

/* ── Nav dropdown (native <details>, no JS — CSP safe) ────── */
.nav-dropdown { position: relative; display: flex; align-items: center; }
.nav-dropdown > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  color: #cdd6df; font-weight: 600; font-size: 15px;
}
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown > summary::after {
  content: ""; width: 0; height: 0; border-left: 4px solid transparent;
  border-right: 4px solid transparent; border-top: 5px solid currentColor;
}
.nav-dropdown > summary:hover, .nav-dropdown[open] > summary { color: #fff; }
.nav-dropdown > summary:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.nav-menu {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 30;
  min-width: 210px; padding: 6px; background: #fff;
  border: 1px solid var(--mis-line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(9, 33, 60, 0.18);
  display: flex; flex-direction: column;
}
/* Scoped under .site-header nav so these out-specify the generic
   `.site-header nav a` header-link rules (which are light grey for the navy bar). */
.site-header nav .nav-menu a {
  color: var(--mis-text); text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 9px 12px; border-radius: 7px;
}
.site-header nav .nav-menu a:hover,
.site-header nav .nav-menu a:focus { background: var(--mis-line); color: var(--mis-navy); }
.site-header nav .nav-menu a:focus-visible { outline: 2px solid var(--mis-navy); outline-offset: -2px; }

/* ── Layout ───────────────────────────────────────────────── */
.container { max-width: 1080px; margin: 32px auto; padding: 0 24px; }

/* Embedded Metabase dashboard: break out of the 1080px container and centre
   on the viewport, capped at 1600px (tune this one number to taste). */
.metabase-embed {
  display: block;
  border: 0;
  width: min(1600px, calc(100vw - 32px));
  margin-left: 50%;
  transform: translateX(-50%);
}

/* ── Forms & buttons ──────────────────────────────────────── */
label { display: block; margin: 14px 0 4px; font-weight: 700; font-size: 14px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
select, textarea {
  width: 100%; padding: 10px 12px; font: inherit;
  border: 1px solid var(--mis-line); border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--mis-navy); border-color: var(--mis-navy);
}
.btn-primary {
  display: inline-block; margin-top: 18px; padding: 10px 22px;
  background: var(--mis-red); color: #fff; border: none; border-radius: 8px;
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn-primary:hover { background: var(--mis-red-dark); }

/* ── Auth card ────────────────────────────────────────────── */
.auth-card {
  max-width: 420px; margin: 48px auto; padding: 32px;
  background: #fff; border: 1px solid var(--mis-line); border-radius: 12px;
}
.auth-card h1 { margin-top: 0; font-size: 24px; }
.auth-card .qr { display: block; margin: 12px 0; }

/* ── Validation & misc ────────────────────────────────────── */
.validation-summary ul { color: var(--mis-red); padding-left: 18px; margin: 8px 0; }
/* The tag helper renders a placeholder <li style="display:none"> when valid;
   strict CSP blocks inline style attributes, so hide via the -valid class. */
.validation-summary-valid { display: none; }
.recovery-codes { columns: 2; list-style: none; padding: 0; }
.recovery-codes li { margin: 4px 0; }

/* ── Admin UI ─────────────────────────────────────────────── */
.lead { font-size: 15px; margin: 0 0 20px; max-width: 60ch; }
.link-list { list-style: none; padding: 0; margin: 0; max-width: 560px; }
.link-list li {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 14px 0; border-bottom: 1px solid var(--mis-line);
}
.link-list li:last-child { border-bottom: none; }
.link-list li > a { font-weight: 700; font-size: 16px; text-decoration: none; }
.link-list li > a:hover { text-decoration: underline; }
.link-list .muted { font-size: 14px; }

.card {
  background: #fff; border: 1px solid var(--mis-line); border-radius: 12px;
  padding: 24px; margin-bottom: 16px;
}

table.data { width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid var(--mis-line); border-radius: 12px; overflow: hidden; }
table.data th, table.data td { text-align: left; padding: 10px 14px;
  border-bottom: 1px solid var(--mis-line); font-size: 14px; vertical-align: top; }
table.data th { background: var(--mis-bg); color: var(--mis-navy);
  font-weight: 700; font-size: 13px; }
table.data tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; }
.badge-admin { background: var(--mis-navy); color: #fff; }
.badge-ok { background: #E2F2E9; color: #1C6B3C; }
.badge-warn { background: #FBE9E7; color: #B3261E; }
.badge-muted { background: var(--mis-line); color: var(--mis-text); }

.btn-secondary {
  display: inline-block; padding: 6px 14px; background: #fff; color: var(--mis-navy);
  border: 1px solid var(--mis-navy); border-radius: 8px; font: inherit;
  font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn-secondary:hover { background: var(--mis-bg); }
.btn-secondary:focus-visible { outline: 2px solid var(--mis-navy); outline-offset: 2px; }
.actions form { display: inline-block; margin: 0 4px 4px 0; }

.filter-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-row > div { min-width: 140px; position: relative; }
.filter-row label { margin-top: 0; }
/* Field hint sits just below its input without adding column height, so the
   flex-end row keeps every input on the same baseline. */
.filter-row .field-hint { position: absolute; top: 100%; left: 0; margin-top: 4px;
  font-size: 12px; font-weight: 400; white-space: nowrap; }
.status-banner { background: #E2F2E9; color: #1C6B3C; border-radius: 8px;
  padding: 10px 16px; margin-bottom: 16px; }
.status-banner.error { background: #FBE9E7; color: #B3261E; }
.page-header { display: flex; justify-content: space-between; align-items: center; }
details.json pre { background: var(--mis-bg); padding: 8px 12px; border-radius: 6px;
  font-size: 12px; overflow-x: auto; margin: 6px 0 0; }

/* ── Policy query ─────────────────────────────────────────── */
table.kv th { width: 280px; font-weight: 600; }
.summary-card h2 { margin: 0 0 2px; font-size: 20px; }
.summary-card .meta { color: var(--mis-muted); margin: 0 0 12px; }
.summary-facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0 0 8px; padding: 0; list-style: none; }
.summary-facts li { font-size: 14px; }
.summary-facts .label { display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--mis-muted); }
.policy-card { margin-bottom: 12px; }
.policy-card summary { cursor: pointer; font-weight: 700; color: var(--mis-navy); padding: 4px 0; }
.policy-card summary .badge { margin-left: 8px; }
.section-group { margin: 16px 0; }
.section-group > details > summary { cursor: pointer; font-weight: 700; color: var(--mis-navy);
  padding: 8px 0; font-size: 15px; }
.inline-form { display: inline; }
.doc-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; }
.doc-row > div { min-width: 130px; }
.doc-row label { margin-top: 0; }
/* htmx ships indicator styles disabled (CSP); these are ours. */
.htmx-indicator { display: none; color: var(--mis-muted); font-size: 13px; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request .htmx-hide-during { display: none; }

/* ── Reporting ────────────────────────────────────────────── */
.report-run.inline-form { display: inline; margin-right: 8px; }
.link-list li .report-name { font-weight: 700; }
.report-run.is-busy button { opacity: .6; cursor: progress; }

.vnb-provisional { background:#FFF7E6; border-left:3px solid #B06A00; padding:.6rem .9rem; margin:.5rem 0 1rem; font-size:.9rem; }
.vnb-verdict { display:flex; gap:1.5rem; align-items:baseline; padding:1rem 1.2rem; border-radius:6px; color:#fff; }
.vnb-verdict.is-green { background:#1C6B3C; } .vnb-verdict.is-red { background:#C50000; }
.vnb-verdict .verdict-label { font-weight:800; letter-spacing:2px; }
.vnb-verdict .verdict-num { font-size:1.6rem; font-weight:800; }
.vnb-kpis { display:grid; grid-template-columns:repeat(6,1fr); gap:.75rem; margin:1rem 0; }
.vnb-kpis div { background:#F6F8F8; border:1px solid #E0E5E5; border-radius:6px; padding:.6rem; text-align:center; }
.vnb-kpis b { display:block; font-size:1.2rem; color:#09213C; } .vnb-kpis span { font-size:.75rem; color:#5F6E6D; }
.vnb-charts { display:grid; grid-template-columns:1fr 1fr; gap:1rem; }
.chart-box { background:#fff; border:1px solid #E0E5E5; border-radius:6px; padding:.5rem; height:300px; position:relative; }
.vnb-assumptions { border:1px solid #E0E5E5; border-radius:6px; padding:.4rem 1rem 1rem; margin:1rem 0; }
.vnb-assumptions > legend { font-weight:700; color:#09213C; padding:0 .4rem; }
.vnb-fields { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:.6rem .9rem; }
.vnb-assumptions label { display:flex; flex-direction:column; font-size:.78rem; gap:.25rem; color:#4A5A59; }
.vnb-assumptions input { padding:.35rem .5rem; border:1px solid #CBD3D3; border-radius:4px; font-size:.9rem; width:100%; box-sizing:border-box; }
.vnb-tail { border:1px solid #E8ECEC; border-radius:6px; margin-top:.9rem; padding:.3rem .8rem .8rem; }
.vnb-tail > legend { font-size:.78rem; color:#5F6E6D; padding:0 .3rem; }
.vnb-tail-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:.7rem; }
.tail-band { display:flex; flex-direction:column; gap:.35rem; background:#F6F8F8; border:1px solid #E8ECEC; border-radius:5px; padding:.5rem .6rem; }
.tail-band-h { font-size:.72rem; font-weight:700; text-transform:uppercase; letter-spacing:.5px; color:#09213C; }
.vnb-form-actions { margin-top:1rem; }
.vnb-form-actions button { padding:.5rem 1.5rem; font-size:.9rem; }
.vnb-error { background:#FDECEA; border-left:3px solid #C50000; padding:.8rem; }
.role-cell { display:flex; flex-direction:column; gap:.3rem; align-items:flex-start; }
.role-cell .role-toggle { margin:0; }
.role-cell label { display:inline-flex; gap:.35rem; align-items:center; font-size:.85rem; }
.role-cell .role-error { color:#C50000; font-size:.75rem; }
