/* =========================================================================
   mAIb Deliverability Repair — interface styles.

   Direction: diagnostic precision. The result is the product, so the page is
   built to make a record, a status and a reason legible at a glance, on a
   phone, in a hurry. Severity is never carried by colour alone: every state
   has a glyph and a word, because a red dot means nothing to a colour-blind
   sysadmin and nothing at all when printed.
   ========================================================================= */

:root {
  --ink:        #16181d;
  --ink-2:      #454c59;
  --muted:      #656d7b;
  --faint:      #8a93a2;
  --bg:         #fbfbfa;
  --surface:    #ffffff;
  --surface-2:  #f5f6f7;
  --border:     #e3e6ea;
  --border-2:   #d2d7de;

  --accent:     #1f5fd9;
  --accent-ink: #17439b;
  --accent-bg:  #eef3fd;

  --critical:    #b42318;
  --critical-bg: #fef3f2;
  --high:        #c2410c;
  --high-bg:     #fff5ed;
  --medium:      #96690b;
  --medium-bg:   #fffaeb;
  --low:         #475467;
  --low-bg:      #f4f5f7;
  --info:        #475467;
  --info-bg:     #f4f5f7;
  --unknown:     #6539b8;
  --unknown-bg:  #f6f3fd;
  --ok:          #027a48;
  --ok-bg:       #f0fdf6;

  --radius:   10px;
  --radius-s: 6px;
  --shadow:   0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  --shadow-l: 0 4px 6px -2px rgba(16,24,40,.03), 0 12px 16px -4px rgba(16,24,40,.08);

  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;

  --maxw: 1060px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; font-weight: 620; letter-spacing: -.015em; }
h1 { font-size: clamp(1.75rem, 4.2vw, 2.6rem); letter-spacing: -.028em; }
h2 { font-size: clamp(1.3rem, 2.6vw, 1.6rem); letter-spacing: -.02em; }
h3 { font-size: 1.08rem; }
h4 { font-size: .95rem; }
p  { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

code, kbd, samp, pre { font-family: var(--mono); font-size: .875em; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 720px; margin: 0 auto; padding: 0 20px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--radius-s) 0;
}
.skip-link:focus { left: 0; }

/* ------------------------------------------------------------------ nav -- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 40;
}
.site-header .wrap { display: flex; align-items: center; gap: 20px; height: 58px; }
.brand { display: flex; align-items: baseline; gap: 8px; font-weight: 650; color: var(--ink); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand .brand-mark { font-size: 1.06rem; }
.brand .brand-sub { font-size: .78rem; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.site-nav a {
  color: var(--ink-2); font-size: .88rem; font-weight: 500;
  padding: 7px 10px; border-radius: var(--radius-s);
}
.site-nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }

/* --------------------------------------------------------------- footer -- */
.site-footer {
  margin-top: 64px; border-top: 1px solid var(--border);
  background: var(--surface); padding: 32px 0 40px;
  font-size: .85rem; color: var(--muted);
}
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; }
.footer-cols h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: .6em; }
.footer-cols ul { list-style: none; margin: 0; padding: 0; }
.footer-cols li { margin-bottom: 5px; }
.footer-cols a { color: var(--ink-2); }
.footer-note { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); line-height: 1.6; }

/* ----------------------------------------------------------------- hero -- */
.hero { padding: 44px 0 30px; }
.hero h1 { max-width: 17ch; margin-bottom: .35em; }
.hero .sub { font-size: 1.08rem; color: var(--ink-2); max-width: 58ch; margin-bottom: 26px; }

.scan-form { display: flex; gap: 10px; flex-wrap: wrap; max-width: 620px; }
.scan-form .field { flex: 1 1 280px; min-width: 0; }
.scan-input {
  width: 100%; font-family: var(--mono); font-size: 1rem;
  padding: 13px 15px; border: 1.5px solid var(--border-2); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.scan-input::placeholder { color: var(--faint); }
.scan-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); outline: none; }
.scan-input[aria-invalid="true"] { border-color: var(--critical); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: .95rem; font-weight: 560; line-height: 1.2;
  padding: 13px 20px; border-radius: var(--radius); border: 1.5px solid transparent;
  cursor: pointer; transition: background .12s, border-color .12s, color .12s;
  min-height: 44px; text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-2); }
.btn-secondary:hover { background: var(--surface-2); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--accent); padding: 8px 10px; min-height: 36px; }
.btn-ghost:hover { background: var(--accent-bg); text-decoration: none; }
.btn-lg { font-size: 1.02rem; padding: 15px 26px; min-height: 50px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

.reassure { margin-top: 12px; font-size: .86rem; color: var(--muted); }
.reassure strong { color: var(--ink-2); font-weight: 560; }

.form-error {
  margin-top: 10px; color: var(--critical); font-size: .9rem;
  display: flex; gap: 7px; align-items: flex-start;
}

/* ---------------------------------------------------------------- cards -- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 22px; }
.card + .card { margin-top: 16px; }
.card-head {
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 22px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

/* -------------------------------------------------------------- severity -- */
.sev {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .74rem; font-weight: 640; letter-spacing: .045em; text-transform: uppercase;
  padding: 3px 9px 3px 7px; border-radius: 999px; border: 1px solid currentColor;
  white-space: nowrap;
}
.sev::before { font-size: .95em; line-height: 1; font-weight: 700; }
.sev-critical { color: var(--critical); background: var(--critical-bg); }
.sev-critical::before { content: "\2716"; }        /* heavy multiplication x */
.sev-high     { color: var(--high);     background: var(--high-bg); }
.sev-high::before { content: "\26A0"; }            /* warning sign */
.sev-medium   { color: var(--medium);   background: var(--medium-bg); }
.sev-medium::before { content: "\25B2"; }          /* up-pointing triangle */
.sev-low      { color: var(--low);      background: var(--low-bg); }
.sev-low::before { content: "\25CF"; }             /* filled circle */
.sev-info     { color: var(--info);     background: var(--info-bg); }
.sev-info::before { content: "\2139"; }            /* information source */
.sev-unknown  { color: var(--unknown);  background: var(--unknown-bg); }
.sev-unknown::before { content: "?"; }
.sev-pass     { color: var(--ok);       background: var(--ok-bg); }
.sev-pass::before { content: "\2713"; }            /* check mark */

/* ---------------------------------------------------------------- score -- */
.score-hero { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; }
.score-dial { flex: 0 0 auto; text-align: center; }
.score-num {
  font-size: 3.6rem; font-weight: 680; line-height: 1; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.score-den { font-size: 1rem; color: var(--faint); font-weight: 500; }
.score-bar { width: 132px; height: 7px; border-radius: 999px; background: var(--surface-2); margin: 12px auto 6px; overflow: hidden; }
.score-bar span { display: block; height: 100%; border-radius: 999px; }
.tone-critical .score-num, .tone-critical .score-label { color: var(--critical); }
.tone-critical .score-bar span { background: var(--critical); }
.tone-warn .score-num, .tone-warn .score-label { color: var(--high); }
.tone-warn .score-bar span { background: var(--high); }
.tone-ok .score-num, .tone-ok .score-label { color: var(--medium); }
.tone-ok .score-bar span { background: var(--medium); }
.tone-good .score-num, .tone-good .score-label { color: var(--ok); }
.tone-good .score-bar span { background: var(--ok); }
.score-label { font-size: .82rem; font-weight: 620; letter-spacing: .02em; }
.score-body { flex: 1 1 300px; min-width: 0; }
.score-caption { font-size: .82rem; color: var(--muted); margin-top: 10px; }

.issue-counts { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 0; padding: 0; list-style: none; }

/* -------------------------------------------------------------- records -- */
.record {
  font-family: var(--mono); font-size: .82rem; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 10px 12px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  color: var(--ink-2);
}
.record-del { background: var(--critical-bg); border-color: #f3c3bd; color: #7a1a12; }
.record-add { background: var(--ok-bg); border-color: #b7e4cd; color: #04593a; }
.record-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); font-weight: 640; margin-bottom: 5px;
}

.copy-row { display: flex; gap: 8px; align-items: flex-start; }
.copy-row .record { flex: 1 1 auto; min-width: 0; }
.copy-btn {
  flex: 0 0 auto; font-size: .78rem; padding: 7px 11px; border-radius: var(--radius-s);
  border: 1px solid var(--border-2); background: var(--surface); cursor: pointer;
  font-family: inherit; font-weight: 560; color: var(--ink-2); min-height: 34px;
}
.copy-btn:hover { background: var(--surface-2); }
.copy-btn[data-copied="1"] { color: var(--ok); border-color: #b7e4cd; background: var(--ok-bg); }

/* ------------------------------------------------------------- findings -- */
.finding { border-top: 1px solid var(--border); padding: 20px 0; }
.finding:first-child { border-top: 0; padding-top: 0; }
.finding-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.finding-head h3 { margin: 0; flex: 1 1 260px; min-width: 0; }
.finding-rule { font-family: var(--mono); font-size: .74rem; color: var(--faint); }
.finding-why { color: var(--ink-2); }
.finding dl { margin: 14px 0 0; }
.finding dt {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--faint); font-weight: 640; margin-top: 12px;
}
.finding dd { margin: 5px 0 0; }

.locked {
  border: 1px dashed var(--border-2); border-radius: var(--radius-s);
  padding: 12px 14px; background: var(--surface-2); color: var(--muted); font-size: .9rem;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.locked strong { color: var(--ink-2); }

/* ------------------------------------------------------------ readiness -- */
.readiness-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.readiness-card ul { list-style: none; margin: 0; padding: 0; }
.readiness-card li {
  display: flex; gap: 10px; align-items: flex-start; justify-content: space-between;
  padding: 9px 0; border-top: 1px solid var(--border); font-size: .9rem;
}
.readiness-card li:first-child { border-top: 0; }
.readiness-card .rlabel { flex: 1 1 auto; min-width: 0; }
.readiness-card .rstate { flex: 0 0 auto; }
.readiness-card .rreason { display: block; font-size: .8rem; color: var(--muted); margin-top: 3px; }
.readiness-summary { font-size: .89rem; color: var(--ink-2); margin-bottom: 14px; }

/* ------------------------------------------------------------ SPF tree --- */
.spf-tree { font-family: var(--mono); font-size: .8rem; line-height: 1.7; }
.spf-tree .node { display: flex; gap: 8px; align-items: baseline; }
.spf-tree .node-name { color: var(--ink); }
.spf-tree .node-err { color: var(--critical); }
.spf-tree .node-rec { color: var(--faint); }
.lookup-meter { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.lookup-meter .bar { flex: 1 1 160px; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 120px; }
.lookup-meter .bar span { display: block; height: 100%; background: var(--ok); }
.lookup-meter.warn .bar span { background: var(--medium); }
.lookup-meter.over .bar span { background: var(--critical); }
.lookup-meter .count { font-family: var(--mono); font-size: .88rem; font-weight: 600; white-space: nowrap; }

/* ---------------------------------------------------------------- table -- */
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 640; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mono { font-family: var(--mono); font-size: .84rem; word-break: break-all; }

/* -------------------------------------------------------------- offer ---- */
.offer {
  border: 1.5px solid var(--accent); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--accent-bg), var(--surface) 70%);
  padding: 24px;
}
.offer h2 { margin-bottom: .3em; }
.offer .price { font-size: 1.55rem; font-weight: 680; letter-spacing: -.025em; }
.offer ul { margin: 14px 0 18px; padding: 0 0 0 2px; list-style: none; }
.offer li { position: relative; padding-left: 24px; margin-bottom: 6px; font-size: .92rem; color: var(--ink-2); }
.offer li::before { content: "\2713"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }

/* ------------------------------------------------------------ progress --- */
.progress { list-style: none; margin: 0; padding: 0; font-size: .92rem; }
.progress li {
  display: flex; gap: 10px; align-items: center; padding: 7px 0; color: var(--faint);
  transition: color .15s;
}
.progress li .tick { width: 18px; flex: 0 0 18px; text-align: center; font-weight: 700; }
.progress li[data-state="active"] { color: var(--ink); }
.progress li[data-state="done"] { color: var(--ink-2); }
.progress li[data-state="done"] .tick { color: var(--ok); }
.spinner {
  display: inline-block; width: 13px; height: 13px; border: 2px solid var(--border-2);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--border-2); }
  * { scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- prose -- */
.prose { max-width: 70ch; }
.prose h2 { margin-top: 1.8em; }
.prose h3 { margin-top: 1.5em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .45em; }
.prose blockquote {
  margin: 1.2em 0; padding: 12px 18px; border-left: 3px solid var(--border-2);
  background: var(--surface-2); border-radius: 0 var(--radius-s) var(--radius-s) 0; color: var(--ink-2);
}
.prose table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 1.2em 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 11px; text-align: left; }
.prose th { background: var(--surface-2); font-weight: 620; }

/* ---------------------------------------------------------------- forms -- */
.field-label { display: block; font-size: .86rem; font-weight: 560; margin-bottom: 6px; color: var(--ink-2); }
.field-hint { font-size: .82rem; color: var(--muted); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: .95rem; padding: 11px 13px;
  border: 1.5px solid var(--border-2); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink);
}
.textarea { font-family: var(--mono); font-size: .82rem; min-height: 190px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); outline: none; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 11px 0; border-top: 1px solid var(--border); }
.check:first-of-type { border-top: 0; }
.check input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 18px; accent-color: var(--accent); }
.check label { font-size: .93rem; cursor: pointer; }
.check .chint { display: block; font-size: .82rem; color: var(--muted); margin-top: 2px; }

.notice {
  border-radius: var(--radius-s); padding: 13px 16px; font-size: .9rem;
  border: 1px solid; display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px;
}
.notice-info    { background: var(--accent-bg); border-color: #cfe0fb; color: var(--accent-ink); }
.notice-warn    { background: var(--medium-bg); border-color: #f3e0a8; color: #7a5408; }
.notice-ok      { background: var(--ok-bg); border-color: #b7e4cd; color: #04593a; }
.notice-critical{ background: var(--critical-bg); border-color: #f3c3bd; color: #7a1a12; }
.notice-unknown { background: var(--unknown-bg); border-color: #ddd0f7; color: #4c28a0; }

details.disclose { border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); }
details.disclose + details.disclose { margin-top: 8px; }
details.disclose > summary {
  cursor: pointer; padding: 12px 16px; font-weight: 560; font-size: .92rem;
  list-style: none; display: flex; gap: 8px; align-items: center;
}
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary::before { content: "\25B8"; color: var(--faint); transition: transform .12s; }
details.disclose[open] > summary::before { transform: rotate(90deg); }
details.disclose .disclose-body { padding: 0 16px 16px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 14px 16px; }
.stat .k { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 640; }
.stat .v { font-size: 1.5rem; font-weight: 660; letter-spacing: -.025em; font-variant-numeric: tabular-nums; margin-top: 3px; }
.stat .sub { font-size: .78rem; color: var(--muted); }

.section { margin-top: 34px; }
.section > h2 { margin-bottom: .7em; }
.section-intro { color: var(--ink-2); max-width: 66ch; margin-bottom: 18px; }

.tag-row { display: flex; gap: 7px; flex-wrap: wrap; }
.tag {
  font-size: .78rem; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2);
}
.tag-mono { font-family: var(--mono); font-size: .74rem; }

.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 18px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

@media (max-width: 640px) {
  .hero { padding: 28px 0 22px; }
  .card-pad, .card-body, .card-head { padding: 16px; }
  .btn { width: 100%; }
  .scan-form .field { flex-basis: 100%; }
  .site-header .wrap { height: auto; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; gap: 8px; }
  .site-nav { width: 100%; margin-left: 0; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}

@media print {
  .site-header, .site-footer, .btn, .copy-btn, .no-print { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  a { color: #000; text-decoration: underline; }
}
