:root {
  --navy-950: #0b1628;
  --navy-900: #12213a;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --green-700: #047857;
  --green-600: #059669;
  --green-100: #d1fae5;
  --red-700: #b91c1c;
  --red-100: #fee2e2;
  --amber-800: #92400e;
  --amber-100: #fef3c7;
  --radius: 14px;
  --shadow: 0 8px 30px rgb(15 23 42 / 7%);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--navy-950); background: var(--slate-50); }
body { margin: 0; min-width: 320px; line-height: 1.5; }
a { color: inherit; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgb(5 150 105 / 35%); outline-offset: 2px; }

.skip-link { position: fixed; z-index: 100; left: 1rem; top: -5rem; padding: .7rem 1rem; background: white; border-radius: 8px; }
.skip-link:focus { top: 1rem; }
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.5rem; background: var(--navy-950); color: white; }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: white; font-weight: 800; font-size: 1.2rem; text-decoration: none; letter-spacing: -.02em; }
.brand > span, .login-brand span { display: grid; place-items: center; width: 2.15rem; height: 2.15rem; border-radius: 10px; color: white; background: var(--green-600); }
.nav-list { display: grid; gap: .3rem; margin-top: 2.3rem; }
.nav-list a { padding: .75rem .85rem; color: var(--slate-300); border-radius: 9px; text-decoration: none; font-weight: 600; }
.nav-list a:hover, .nav-list a:focus-visible { color: white; background: rgb(255 255 255 / 8%); }
.nav-logout { display: none; }
.sidebar-user { margin-top: auto; padding-top: 1.2rem; border-top: 1px solid rgb(255 255 255 / 12%); font-size: .9rem; }
.sidebar-user .muted { color: #94a3b8; }
.link-button { margin: .55rem 0 0; padding: 0; border: 0; color: #a7f3d0; background: transparent; cursor: pointer; }
.mobile-header { display: none; }
.content { width: min(1480px, 100%); padding: clamp(1.4rem, 3vw, 3.5rem); }

.page-header { display: flex; justify-content: space-between; gap: 2rem; align-items: flex-start; margin-bottom: 2rem; }
h1, h2 { margin: 0; letter-spacing: -.035em; line-height: 1.15; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: 1.25rem; }
.eyebrow { margin: 0 0 .4rem; color: var(--green-700); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.lead { max-width: 680px; margin: .65rem 0 0; color: var(--slate-500); font-size: 1.02rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: .65rem; flex: 0 0 auto; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: .62rem .95rem; border: 1px solid transparent; border-radius: 9px; font-weight: 700; font-size: .9rem; text-decoration: none; cursor: pointer; }
.button-primary { color: white; border-color: var(--green-700); background: var(--green-700); }
.button-primary:hover { background: #065f46; }
.button-quiet { color: var(--slate-700); border-color: var(--slate-300); background: white; }
.button-block { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: .85rem; }
.metric-card { min-height: 142px; padding: 1.1rem; border: 1px solid var(--slate-200); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.metric-card > span, .metric-card > small { display: block; color: var(--slate-500); }
.metric-card > span { font-size: .86rem; font-weight: 700; }
.metric-card > strong { display: block; margin: .3rem 0 .2rem; font-size: 2rem; letter-spacing: -.04em; }
.metric-card > small { font-size: .78rem; }
.metric-primary { color: white; border-color: var(--navy-900); background: var(--navy-900); }
.metric-primary > span, .metric-primary > small { color: var(--slate-300); }
.metric-success > strong { color: var(--green-700); }
.metric-danger > strong { color: var(--red-700); }
.formula-note { margin: .7rem .2rem 2rem; color: var(--slate-500); font-size: .78rem; }

.section-card { margin: 1.2rem 0; overflow: hidden; border: 1px solid var(--slate-200); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.25rem; border-bottom: 1px solid var(--slate-200); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { color: var(--slate-500); background: var(--slate-50); font-size: .74rem; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
th, td { padding: .85rem 1.25rem; border-bottom: 1px solid var(--slate-200); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfc; }
td small { display: block; margin-top: .12rem; color: var(--slate-500); }
.table-link { font-weight: 700; text-decoration: none; }
.table-link:hover { color: var(--green-700); text-decoration: underline; }
.status { display: inline-block; padding: .24rem .58rem; border-radius: 999px; white-space: nowrap; font-size: .76rem; font-weight: 800; }
.status-passed { color: var(--green-700); background: var(--green-100); }
.status-failed { color: var(--red-700); background: var(--red-100); }
.status-pending { color: var(--amber-800); background: var(--amber-100); }
.status-cancelled { color: var(--slate-700); background: var(--slate-200); }
.status-manual_review { color: var(--amber-800); background: var(--amber-100); }
.muted { color: var(--slate-500); }

.filter-panel { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); gap: .85rem; margin-bottom: 1.25rem; padding: 1rem; border: 1px solid var(--slate-200); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.field { display: grid; gap: .35rem; }
.field-wide { grid-column: span 2; }
.field label { color: var(--slate-700); font-size: .78rem; font-weight: 800; }
.field input, .field select, .simple-search input { width: 100%; height: 42px; padding: 0 .7rem; border: 1px solid var(--slate-300); border-radius: 8px; color: var(--navy-950); background: white; }
.field input:hover, .field select:hover, .simple-search input:hover { border-color: var(--slate-500); }
.filter-actions { display: flex; align-items: end; gap: .45rem; }
.simple-search { display: flex; gap: .6rem; max-width: 580px; margin-bottom: 1.3rem; }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .85rem; margin-top: 1.2rem; }
.quick-actions a { display: grid; padding: 1rem 1.1rem; border: 1px solid var(--slate-200); border-radius: 11px; background: white; text-decoration: none; }
.quick-actions a:hover { border-color: var(--green-600); }
.quick-actions span { margin-top: .2rem; color: var(--slate-500); font-size: .82rem; }
.card-list { display: grid; gap: .65rem; }
.entity-card { display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; padding: .9rem 1rem; border: 1px solid var(--slate-200); border-radius: 11px; background: white; box-shadow: 0 3px 15px rgb(15 23 42 / 4%); text-decoration: none; }
.entity-card:hover { border-color: var(--green-600); transform: translateY(-1px); }
.entity-card small { display: block; margin-top: .15rem; color: var(--slate-500); }
.avatar { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: var(--green-700); background: var(--green-100); font-weight: 900; }
.avatar-exam { color: var(--navy-900); background: var(--slate-200); }
.count { color: var(--slate-500); font-size: .82rem; }
.pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 1rem 1.25rem; color: var(--slate-500); font-size: .85rem; }
.pagination a { color: var(--green-700); font-weight: 800; text-decoration: none; }
.pagination a:last-child { justify-self: end; }
.breadcrumbs { display: flex; gap: .45rem; margin-bottom: 1rem; color: var(--slate-500); font-size: .83rem; }
.breadcrumbs a { color: var(--green-700); }

.timeline { margin: 0; padding: 1.2rem 1.3rem; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 16px 1fr; gap: .8rem; padding-bottom: 1.25rem; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 13px; bottom: -1px; width: 2px; background: var(--slate-200); }
.timeline-marker { z-index: 1; width: 12px; height: 12px; margin-top: .3rem; border: 3px solid var(--green-600); border-radius: 50%; background: white; }
.timeline-title { display: flex; justify-content: space-between; gap: 1rem; }
.timeline-title time { color: var(--slate-500); font-size: .82rem; white-space: nowrap; }
.timeline-content > p { margin: .25rem 0; color: var(--slate-500); }
.timeline-content .event-text { margin-top: .55rem; padding: .65rem .8rem; color: var(--slate-700); border-radius: 8px; background: var(--slate-50); white-space: pre-wrap; overflow-wrap: anywhere; }
.tag { display: inline-block; padding: .15rem .45rem; color: var(--amber-800); border-radius: 999px; background: var(--amber-100); font-size: .72rem; font-weight: 800; }
.source { margin-top: .5rem; color: var(--slate-500); font-size: .84rem; }
.source p { padding: .6rem .8rem; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--slate-50); border-radius: 8px; }
.empty-state { padding: 2.8rem 1.2rem; color: var(--slate-500); text-align: center; }
.empty-state strong { color: var(--navy-950); }
.empty-state p { margin: .35rem 0 0; }
.empty-state.compact { padding: 2rem 1rem; }

.auth-shell { display: grid; place-items: center; min-height: 100vh; padding: 1.2rem; background: radial-gradient(circle at top left, #d1fae5 0, transparent 32%), var(--slate-100); }
.login-card { width: min(430px, 100%); padding: clamp(1.5rem, 5vw, 2.5rem); border: 1px solid var(--slate-200); border-radius: 18px; background: white; box-shadow: 0 20px 50px rgb(15 23 42 / 12%); }
.login-brand { margin-bottom: 1.5rem; }
.login-brand span { width: 2.8rem; height: 2.8rem; font-size: 1.2rem; font-weight: 900; }
.login-form { display: grid; gap: 1rem; margin-top: 1.5rem; }
.login-help { margin: 1.2rem 0 0; color: var(--slate-500); font-size: .78rem; text-align: center; }
.alert { margin-top: 1rem; padding: .75rem; color: var(--red-700); border: 1px solid #fecaca; border-radius: 8px; background: #fef2f2; font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .filter-panel { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
  .app-shell { display: block; min-height: auto; }
  .sidebar { display: none; }
  .mobile-header { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: .7rem 1rem; background: var(--navy-950); }
  .mobile-nav { color: white; }
  .mobile-nav summary { padding: .45rem .65rem; border: 1px solid rgb(255 255 255 / 25%); border-radius: 7px; cursor: pointer; list-style: none; }
  .mobile-nav[open] .nav-list { position: absolute; top: 56px; right: .7rem; width: min(260px, calc(100vw - 1.4rem)); margin: 0; padding: .7rem; border-radius: 10px; background: var(--navy-900); box-shadow: 0 18px 40px rgb(0 0 0 / 30%); }
  .mobile-header .nav-logout { display: block; }
  .mobile-header .nav-logout button { width: 100%; padding: .75rem .85rem; border: 0; color: #a7f3d0; border-radius: 9px; background: transparent; font-weight: 700; text-align: left; cursor: pointer; }
  .content { padding: 1.2rem 1rem 2rem; }
  .page-header { display: grid; gap: 1rem; margin-bottom: 1.4rem; }
  .page-actions { width: 100%; }
  .page-actions .button { flex: 1; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-primary { grid-column: span 2; }
  .filter-panel { grid-template-columns: repeat(2, 1fr); }
  .field-wide { grid-column: span 2; }
  .quick-actions { grid-template-columns: 1fr; }
  th, td { padding: .75rem .85rem; }
}

@media (max-width: 460px) {
  .metric-grid, .filter-panel { grid-template-columns: 1fr; }
  .metric-primary, .field-wide { grid-column: auto; }
  .filter-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .simple-search { display: grid; }
  .entity-card { grid-template-columns: auto 1fr; }
  .entity-card .count { grid-column: 2; }
  .timeline-title { display: grid; gap: .1rem; }
}

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