/* EasierDMARC. Design system: design-system/easierdmarc/MASTER.md (data-dense dashboard, Fira Sans/Fira Code).
   Chart colors validated with the dataviz palette script: light #2563EB/#DC2626 on #FFFFFF,
   dark #3987e5/#e66767 on #111827. */
:root {
  color-scheme: light;
  --bg: #F8FAFC; --card: #FFFFFF; --fg: #0F172A; --fg-2: #334155; --muted: #475569;
  --border: #E2E8F0; --border-2: #CBD5E1; --soft: #F1F5F9;
  --primary: #1E40AF; --primary-hover: #1E3A8A; --on-primary: #FFFFFF; --ring: #2563EB;
  --accent: #B45309;
  --good: #15803D; --good-bg: #DCFCE7; --warn: #A16207; --warn-bg: #FEF9C3; --bad: #B91C1C; --bad-bg: #FEE2E2;
  --viz-pass: #2563EB; --viz-fail: #DC2626; --grid: #E2E8F0;
  --sidebar: #0F172A; --sidebar-fg: #CBD5E1; --sidebar-active: #1E293B;
  --radius: 8px; --shadow: 0 1px 2px rgba(15, 23, 42, .06);
  --sans: 'Fira Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0B1120; --card: #111827; --fg: #F1F5F9; --fg-2: #CBD5E1; --muted: #94A3B8;
    --border: #1F2937; --border-2: #334155; --soft: #1E293B;
    --primary: #3B82F6; --primary-hover: #60A5FA; --on-primary: #0B1120; --ring: #60A5FA;
    --good: #4ADE80; --good-bg: rgba(74, 222, 128, .12); --warn: #FACC15; --warn-bg: rgba(250, 204, 21, .12); --bad: #F87171; --bad-bg: rgba(248, 113, 113, .12);
    --viz-pass: #3987e5; --viz-fail: #e66767; --grid: #1F2937;
    --sidebar: #070B14; --sidebar-fg: #94A3B8; --sidebar-active: #172033;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B1120; --card: #111827; --fg: #F1F5F9; --fg-2: #CBD5E1; --muted: #94A3B8;
  --border: #1F2937; --border-2: #334155; --soft: #1E293B;
  --primary: #3B82F6; --primary-hover: #60A5FA; --on-primary: #0B1120; --ring: #60A5FA;
  --good: #4ADE80; --good-bg: rgba(74, 222, 128, .12); --warn: #FACC15; --warn-bg: rgba(250, 204, 21, .12); --bad: #F87171; --bad-bg: rgba(248, 113, 113, .12);
  --viz-pass: #3987e5; --viz-fail: #e66767; --grid: #1F2937;
  --sidebar: #070B14; --sidebar-fg: #94A3B8; --sidebar-active: #172033;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--sans); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.5rem; } h2 { font-size: 1rem; } h3 { font-size: .9rem; }
.mono { font-family: var(--mono); font-feature-settings: 'tnum'; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .strong { font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; } .skip:focus { left: 8px; top: 8px; z-index: 100; background: var(--card); padding: 8px 12px; }
.i { flex: none; vertical-align: middle; }

/* Shell */
.has-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-fg); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 1.1rem; padding: 4px 8px 16px; }
.brand b, .auth-brand b { color: #60A5FA; font-weight: 700; }
.brand:hover { text-decoration: none; }
.org-switch select, .org-name { width: 100%; margin-bottom: 12px; }
.org-name { color: #fff; font-weight: 600; padding: 0 8px; }
.org-switch select { background: var(--sidebar-active); color: #fff; border-color: #334155; }
.nav-section { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #64748B; margin: 16px 8px 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 6px; color: var(--sidebar-fg); min-height: 36px; transition: background-color .15s, color .15s; }
.nav-link:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #60A5FA; }
.nav-domain span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; }
.me { margin-top: auto; display: flex; align-items: center; gap: 8px; border-top: 1px solid #1E293B; padding: 12px 4px 0; }
.me-id { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.me-name { color: #fff; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-mail { font-size: .75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .icon-btn { color: var(--sidebar-fg); }
.topbar { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--card); position: sticky; top: 0; z-index: 5; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem; min-width: 0; }
.crumbs a { color: var(--fg-2); }
.crumbs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn, .nav-toggle, .scrim { display: none; }
main { padding: 24px; max-width: 1400px; outline: none; }
.main-col { min-width: 0; }

/* Page building blocks */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.back { font-size: .85rem; display: inline-block; margin-bottom: 4px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.narrow { max-width: 760px; }
.card.highlight { border-color: var(--primary); }
.card.danger { border-color: var(--bad-bg); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head.sub { margin: 16px 0 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 + * { margin-top: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.6rem; font-weight: 600; margin: 2px 0; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.kpi .badge { margin-top: 6px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--fg); text-decoration: none; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

/* Tables */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr.row-link { cursor: pointer; transition: background-color .12s; }
.tbl tr.row-link:hover { background: var(--soft); }
.num { text-align: right !important; white-space: nowrap; }
.rate { min-width: 140px; }
.rate-row { display: flex; align-items: center; gap: 8px; }
.rate-row .mono { width: 52px; text-align: right; font-size: .84rem; }
.meter { flex: 1; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; min-width: 60px; }
.meter-fill { display: block; height: 100%; background: var(--viz-pass); border-radius: 3px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 500; white-space: nowrap; line-height: 1.6; }
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-muted { background: var(--soft); color: var(--muted); }
a.badge:hover { text-decoration: none; filter: brightness(.97); }

.pill-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pill-list li { display: flex; gap: 8px; padding: 4px 10px; background: var(--soft); border-radius: 6px; font-size: .84rem; }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0; }
.meta dt { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.meta dd { margin: 2px 0 0; }
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.sub-h { margin: 16px 0 8px; }

/* Forms & buttons */
.form { display: grid; gap: 14px; }
.form-row { grid-template-columns: 1fr auto auto; align-items: end; }
.form-row .grow { min-width: 0; }
.field { display: grid; gap: 4px; }
.field label { font-weight: 500; font-size: .88rem; }
input, select { font: inherit; color: var(--fg); background: var(--card); border: 1px solid var(--border-2); border-radius: 6px; padding: 8px 10px; min-height: 40px; width: 100%; }
select { cursor: pointer; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--ring); outline-offset: 0; border-color: var(--ring); }
input[aria-invalid="true"] { border-color: var(--bad); }
.help { margin: 0; font-size: .8rem; color: var(--muted); }
.field-error { margin: 4px 0 0; color: var(--bad); font-size: .84rem; display: flex; gap: 6px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 500; font-size: .9rem; padding: 8px 14px; min-height: 40px; border-radius: 6px; border: 1px solid var(--border-2); background: var(--card); color: var(--fg); cursor: pointer; transition: background-color .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--soft); text-decoration: none; }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .84rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: #B91C1C; border-color: #B91C1C; color: #fff; }
.btn-danger:hover { background: #991B1B; border-color: #991B1B; }
.btn-ghost-danger { color: var(--bad); border-color: transparent; background: transparent; }
.btn-ghost-danger:hover { background: var(--bad-bg); }
.btn-block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 6px; border: 0; background: transparent; color: var(--muted); cursor: pointer; transition: background-color .15s, color .15s; }
.icon-btn:hover { background: var(--soft); color: var(--fg); }
.icon-btn.copied { color: var(--good); }
.range select { width: auto; min-width: 160px; }
.inline select { width: auto; min-height: 32px; padding: 2px 8px; }
.link { font-size: .85rem; display: inline-flex; align-items: center; gap: 2px; }

.flash { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: .9rem; border: 1px solid; }
.flash-info { background: var(--good-bg); border-color: transparent; color: var(--fg); }
.flash-info .i { color: var(--good); }
.flash-error { background: var(--bad-bg); border-color: transparent; color: var(--fg); }
.flash-error .i { color: var(--bad); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty h3 { color: var(--fg); margin: 8px 0 4px; font-size: 1rem; }
.empty p { margin: 0 auto 16px; max-width: 46ch; }

/* Setup checklist */
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.check { display: grid; grid-template-columns: 28px 1fr; gap: 12px; }
.check + .check { border-top: 1px solid var(--border); padding-top: 16px; }
.check-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; }
.check-good .check-ic { background: var(--good-bg); color: var(--good); }
.check-bad .check-ic { background: var(--bad-bg); color: var(--bad); }
.check-muted .check-ic { background: var(--soft); color: var(--muted); }
.check-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.check p { margin: 6px 0; color: var(--fg-2); font-size: .9rem; }
.copy { margin-top: 8px; }
.copy-label { font-size: .76rem; color: var(--muted); margin-bottom: 2px; }
.copy-row { display: flex; align-items: center; gap: 4px; background: var(--soft); border-radius: 6px; padding: 4px 4px 4px 10px; }
.copy-row code { flex: 1; font-family: var(--mono); font-size: .82rem; overflow-x: auto; white-space: nowrap; padding: 4px 0; }

/* Charts */
.viz { margin: 0; }
.legend { display: flex; gap: 16px; font-size: .82rem; color: var(--fg-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.viz-pass { background: var(--viz-pass); } .sw.viz-fail { background: var(--viz-fail); }
.plot { position: relative; padding: 0 0 22px 40px; }
.chart { width: 100%; height: 178px; display: block; overflow: visible; }
.ax-y span, .ax-x span { position: absolute; font: 11px var(--mono); color: var(--muted); white-space: nowrap; }
.ax-y { position: absolute; left: 0; top: 0; width: 34px; height: 178px; }
.ax-y span { right: 0; transform: translateY(-50%); }
.ax-x { position: absolute; left: 40px; right: 0; bottom: 0; height: 18px; }
.ax-x span { transform: translateX(-50%); bottom: 0; }
.chart .viz-pass { fill: var(--viz-pass); } .chart .viz-fail { fill: var(--viz-fail); }
.chart .grid { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .ax { fill: var(--muted); font: 11px var(--mono); }
.chart .hit { fill: transparent; }
.chart .hit.on { fill: var(--fg); fill-opacity: .05; }
.table-view { margin-top: 8px; font-size: .85rem; }
.table-view summary { cursor: pointer; color: var(--primary); }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--fg); color: var(--bg); font-size: .8rem; padding: 8px 10px; border-radius: 6px; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); font-family: var(--mono); }

/* Auth */
.bare main { min-height: 100vh; display: grid; place-items: center; max-width: none; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 32px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; color: var(--primary); margin-bottom: 24px; }
.auth-brand span { color: var(--fg); }
.auth-card h1 { margin-bottom: 16px; }

@media (max-width: 1024px) { .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .has-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 30; transform: translateX(-100%); transition: transform .2s ease-out; }
  .nav-toggle:checked ~ .sidebar { transform: none; }
  .nav-toggle:checked ~ .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 20; }
  .menu-btn { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; cursor: pointer; margin-left: -10px; color: var(--fg); }
  .topbar { padding: 0 16px; }
  main { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .auth-card { padding: 24px 16px; border: 0; box-shadow: none; background: transparent; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
