:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --ink: #162033;
  --ink-soft: #5d6b80;
  --line: #dfe5ef;
  --sidebar: #0b1220;
  --sidebar-soft: #151f33;
  --primary: #0e9f91;
  --primary-strong: #087d73;
  --primary-soft: #dff7f3;
  --focus: #087d73;
  --danger: #c73545;
  --warning: #b36b00;
  --status-ready: #138a62;
  --status-conditional: #b36b00;
  --status-not-ready: #6b7280;
  --status-blocked: #c73545;
  --status-not-started: #667085;
  --shadow: 0 10px 30px rgba(22, 32, 51, .08);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

* { box-sizing: border-box; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: .5rem; left: .5rem; z-index: 100; padding: .65rem .85rem; border-radius: 8px; color: #fff; background: var(--sidebar); transform: translateY(-160%); }
.skip-link:focus { color: #fff; transform: translateY(0); }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--bg); }
a { color: var(--primary-strong); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary); }
button, input, select, textarea { font: inherit; }
button, .button, .button-link {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 42px; border: 1px solid transparent; border-radius: 9px; padding: .65rem 1rem;
  color: #fff; background: var(--primary-strong); font-weight: 650; text-decoration: none; cursor: pointer;
  transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
button:hover, .button:hover, .button-link:hover { color: #fff; background: var(--primary); box-shadow: 0 6px 18px rgba(14,159,145,.18); }
button:active, .button:active, .button-link:active { transform: translateY(1px); }
.button-secondary { color: var(--ink); background: #fff; border-color: var(--line); }
.button-secondary:hover { color: var(--ink); background: var(--surface-muted); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(14,159,145,.28); outline-offset: 2px; }

.app-shell { min-height: 100vh; }
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; display: flex; flex-direction: column;
  width: 264px; padding: 1.25rem 1rem; color: #e9eef8; background: var(--sidebar);
}
.brand-lockup { display: flex; align-items: center; gap: .75rem; padding: .25rem .5rem 1.4rem; color: #fff; text-decoration: none; }
.brand-lockup:hover { color: #fff; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-size: 1rem; letter-spacing: -.01em; }
.brand-copy small { color: #93a2bb; font-size: .72rem; margin-top: .2rem; }
.organization-label { margin: 0 .5rem 1rem; padding: .7rem .8rem; border: 1px solid rgba(255,255,255,.08); border-radius: 10px; background: var(--sidebar-soft); }
.organization-label small { display: block; color: #93a2bb; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; }
.organization-label strong { display: block; margin-top: .15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-nav { display: grid; gap: .28rem; }
.app-nav a { display: flex; align-items: center; gap: .7rem; padding: .72rem .8rem; border-radius: 9px; color: #bcc8da; font-weight: 560; text-decoration: none; }
.app-nav a:hover, .app-nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.08); }
.app-nav svg { width: 19px; height: 19px; flex: 0 0 auto; }
.sidebar-user { margin-top: auto; padding: 1rem .6rem .25rem; border-top: 1px solid rgba(255,255,255,.09); }
.language-switcher { margin-bottom: .85rem; }
.language-switcher label { display: grid; gap: .25rem; color: #93a2bb; font-size: .75rem; }
.language-switcher select { height: 44px; min-height: 44px; color: #e9eef8; border-color: rgba(255,255,255,.13); background: var(--sidebar-soft); }
.user-identity { display: grid; margin-bottom: .75rem; }
.user-identity strong { color: #fff; }
.user-identity small { color: #93a2bb; }
.sidebar-user form button { width: 100%; color: #d6deeb; background: transparent; border-color: rgba(255,255,255,.13); }
.sidebar-user form button:hover { color: #fff; background: rgba(255,255,255,.08); box-shadow: none; }

.app-main { min-height: 100vh; margin-left: 264px; }
.app-topbar { display: none; }
.app-content { width: min(1440px, 100%); margin: 0 auto; padding: 2rem clamp(1rem, 3vw, 3rem) 4rem; }
.nav-backdrop { display: none; }

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.6rem; }
.page-heading h1 { margin: .15rem 0 .3rem; font-size: clamp(1.65rem, 3vw, 2.35rem); line-height: 1.15; letter-spacing: -.035em; }
.page-heading p { max-width: 760px; margin: 0; color: var(--ink-soft); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .6rem; }
h1, h2, h3 { color: #142038; }
h2 { margin: 0 0 1rem; font-size: 1.08rem; letter-spacing: -.012em; }
h3 { margin: 0 0 .45rem; font-size: .98rem; }
p { margin-top: 0; }
small { color: var(--ink-soft); }

.panel, section { margin-bottom: 1rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 2px rgba(22,32,51,.03); }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1.4rem; }
.metric-card { padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.metric-card small { display: block; min-height: 2.2em; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .055em; }
.metric-card strong { display: block; margin-top: .4rem; font-size: 1.8rem; line-height: 1; }
.metric-card.ready { border-top: 4px solid var(--status-ready); }
.metric-card.conditional { border-top: 4px solid var(--status-conditional); }
.metric-card.blocked { border-top: 4px solid var(--status-blocked); }
.metric-card.not-ready { border-top: 4px solid var(--status-not-ready); }
.metric-card.not-started { border-top: 4px solid var(--status-not-started); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.4fr); gap: 1rem; align-items: start; }
.program-list, .record-list { display: grid; gap: .65rem; }
.program-list a, .record-list article { display: block; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-muted); }
.program-list a { color: var(--ink); text-decoration: none; }
.program-list a:hover { border-color: #9cd9d2; background: var(--primary-soft); }
.record-list article small { display: block; margin: .15rem 0 .4rem; }

.data-table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 11px; }
table, .data-table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: .78rem .85rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; z-index: 1; color: #526076; background: #f7f9fc; font-size: .75rem; text-transform: uppercase; letter-spacing: .055em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfe; }
.status, .status-badge { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; padding: .28rem .65rem; font-size: .76rem; font-weight: 750; text-transform: capitalize; background: #edf1f6; }
.status-ready { color: #086345; background: #daf5e9; }
.status-conditional, .status-approved { color: #7f4a00; background: #fff0cc; }
.status-blocked, .status-rejected { color: #9f2030; background: #fde3e7; }
.status-not_ready, .status-not-ready, .status-pending { color: #505b6d; background: #eaf0f5; }
.status-not_started, .status-not-started { color: #526076; background: #eef2f7; }
.readiness-summary { display: grid; min-width: 150px; padding: .85rem 1rem; border-radius: 12px; text-align: right; }
.readiness-summary span { font-size: 1.5rem; font-weight: 800; }

.stacked-form { display: grid; gap: .85rem; }
.stacked-form.compact { margin-top: .75rem; gap: .6rem; }
.stacked-form label { display: grid; gap: .34rem; color: #45536a; font-size: .82rem; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid #cfd7e4; border-radius: 8px; padding: .62rem .72rem; color: var(--ink); background: #fff; }
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--primary); }
input[type="file"] { padding: .48rem; background: var(--surface-muted); }
.inline-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: .45rem; }
.inline-actions input { min-width: 180px; flex: 1; }
.assessment-list { display: grid; gap: .75rem; }
.assessment { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(240px, .7fr); gap: 1.2rem; padding: 1rem; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-muted); }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.three-column { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: start; }
pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
pre { max-width: 100%; overflow: auto; padding: .85rem; border-radius: 8px; color: #dfe8f7; background: #101827; font-size: .78rem; }

.alert { margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid; border-radius: 10px; }
.alert-success { color: #086345; border-color: #a7dfca; background: #e5f8f1; }
.alert-error { color: #9f2030; border-color: #f1b9c0; background: #fff0f2; }
.alert-warning { color: #7f4a00; border-color: #f0d18d; background: #fff8e7; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 1.25rem; background: radial-gradient(circle at 20% 20%, #dff7f3 0, transparent 34%), var(--bg); }
.login-shell { width: min(440px, 100%); margin: 0; padding: 2rem; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.5rem; }
.login-brand img { width: 48px; height: 48px; }
.login-shell h1 { margin: 0 0 .35rem; font-size: 1.7rem; }
.login-shell > p { color: var(--ink-soft); }
.login-language { margin-bottom: 1rem; }
.login-language label { display: grid; gap: .25rem; color: var(--ink-soft); font-size: .82rem; font-weight: 650; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .three-column { grid-template-columns: 1fr; }
}

@media (max-width: 840px) {
  .app-sidebar { transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .nav-open .app-sidebar { transform: translateX(0); }
  .nav-backdrop { position: fixed; inset: 0; z-index: 30; display: block; visibility: hidden; opacity: 0; background: rgba(5,12,25,.48); transition: opacity .2s ease, visibility .2s; }
  .nav-open .nav-backdrop { visibility: visible; opacity: 1; }
  .app-main { margin-left: 0; }
  .app-topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 62px; padding: .65rem 1rem; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
  .nav-toggle { width: 42px; padding: 0; color: var(--ink); background: #fff; border-color: var(--line); box-shadow: none; }
  .nav-toggle:hover { color: var(--ink); background: var(--surface-muted); box-shadow: none; }
  .mobile-brand { display: flex; align-items: center; gap: .55rem; color: var(--ink); font-weight: 750; text-decoration: none; }
  .mobile-brand img { width: 32px; height: 32px; }
  .app-content { padding-top: 1.35rem; }
  .dashboard-grid, .two-column { grid-template-columns: 1fr; }
  .assessment { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .page-heading { display: grid; }
  .page-actions { justify-content: flex-start; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card:last-child { grid-column: 1 / -1; }
  .app-content { padding-inline: .8rem; }
  .panel, section { padding: 1rem; border-radius: 11px; }
  th, td { white-space: nowrap; }
  .readiness-summary { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}


.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, .6fr) auto; gap: .8rem; align-items: end; }
.filter-bar label { display: grid; gap: .35rem; color: #45536a; font-size: .82rem; font-weight: 650; }
.filter-actions { display: flex; gap: .5rem; }
.audit-list { display: grid; }
.audit-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.audit-row:last-child { border-bottom: 0; }
.audit-time { color: var(--ink-soft); font-size: .82rem; font-variant-numeric: tabular-nums; }
.audit-event { min-width: 0; }
.audit-event > small { display: block; margin-top: .12rem; }
.audit-details { display: flex; flex-wrap: wrap; gap: .45rem .85rem; margin: .7rem 0 0; }
.audit-details div { display: flex; gap: .35rem; min-width: 0; }
.audit-details dt { color: var(--ink-soft); font-size: .74rem; font-weight: 700; }
.audit-details dd { margin: 0; overflow-wrap: anywhere; font-size: .8rem; }
.error-state { display: grid; place-items: center; min-height: min(62vh, 620px); text-align: center; }
.error-state .error-code { color: var(--primary); font-size: clamp(3.5rem, 12vw, 8rem); font-weight: 850; line-height: .9; letter-spacing: -.08em; }
.error-state h1 { margin: 1rem 0 .5rem; }
.error-state p { max-width: 560px; color: var(--ink-soft); }
.error-state small { margin-top: 1rem; }
@media (max-width: 720px) {
  .filter-bar { grid-template-columns: 1fr; }
  .filter-actions { flex-wrap: wrap; }
  .audit-row { grid-template-columns: 1fr; gap: .35rem; }
}

/* Grid children with wide tables must be allowed to shrink so horizontal
   scrolling stays inside the table wrapper instead of widening the page. */
.app-main,
.app-content,
.dashboard-grid,
.dashboard-grid > *,
.two-column,
.two-column > *,
.three-column,
.three-column > *,
.panel,
section,
.data-table-wrap {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 620px) {
  .data-table { min-width: 700px; }
}

.program-list small {
  display: block;
  margin-top: .25rem;
}

.data-table th:first-child,
.data-table td:first-child {
  white-space: nowrap;
}
