/* tee-mail control panel. System fonts only (no third-party requests). */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --ink: #16202b;
  --muted: #5a6776;
  --line: #d7dde4;
  --accent: #1f5fbf;
  --accent-ink: #ffffff;
  --good: #137a4b;
  --good-bg: #e3f4ea;
  --warn: #8a5a00;
  --warn-bg: #fdf1d8;
  --bad: #b3261e;
  --bad-bg: #fbe4e2;
  --neutral-bg: #eceff3;
  --code-bg: #f1f3f6;
  --radius: 8px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a; --surface: #161d25; --surface-2: #1c2530; --ink: #e5eaf0; --muted: #98a5b3; --line: #2b3643;
    --accent: #6f9ef0; --accent-ink: #0b1220; --good: #5fd39a; --good-bg: #14301f; --warn: #f0c060; --warn-bg: #352812;
    --bad: #f2867d; --bad-bg: #3a1a18; --neutral-bg: #222c37; --code-bg: #1e2732; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 0.95rem; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
code, .mono { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; word-break: break-all; }

/* Layout: top bar, side navigation, content. */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px max(16px, 3vw); background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.topbar .spacer { flex: 1; }
.topbar form { margin: 0; }
.orgswitch select { max-width: 220px; }
.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 53px); }
.nav { padding: 18px 12px; border-right: 1px solid var(--line); background: var(--surface); }
.nav a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--ink); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--surface-2); font-weight: 600; }
.nav .section { margin: 16px 10px 4px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
main { padding: 24px max(16px, 3vw) 48px; max-width: 1180px; width: 100%; }
.narrow { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { border-right: 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .nav .section { display: none; }
}

.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid .card { margin-bottom: 0; }

.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid transparent; }
.banner.ok { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.banner.err { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.banner.support { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); font-weight: 600; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.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.neutral { background: var(--neutral-bg); color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.meter { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 6px 0 4px; }
.meter > div { height: 100%; background: var(--accent); border-radius: 999px; }
.meter.high > div { background: var(--warn); }
.meter.full > div { background: var(--bad); }
.stat { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }

form.inline { display: inline; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.row > * { min-width: 0; }
label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 10px; min-width: 0; width: 100%; }
.field { margin-bottom: 14px; flex: 1 1 200px; }
button, .button { font: inherit; font-weight: 600; border-radius: 6px; padding: 7px 14px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); cursor: pointer; display: inline-block; }
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
button.small { padding: 3px 10px; font-size: 0.85rem; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* DNS records: expected value with a copy button. */
.copyable { display: flex; gap: 6px; align-items: flex-start; }
.copyable code { flex: 1; }
.copy { flex: none; }
.record-advice { margin-top: 6px; font-size: 0.85rem; }
.secret { border: 2px solid var(--warn); }
.qr { background: #fff; padding: 8px; border-radius: 6px; display: inline-block; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.mt { margin-top: 18px; }
.mt-s { margin-top: 6px; }
.mb-s { margin-bottom: 10px; }
.fixed { flex: 0 0 auto; }
.grow { flex: 1 1 220px; }
.brand.big { font-size: 1.3rem; }
.meter .w-0 { width: 0%; }
.meter .w-5 { width: 5%; }
.meter .w-10 { width: 10%; }
.meter .w-15 { width: 15%; }
.meter .w-20 { width: 20%; }
.meter .w-25 { width: 25%; }
.meter .w-30 { width: 30%; }
.meter .w-35 { width: 35%; }
.meter .w-40 { width: 40%; }
.meter .w-45 { width: 45%; }
.meter .w-50 { width: 50%; }
.meter .w-55 { width: 55%; }
.meter .w-60 { width: 60%; }
.meter .w-65 { width: 65%; }
.meter .w-70 { width: 70%; }
.meter .w-75 { width: 75%; }
.meter .w-80 { width: 80%; }
.meter .w-85 { width: 85%; }
.meter .w-90 { width: 90%; }
.meter .w-95 { width: 95%; }
.meter .w-100 { width: 100%; }

/* Phones: wrap the top bar, and stack DNS records as cards. */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; }
  .topbar .who { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .orgswitch select { max-width: 160px; }
  table.records thead { display: none; }
  table.records, table.records tbody, table.records tr, table.records td { display: block; width: 100%; }
  table.records tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  table.records td { border: 0; padding: 4px 0; }
  table.records td::before { content: attr(data-label); display: block; font-size: 0.75rem; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--muted); }
}

/* Analytics: period tabs, stacked bar chart (SVG), log filters. */
:root { --c-delivered: #2e8b57; --c-bounced: #c0392b; --c-spam: #7d4cc2; --c-sandbox: #9aa5b1; }
@media (prefers-color-scheme: dark) { :root { --c-delivered: #5fd39a; --c-bounced: #f2867d; --c-spam: #b598f0; --c-sandbox: #5d6b7a; } }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat.warn { color: var(--warn); }
.stat.bad { color: var(--bad); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 18px; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); background: var(--surface); font-size: 0.9rem; }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tabs a:hover { text-decoration: none; }
.cardhead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.legend { margin: 0; color: var(--muted); }
.legend .key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; }
.chart { width: 100%; height: auto; display: block; margin-top: 8px; }
.chart .axis { stroke: var(--line); }
.chart .tick { fill: var(--muted); font-size: 11px; }
.chart .hit { fill: transparent; }
.chart g:hover .hit { fill: var(--surface-2); }
.c-delivered { fill: var(--c-delivered); background: var(--c-delivered); }
.c-bounced { fill: var(--c-bounced); background: var(--c-bounced); }
.c-spam { fill: var(--c-spam); background: var(--c-spam); }
.c-sandbox { fill: var(--c-sandbox); background: var(--c-sandbox); }
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.filters input { width: 190px; }
.filters label { margin: 0; }
.nowrap { white-space: nowrap; }
/* SMTP logs: the detail takes the room the short ids leave, as fields that wrap. */
table.logs td.detail, table.logs th.detail { width: 100%; min-width: 220px; }
table.logs .kv { display: inline-block; margin: 0 12px 2px 0; overflow-wrap: anywhere; }
td.wrap { word-break: break-word; }

/* Mail flow (SVG, animated by flow.js). */
:root { --o-ok: #2e8b57; --o-deferred: #c98a00; --o-held: #7d4cc2; --o-bad: #c0392b; --o-sandbox: #8795a3; }
@media (prefers-color-scheme: dark) { :root { --o-ok: #5fd39a; --o-deferred: #f0c060; --o-held: #b598f0; --o-bad: #f2867d; --o-sandbox: #6f7d8b; } }
.flow { width: 100%; height: auto; display: block; margin-top: 8px; }
.flow .edge { stroke: var(--line); stroke-width: 2; transition: stroke 0.3s; }
.flow .edge.hot { stroke: var(--accent); }
.flow .node rect { fill: var(--surface-2); stroke: var(--line); transition: stroke 0.2s; }
.flow .node.pulse rect { stroke: var(--accent); stroke-width: 2; }
.flow .n-refused rect, .flow .n-rejected rect, .flow .n-bounced rect { fill: var(--bad-bg); }
.flow .n-quarantine rect { fill: var(--surface-2); stroke: var(--o-held); }
.flow .n-deferred rect { fill: var(--warn-bg); }
.flow .nlabel { fill: var(--ink); font-size: 13px; font-weight: 600; }
.flow .ncount { fill: var(--muted); font-size: 11px; }
.flow .dot { stroke: var(--surface); stroke-width: 1.5; transition: opacity 0.5s; }
.flow .dot.arrived { opacity: 0; }
.o-ok { fill: var(--o-ok); background: var(--o-ok); }
.o-deferred { fill: var(--o-deferred); background: var(--o-deferred); }
.o-held { fill: var(--o-held); background: var(--o-held); }
.o-bad { fill: var(--o-bad); background: var(--o-bad); }
.o-sandbox { fill: var(--o-sandbox); background: var(--o-sandbox); }
.tracelog { margin: 12px 0 0; padding-left: 20px; }
.tracelog li { background: none; margin-bottom: 4px; }
.tracelog li::marker { color: var(--muted); }

/* Infrastructure map (infra.js). */
.pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 8px; }
.stagecol { display: flex; flex-direction: column; gap: 8px; }
.stagehead { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.inst { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface-2); }
.inst.new { animation: instin 0.6s ease-out; }
@keyframes instin { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .inst.new { animation: none; } }
.insthead { display: flex; align-items: center; gap: 6px; }
.dotstatus { width: 9px; height: 9px; border-radius: 50%; background: var(--o-ok); }
.inst.s-draining { opacity: 0.6; }
.inst.s-draining .dotstatus, .inst.s-unready .dotstatus { background: var(--o-deferred); }
.inst.s-stopped { opacity: 0.4; }
.inst.s-stopped .dotstatus { background: var(--o-sandbox); }
.components { display: flex; flex-wrap: wrap; gap: 8px; }
.comp { padding: 4px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }
.comp.up { background: var(--good-bg); color: var(--good); }
.comp.down { background: var(--bad-bg); color: var(--bad); }
.pagehead form.row { flex-wrap: nowrap; }
.pagehead form.row input { width: 240px; }

/* Status page. */
.statushead { font-size: 1.1rem; font-weight: 700; }
.statuslist { list-style: none; margin: 0; padding: 0; }
.statuslist li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.statuslist li:last-child { border-bottom: 0; }
.incident { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.incident:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin-right: 14px; }
fieldset.field { border: 0; padding: 0; }
textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }
.narrow.wide { max-width: 760px; }
pre.wrap { white-space: pre-wrap; word-break: break-word; margin: 6px 0 0; }

/* Agent inbox conversation. */
.agentmsg { border-top: 1px solid var(--line); padding: 12px 0; }
.agentmsg:first-of-type { border-top: 0; }
.agentmsg.out { padding-left: 16px; border-left: 3px solid var(--accent); }

/* Message content preview (sandboxed frame). */
.mailview { width: 100%; height: 480px; border: 1px solid var(--line); border-radius: 6px; background: #fff; margin: 8px 0; }
.setting { padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
details.explain { margin: 6px 0 10px; }
details.explain summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
details.explain[open] { background: var(--neutral-bg); border-radius: 6px; padding: 8px 12px; }

/* Setup wizard. */
.wizard { max-width: 760px; margin: 0 auto; }
.wizsteps { display: flex; flex-wrap: wrap; gap: 6px 14px; list-style: none; padding: 0; margin: 0 0 16px; font-size: 0.9rem; counter-reset: step; }
.wizsteps li { color: var(--muted); counter-increment: step; }
.wizsteps li::before { content: counter(step) ". "; }
.wizsteps li.current { color: var(--ink); font-weight: 700; }
.wizsteps li.done a { color: var(--good); }
.checks { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.checks .badge { min-width: 70px; text-align: center; }
.field.choice label { display: flex; gap: 8px; align-items: center; font-size: 1rem; }
.field.choice input { width: auto; }
/* The recovery kit copies when clicked. */
.clickcopy { cursor: copy; }
.clickcopy:hover { outline: 1px solid var(--accent); }
.kit { white-space: pre-wrap; word-break: break-all; background: var(--surface-2); padding: 12px; border-radius: 6px; font-size: 0.85rem; }
