/* ETL Compliance Portal — site stylesheet.
   Derived from the approved Phase 0 mockups (mockups/assets/mock.css). No CSS framework. */

:root {
  --ink: #1F2933;
  --ink-2: #323F4B;
  --slate: #52606D;
  --slate-2: #7B8794;
  --mist: #E4E7EB;
  --mist-2: #CBD2D9;
  --paper: #F7F8F9;
  --white: #FFFFFF;
  --accent: #1F4FD8;
  --accent-soft: #E8EEFC;
  --pass: #1E7F4F;
  --pass-soft: #E3F3EA;
  --due: #B7791F;
  --due-soft: #FBF1DC;
  --fail: #B42318;
  --fail-soft: #FBE7E5;
  --sidebar-w: 240px;
  --radius: 4px;
  --font: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink);
  color: var(--mist);
  padding: 20px 0 24px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 18px;
  border-bottom: 1px solid var(--ink-2);
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 3px;
  background: var(--mist); color: var(--ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.brand-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.brand-sub  { font-size: 11px; color: var(--slate-2); white-space: nowrap; }

.nav-group { padding: 14px 12px 4px; }
.nav-group-title { font-size: 12px; color: var(--slate-2); padding: 0 8px 6px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border-radius: var(--radius);
  color: var(--mist); font-size: 14px;
}
.nav a:hover { background: var(--ink-2); text-decoration: none; }
.nav a.active { background: var(--white); color: var(--ink); font-weight: 600; }
.nav .count {
  font-size: 12px; background: var(--ink-2); color: var(--mist);
  padding: 0 7px; border-radius: 10px; line-height: 18px;
}
.nav a.active .count { background: var(--accent-soft); color: var(--accent); }
.nav .count.alert { background: var(--fail); color: #fff; }

.content { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 32px; background: var(--white);
  border-bottom: 1px solid var(--mist);
}
.topbar-title { font-size: 20px; font-weight: 600; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--slate); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--mist); color: var(--ink);
  display: grid; place-items: center; font-weight: 600; font-size: 12px;
}
.role-badge {
  font-size: 12px; padding: 2px 8px; border-radius: 10px;
  border: 1px solid var(--mist-2); color: var(--slate);
}
main { padding: 28px 32px 48px; max-width: 1280px; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.01em; }
.page-head p.lede { margin: 0; color: var(--slate); max-width: 68ch; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* CE clause references — structural, not decorative */
.ce-refs { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ce-ref {
  font-size: 12px; color: var(--slate);
  border: 1px solid var(--mist-2); border-left: 3px solid var(--accent);
  padding: 1px 7px 1px 6px; border-radius: 2px; background: var(--white);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--mist-2); background: var(--white); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--paper); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1840B3; }
.btn-danger { color: var(--fail); border-color: var(--fail); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-link { border-color: transparent; background: transparent; color: var(--accent); padding-left: 4px; padding-right: 4px; }

/* ---------- status stamps ---------- */
.stamp {
  display: inline-block; font-size: 12px; font-weight: 600;
  padding: 2px 8px 2px 7px; border-radius: 2px;
  border: 1px solid; border-left-width: 3px; white-space: nowrap;
}
.stamp-pass  { color: var(--pass); background: var(--pass-soft); border-color: var(--pass); }
.stamp-due   { color: var(--due);  background: var(--due-soft);  border-color: var(--due); }
.stamp-fail  { color: var(--fail); background: var(--fail-soft); border-color: var(--fail); }
.stamp-info  { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.stamp-muted { color: var(--slate); background: var(--white); border-color: var(--mist-2); }

/* ---------- filter bar ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  padding: 14px 16px; margin-bottom: 16px;
  background: var(--white); border: 1px solid var(--mist); border-radius: var(--radius);
}
.filters .field { margin: 0; min-width: 160px; }
.filters .spacer { flex: 1; }

/* ---------- tables ---------- */
.table-wrap { background: var(--white); border: 1px solid var(--mist); border-radius: var(--radius); overflow-x: auto; }
table.register { width: 100%; border-collapse: collapse; font-size: 14px; }
.register th {
  text-align: left; font-weight: 600; color: var(--slate);
  padding: 10px 14px; border-bottom: 2px solid var(--mist-2);
  background: var(--paper); white-space: nowrap;
}
.register td { padding: 10px 14px; border-bottom: 1px solid var(--mist); vertical-align: top; }
.register tbody tr:last-child td { border-bottom: 0; }
.register tbody tr:hover td { background: #FAFBFC; }
.register .num { text-align: right; }
.register .muted { color: var(--slate-2); }
.register .cell-sub { display: block; font-size: 12px; color: var(--slate-2); margin-top: 1px; }
.register tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--fail); }
.register tr.attention td:first-child { box-shadow: inset 3px 0 0 var(--due); }
.table-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; font-size: 13px; color: var(--slate);
  border-top: 1px solid var(--mist);
}
.pager { display: flex; gap: 4px; }
.pager a, .pager span { padding: 2px 8px; border: 1px solid var(--mist-2); border-radius: 3px; color: var(--ink); }
.pager span.current { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- cards & panels ---------- */
.panel { background: var(--white); border: 1px solid var(--mist); border-radius: var(--radius); padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.panel h2 small { font-weight: 400; color: var(--slate-2); font-size: 13px; margin-left: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.span-2 { grid-column: span 2; }

.count-card { background: var(--white); border: 1px solid var(--mist); border-radius: var(--radius); padding: 14px 16px; }
.count-card .n { font-size: 28px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.count-card .l { font-size: 13px; color: var(--slate); margin-top: 2px; }
.count-card.alert { border-left: 3px solid var(--fail); }
.count-card.warn  { border-left: 3px solid var(--due); }
.count-card.ok    { border-left: 3px solid var(--pass); }

/* ---------- definition lists (record detail) ---------- */
.kv { display: grid; grid-template-columns: 180px 1fr; row-gap: 8px; column-gap: 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--slate); }
.kv dd { margin: 0; }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 5px; }
.field .hint { font-size: 13px; color: var(--slate-2); margin-top: 4px; }
.field .error { font-size: 13px; color: var(--fail); margin-top: 4px; }
.input, select, textarea {
  width: 100%; font: inherit; font-size: 14px; color: var(--ink);
  padding: 7px 10px; border: 1px solid var(--mist-2); border-radius: var(--radius); background: var(--white);
}
textarea { min-height: 96px; resize: vertical; }
.input.invalid { border-color: var(--fail); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin-bottom: 8px; }
.check input { margin-top: 3px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--mist); }
.form-narrow { max-width: 640px; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- workflow steps ---------- */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-bottom: 20px; border: 1px solid var(--mist); border-radius: var(--radius); background: var(--white); overflow: hidden; }
.step { padding: 12px 16px; border-right: 1px solid var(--mist); font-size: 13px; position: relative; }
.step:last-child { border-right: 0; }
.step .step-name { font-weight: 600; font-size: 14px; display: block; }
.step .step-meta { color: var(--slate); display: block; margin-top: 2px; }
.step.done { box-shadow: inset 0 3px 0 var(--pass); }
.step.current { box-shadow: inset 0 3px 0 var(--accent); background: var(--accent-soft); }
.step.todo { color: var(--slate-2); }
.step.todo .step-name { color: var(--slate-2); }

/* ---------- signature pad ---------- */
.sigpad {
  position: relative; background: var(--white);
  border: 1px solid var(--mist-2); border-radius: var(--radius);
  height: 150px; width: 100%; max-width: 520px;
}
.sigpad::before { /* baseline */
  content: ""; position: absolute; left: 24px; right: 24px; bottom: 36px;
  border-bottom: 1px solid var(--mist-2);
}
.sigpad::after { content: "×"; position: absolute; left: 24px; bottom: 40px; color: var(--slate-2); font-size: 18px; }
.sigpad img, .sigpad svg { position: absolute; left: 40px; bottom: 32px; height: 70px; }
.sig-meta { font-size: 13px; color: var(--slate); margin-top: 6px; }
.sig-tools { display: flex; gap: 8px; margin-top: 8px; }

/* ---------- CE readiness grid (dashboard hero) ---------- */
.ce-grid-wrap { background: var(--white); border: 1px solid var(--mist); border-radius: var(--radius); padding: 18px 20px 14px; }
.ce-grid-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.ce-grid-head h2 { margin: 0; font-size: 16px; }
.ce-legend { display: flex; gap: 14px; font-size: 13px; color: var(--slate); }
.ce-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; border-radius: 1px; }
.ce-sections { display: grid; grid-template-columns: repeat(8, 1fr); gap: 14px; }
.ce-section .ce-section-name { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.ce-section .ce-section-sub { font-size: 12px; color: var(--slate-2); margin-bottom: 6px; }
.ce-cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.ce-cell { aspect-ratio: 1; border-radius: 1px; font-size: 0; }
.ce-cell.ready { background: var(--pass); }
.ce-cell.draft { background: #8FCBA8; }
.ce-cell.review { background: var(--due); }
.ce-cell.none, .ce-cell.notstarted { background: var(--mist-2); }
.ce-cell.na { background: var(--white); border: 1px dashed var(--mist-2); }

/* ---------- misc ---------- */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--mist); }
.timeline li { position: relative; padding: 0 0 14px 18px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--slate-2); }
.timeline li.sig::before { background: var(--pass); }
.timeline .when { color: var(--slate-2); font-size: 13px; display: block; }
.notice { padding: 10px 14px; border-radius: var(--radius); font-size: 14px; border: 1px solid; }
.notice-warn { background: var(--due-soft); border-color: var(--due); color: #6B4A0E; }
.notice-fail { background: var(--fail-soft); border-color: var(--fail); color: #7A1710; }
.notice-info { background: var(--accent-soft); border-color: var(--accent); color: #163A9C; }
.empty { padding: 36px; text-align: center; color: var(--slate); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--mist); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--slate); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(31,41,51,.45); display: grid; place-items: center; }
.modal { background: var(--white); border-radius: var(--radius); width: 720px; max-width: 94vw; max-height: 86vh; overflow: auto; padding: 20px 24px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h2 { margin: 0 0 12px; font-size: 18px; }
kbd { font: inherit; font-size: 12px; border: 1px solid var(--mist-2); border-bottom-width: 2px; border-radius: 3px; padding: 0 5px; }

/* ---------- login page ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-left { background: var(--ink); color: var(--mist); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-left h1 { font-size: 30px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 12px; max-width: 18ch; line-height: 1.15; }
.login-left p { color: var(--slate-2); max-width: 44ch; }
.login-right { display: grid; place-items: center; padding: 48px; }
.login-card { width: 380px; }
.login-card h2 { font-size: 20px; margin: 0 0 6px; }
.btn-google { width: 100%; justify-content: center; padding: 10px; }

/* ---------- print ---------- */
@media print {
  .sidebar, .topbar, .page-actions, .filters, .pager { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  main { padding: 0; max-width: none; }
  .table-wrap, .panel { border: 0; }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .ce-sections { grid-template-columns: repeat(4, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 56px; }
  .brand-name, .brand-sub, .nav-group-title, .nav a span.label, .nav .count { display: none; }
  .nav a { justify-content: center; padding: 10px; }
  .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  main, .topbar { padding-left: 16px; padding-right: 16px; }
  .grid-2, .grid-3, .grid-4, .inline-fields, .steps { grid-template-columns: 1fr; }
  .step { border-right: 0; border-bottom: 1px solid var(--mist); }
  .kv { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-left { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a { transition: background-color .12s ease; }
}

/* ---------- app-only additions ---------- */
.inline-form { display: inline; margin: 0; }
.nav a.todo { color: var(--slate-2); cursor: default; }
.nav a.todo:hover { background: transparent; }

.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- CE question pages ---------- */
.muted { color: var(--slate-2); }
.prewrap { white-space: pre-line; }
.label-note { font-weight: 400; color: var(--slate-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inline-form select { width: auto; }
.register td.actions { white-space: nowrap; }
.register td.actions .btn-link { padding: 0; font-size: 14px; }
.timeline details summary { cursor: pointer; color: var(--accent); }
.timeline .version-text { margin-top: 6px; padding: 8px 10px; background: var(--paper); border-radius: var(--radius); }
.modal-backdrop { z-index: 50; }
.modal-backdrop[hidden] { display: none; }
