:root {
  --ink:        #1B2A4A;
  --ink-deep:   #101A2E;
  --paper:      #FAF8F3;
  --paper-dim:  #F1EEE5;
  --line:       #DAD4C4;
  --brass:      #5B6EAE;
  --brass-deep: #414F82;
  --pass:       #2F6B4F;
  --pass-bg:    #E7EFEA;
  --fail:       #A13D3D;
  --fail-bg:    #F3E6E4;
  --text:       #16202E;
  --text-soft:  #4B5568;
  --text-faint: #85899a;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "IBM Plex Sans", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  --radius: 3px;
  --shadow-card: 0 1px 2px rgba(16,26,46,0.06), 0 1px 12px rgba(16,26,46,0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--text); font-family: var(--font-body); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; text-decoration: none; }
button, input, select { font-family: inherit; font-size: inherit; }
::selection { background: var(--brass); color: var(--paper); }
:focus-visible { outline: 2px solid var(--brass-deep); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 32px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.brand-mark { color: var(--brass-deep); display: flex; }
.brand-word { font-family: var(--font-display); font-weight: 600; font-size: 19px; letter-spacing: 0.01em; }
.topbar-nav { display: flex; align-items: center; gap: 22px; font-size: 14px; color: var(--text-soft); }
.topbar-nav a, .topbar-nav button.link { color: var(--text-soft); background: none; border: none; cursor: pointer; font-size: 14px; padding: 0; }
.topbar-nav a:hover, .topbar-nav button.link:hover { color: var(--ink); }
.pill { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; padding: 4px 10px; border-radius: 20px; background: var(--paper-dim); border: 1px solid var(--line); color: var(--text-soft); }

#app { flex: 1; }
.container { max-width: 1040px; margin: 0 auto; padding: 0 32px; }
.sitefooter { border-top: 1px solid var(--line); padding: 22px 32px; font-size: 12.5px; color: var(--text-faint); text-align: center; }

.hero { padding: 84px 32px 64px; border-bottom: 1px solid var(--line); position: relative; overflow: hidden; }
.hero-inner { max-width: 1040px; margin: 0 auto; display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 56px; align-items: center; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brass-deep); margin: 0 0 18px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(36px, 4.4vw, 56px); line-height: 1.06; font-weight: 600; margin: 0 0 22px; color: var(--ink); }
.hero h1 em { font-style: italic; color: var(--brass-deep); }
.hero p.lede { font-size: 17px; line-height: 1.6; color: var(--text-soft); max-width: 46ch; margin: 0 0 32px; }
.hero-form { display: flex; gap: 0; max-width: 460px; border: 1.5px solid var(--ink); border-radius: var(--radius); overflow: hidden; background: var(--paper); }
.hero-note { font-size: 12.5px; color: var(--text-faint); margin-top: 10px; }
.seal-display { display: flex; align-items: center; justify-content: center; }

.stamp { --stamp-color: var(--ink); width: 168px; height: 168px; border-radius: 50%; border: 3px solid var(--stamp-color); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--stamp-color); transform: rotate(-7deg); position: relative; font-family: var(--font-mono); flex-shrink: 0; }
.stamp::before { content: ""; position: absolute; inset: 10px; border: 1px solid var(--stamp-color); border-radius: 50%; opacity: 0.55; }
.stamp .stamp-grade { font-family: var(--font-display); font-size: 34px; font-weight: 700; line-height: 1.1; text-align: center; }
.stamp .stamp-label { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; margin-top: 4px; }
.stamp.exempt { --stamp-color: var(--pass); }
.stamp.liable { --stamp-color: var(--fail); }
.stamp-lg { width: 148px; height: 148px; }
.stamp-lg .stamp-grade { font-size: 38px; }

.section { padding: 64px 32px; }
.section-head { margin-bottom: 40px; }
.section-head .eyebrow { margin-bottom: 10px; }
.section-head h2 { font-family: var(--font-display); font-size: 30px; font-weight: 600; color: var(--ink); margin: 0; }

.checklist { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); max-width: 1040px; margin: 0 auto; }
.checklist-item { background: var(--paper); padding: 22px 26px; display: flex; gap: 14px; }
.checklist-num { font-family: var(--font-mono); font-size: 12px; color: var(--brass-deep); padding-top: 2px; flex-shrink: 0; }
.checklist-item h3 { font-family: var(--font-body); font-size: 14.5px; font-weight: 600; margin: 0 0 4px; color: var(--ink); }
.checklist-item p { font-size: 13.5px; color: var(--text-soft); margin: 0; line-height: 1.5; }

.auth-wrap { padding: 72px 24px; min-height: 60vh; display: flex; align-items: flex-start; justify-content: center; }
.auth-card { width: 100%; max-width: 420px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 36px 32px; box-shadow: var(--shadow-card); }
.auth-card h1 { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin: 0 0 6px; color: var(--ink); }
.auth-card .sub { font-size: 13.5px; color: var(--text-soft); margin: 0 0 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-dim); font-size: 14.5px; color: var(--text); }
.field input:focus, .field select:focus { outline: none; border-color: var(--ink); background: var(--paper); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: var(--radius); border: none; font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.15s ease; }
.btn-primary { background: var(--ink); color: var(--paper); width: 100%; }
.btn-primary:hover { background: var(--ink-deep); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: none; border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--ink); }
.auth-switch { margin-top: 18px; font-size: 13.5px; color: var(--text-soft); text-align: center; }
.auth-switch button { background: none; border: none; color: var(--brass-deep); font-weight: 600; cursor: pointer; padding: 0; font-size: 13.5px; }
.error-box { background: var(--fail-bg); border: 1px solid var(--fail); color: var(--fail); padding: 10px 13px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }

.dash-head { padding: 40px 32px 28px; border-bottom: 1px solid var(--line); }
.dash-head-row { display: flex; justify-content: space-between; align-items: flex-end; max-width: 1040px; margin: 0 auto; gap: 24px; flex-wrap: wrap; }
.dash-head h1 { font-family: var(--font-display); font-size: 28px; font-weight: 600; margin: 0 0 6px; color: var(--ink); }
.dash-head .sub { font-size: 13.5px; color: var(--text-soft); margin: 0; }
.usage-meter { min-width: 220px; }
.usage-meter .num { font-family: var(--font-mono); font-size: 13px; color: var(--text-soft); margin-bottom: 6px; display: flex; justify-content: space-between; }
.usage-track { height: 6px; background: var(--paper-dim); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.usage-fill { height: 100%; background: var(--brass); }
.dash-body { padding: 36px 32px 80px; }

.calc-form { max-width: 1040px; margin: 0 auto 32px; border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 24px; background: var(--paper); }
.calc-form h3 { font-family: var(--font-display); font-size: 18px; margin: 0 0 16px; color: var(--ink); }
.calc-form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-soft); margin-bottom: 14px; }

.scan-list { max-width: 1040px; margin: 0 auto; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.scan-row { display: grid; grid-template-columns: 40px 1fr 110px 120px 140px; align-items: center; padding: 16px 20px; background: var(--paper); border-bottom: 1px solid var(--line); cursor: pointer; transition: background 0.12s ease; gap: 12px; }
.scan-row:last-child { border-bottom: none; }
.scan-row:hover { background: var(--paper-dim); }
.scan-row .grade-chip { width: 34px; height: 34px; border-radius: 50%; border: 2px solid currentColor; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 700; font-size: 10px; }
.grade-chip.exempt { color: var(--pass); }
.grade-chip.liable { color: var(--fail); }
.grade-chip.grade-none { color: var(--text-faint); border-style: dashed; }
.scan-row .url { font-size: 14.5px; color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-tag { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 3px 8px; border-radius: 3px; width: fit-content; }
.status-tag.calculated { background: var(--pass-bg); color: var(--pass); }
.status-tag.failed { background: var(--fail-bg); color: var(--fail); }
.scan-row .date { font-size: 12.5px; color: var(--text-faint); font-family: var(--font-mono); }
.empty-state { padding: 64px 24px; text-align: center; color: var(--text-faint); }
.empty-state .big { font-family: var(--font-display); font-size: 20px; color: var(--text-soft); margin-bottom: 6px; }

.scan-detail-head { padding: 40px 32px 32px; border-bottom: 1px solid var(--line); }
.scan-detail-inner { max-width: 1040px; margin: 0 auto; display: flex; gap: 36px; align-items: center; flex-wrap: wrap; }
.scan-detail-meta { flex: 1; min-width: 260px; }
.scan-detail-meta .back-link { font-size: 13px; color: var(--text-soft); margin-bottom: 14px; display: inline-block; }
.scan-detail-meta .back-link:hover { color: var(--ink); }
.scan-detail-meta h1 { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin: 0 0 8px; color: var(--ink); word-break: break-word; }
.score-line { font-family: var(--font-mono); font-size: 13.5px; color: var(--text-soft); }
.scan-detail-actions { display: flex; gap: 10px; }

.rules-section { padding: 40px 32px 80px; }
.rules-inner { max-width: 1040px; margin: 0 auto; }
.rule-card { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 10px; background: var(--paper); }
.rule-card.pass { border-left-color: var(--pass); }
.rule-card.fail { border-left-color: var(--fail); }
.rule-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; }
.rule-id { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-faint); }
.rule-name { font-size: 15px; font-weight: 600; color: var(--ink); flex: 1; }
.rule-status { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; }
.rule-status.pass { color: var(--pass); }
.rule-status.fail { color: var(--fail); }
.rule-evidence { font-size: 13px; color: var(--text-soft); line-height: 1.5; }
.severity-tag { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; color: var(--text-faint); }
.recs-box { background: var(--paper-dim); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-top: 28px; }
.recs-box h3 { font-family: var(--font-display); font-size: 17px; margin: 0 0 12px; color: var(--ink); }
.recs-box ol, .recs-box ul { margin: 0; padding-left: 20px; }
.recs-box li { font-size: 13.5px; color: var(--text-soft); margin-bottom: 8px; line-height: 1.5; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); max-width: 1040px; margin: 0 auto 24px; }
.metric-card { background: var(--paper); padding: 20px 22px; }
.metric-card .metric-label { font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); margin: 0 0 6px; }
.metric-card .metric-value { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--ink); margin: 0; }

.loading-row { display: flex; align-items: center; gap: 10px; padding: 40px; justify-content: center; color: var(--text-faint); font-size: 13.5px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--brass-deep); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ISO 42001 specific ---------- */

.domain-group {
  max-width: 1040px;
  margin: 0 auto 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.domain-group-head {
  background: var(--paper-dim);
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.domain-group-head h3 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0 0 4px;
  color: var(--ink);
}

.domain-group-head p {
  font-size: 12.5px;
  color: var(--text-soft);
  margin: 0;
}

.control-row {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.control-row:last-child { border-bottom: none; }

.control-row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.control-row .control-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.control-row .control-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 2px 0 4px;
}

.control-row .control-question {
  font-size: 13px;
  color: var(--text-soft);
  margin: 0;
}

.status-select {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--paper);
  color: var(--text);
  flex-shrink: 0;
}
.status-select.st-implemented { border-color: var(--pass); color: var(--pass); }
.status-select.st-in_progress { border-color: var(--brass-deep); color: var(--brass-deep); }
.status-select.st-not_applicable { border-color: var(--text-faint); color: var(--text-faint); }

.control-notes-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--paper-dim);
  margin-top: 6px;
}
.control-notes-input:focus { outline: none; border-color: var(--ink); background: var(--paper); }

.maturity-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid currentColor;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.evidence-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--paper);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.evidence-card .evidence-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.evidence-card .evidence-meta {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.policy-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  background: var(--paper);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.policy-card h4 {
  font-family: var(--font-display);
  font-size: 15px;
  margin: 0;
  color: var(--ink);
}

@media (max-width: 760px) {
  .hero-inner { grid-template-columns: 1fr; }
  .seal-display { order: -1; justify-content: flex-start; }
  .checklist { grid-template-columns: 1fr; }
  .calc-form-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .scan-row { grid-template-columns: 32px 1fr; grid-template-areas: "grade url" "grade status" "grade date"; row-gap: 4px; }
  .scan-row .status-tag, .scan-row .date { grid-column: 2; }
  .control-row-top { flex-direction: column; }
  .topbar { padding: 14px 18px; }
  .topbar-nav { gap: 14px; font-size: 13px; }
  .hero, .section, .dash-head, .dash-body, .scan-detail-head, .rules-section { padding-left: 18px; padding-right: 18px; }
}
