/* Mail Steward. One stylesheet for the console (app.) and the admin (admin.).
   Tokens first; light and dark are both chosen, not inverted. */
:root {
  --paper: #f4f6f3;      /* page */
  --surface: #ffffff;    /* panels */
  --sunk: #eef1ed;       /* wells, code, tracks */
  --ink: #18211c;
  --ink-2: #4d5852;
  --ink-3: #6f7a73;
  --line: #dde2dc;
  --line-2: #c9d0c9;
  --green: #1f5c45;      /* primary: actions, current place */
  --green-2: #174936;
  --green-ink: #ffffff;
  --green-tint: #e4eee8;
  --brass: #9a6f22;      /* owner-only marks, used sparingly */
  --brass-tint: #f5ecd9;
  --ok: #1d6f3c; --ok-bg: #e2f1e6;
  --warn: #7d5300; --warn-bg: #fbf0d6;
  --bad: #a3241c; --bad-bg: #fbe4e1;
  --focus: #2f6fd6;
  /* chart series: validated categorical slots 1-3 */
  --s-sent: #2a78d6; --s-received: #1baf7a; --s-bounced: #eb6834; --grid: #e3e7e2;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-s: 6px; --r-m: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1412; --surface: #161d19; --sunk: #1d2621; --ink: #e6ebe7; --ink-2: #a9b5ae; --ink-3: #85918a;
    --line: #27312c; --line-2: #34403a; --green: #6cc197; --green-2: #85d0aa; --green-ink: #0b1510; --green-tint: #1a2c23;
    --brass: #d4ac5c; --brass-tint: #2c2415; --ok: #7fd6a0; --ok-bg: #163323; --warn: #f0c46a; --warn-bg: #362a12;
    --bad: #ff9a90; --bad-bg: #3b1c18; --focus: #8fb4ff;
    --s-sent: #3987e5; --s-received: #199e70; --s-bounced: #d95926; --grid: #26302b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--sans); }
a { color: var(--green); text-underline-offset: 2px; }
a:hover { color: var(--green-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.005em; color: var(--ink); }
h1 { font-size: 30px; line-height: 1.15; margin: 0; }
h2 { font-size: 20px; line-height: 1.25; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code, .mono { font-family: var(--mono); font-size: 13px; background: var(--sunk); padding: 1px 6px; border-radius: 4px; word-break: break-all; }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column;
        position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-top { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-family: var(--serif);
         font-size: 18px; font-weight: 600; }
.brand svg { flex: 0 0 26px; }
.owner-tag { font-size: 12px; font-weight: 600; color: var(--brass); background: var(--brass-tint); padding: 1px 8px; border-radius: 999px; }
.nav-toggle-label { display: none; }
.nav { display: flex; flex-direction: column; flex: 1; padding: 4px 10px 14px; }
.nav-group { margin: 10px 0 2px; padding: 0 8px; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.nav a, .nav-foot a { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: var(--r-s); color: var(--ink-2);
         text-decoration: none; font-size: 14px; line-height: 1.3; }
.nav a:hover, .nav-foot a:hover { background: var(--sunk); color: var(--ink); }
.nav a[aria-current="page"], .nav a.here, .nav-foot a[aria-current="page"] { background: var(--green-tint); color: var(--green); font-weight: 600; }
.nav a.org-link { color: var(--ink); font-weight: 600; }
.nav .sub { margin: 2px 0 6px 18px; padding-left: 10px; border-left: 1px solid var(--line); }
.nav .sub a { font-size: 13.5px; padding: 5px 8px; }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.nav .count { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.nav-foot { border-top: 1px solid var(--line); margin-top: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-foot .who { padding: 4px 10px 8px; font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-foot form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 7px 10px; color: var(--ink-2); font: inherit; font-size: 14px; cursor: pointer;
           text-align: left; width: 100%; border-radius: var(--r-s); }
.linkbtn:hover { background: var(--sunk); color: var(--ink); }
.ext::after { content: " \2197"; color: var(--ink-3); font-size: 12px; }

.main { padding: 26px 36px 72px; max-width: 1120px; width: 100%; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--ink-3); margin: 0 0 10px; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { color: var(--green); text-decoration: underline; }
.crumbs span[aria-hidden] { color: var(--line-2); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 0 22px; }
.page-head .sub { margin: 6px 0 0; color: var(--ink-2); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 20px 22px; margin: 0 0 18px; }
.panel > h2:first-child, .panel-head h2 { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; }
.panel-head h2 { margin: 0; }
.panel.quiet { background: transparent; border-style: dashed; }
.lede { color: var(--ink-2); max-width: 64ch; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.grid-2 > .panel { margin: 0; }
.narrow { max-width: 440px; margin: 0 auto; }

/* ---------------------------------------------------------------- notes, pills */
.note { padding: 11px 14px; border-radius: var(--r-s); margin: 0 0 16px; border: 1px solid transparent; }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.note.info { background: var(--green-tint); color: var(--ink); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 12.5px;
        font-weight: 600; background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.plain::before { display: none; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.rowlink:hover td { background: var(--sunk); }
.cell-main a { font-weight: 600; text-decoration: none; }
.cell-main a:hover { text-decoration: underline; }
.cell-sub { font-size: 13px; color: var(--ink-3); }

/* ---------------------------------------------------------------- forms */
label { display: block; margin: 12px 0 5px; font-weight: 600; font-size: 14px; }
.hint { font-size: 13px; color: var(--ink-3); margin: 4px 0 0; font-weight: 400; }
input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--r-s);
                          background: var(--surface); color: var(--ink); width: 100%; }
input:focus, select:focus { border-color: var(--green); outline: 2px solid color-mix(in srgb, var(--green) 25%, transparent); outline-offset: 0; }
input[type=checkbox] { width: auto; accent-color: var(--green); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 12px 0; }
.check input { margin-top: 4px; }
.check b { font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form > div { flex: 1 1 220px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
form.inline { display: inline; margin: 0; }
.panel .inline-form { border-top: 1px solid var(--line); padding-top: 14px; }
.input-addon { display: flex; align-items: stretch; }
.input-addon input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon span { display: flex; align-items: center; padding: 0 11px; border: 1px solid var(--line-2); border-left: 0;
                    border-radius: 0 var(--r-s) var(--r-s) 0; background: var(--sunk); color: var(--ink-2); font-size: 14px; white-space: nowrap; }

.btn, button { font: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: var(--r-s);
               border: 1px solid var(--green); background: var(--green); color: var(--green-ink); cursor: pointer;
               text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; }
.btn:hover, button:hover { background: var(--green-2); border-color: var(--green-2); color: var(--green-ink); }
.btn.secondary, button.secondary { background: var(--surface); color: var(--green); border-color: var(--line-2); }
.btn.secondary:hover, button.secondary:hover { background: var(--green-tint); border-color: var(--green); color: var(--green); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.small, .btn.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }

/* ---------------------------------------------------------------- domain steps */
.steps { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
         gap: 8px; counter-reset: step; }
.steps li { position: relative; padding: 12px 14px 12px 46px; border-radius: var(--r-m); background: var(--surface);
            border: 1px solid var(--line); counter-increment: step; min-height: 64px; }
.steps li::before { content: counter(step); position: absolute; left: 13px; top: 13px; width: 24px; height: 24px; border-radius: 50%;
                    display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--sunk); color: var(--ink-2); }
.steps li.done::before { content: "\2713"; background: var(--ok-bg); color: var(--ok); }
.steps li.now { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.steps li.now::before { background: var(--green); color: var(--green-ink); }
.steps b { display: block; font-size: 14px; }
.steps span { display: block; font-size: 12.5px; color: var(--ink-3); }

.records td:nth-child(3) { width: 46%; }
.rec-value { display: flex; gap: 8px; align-items: flex-start; }
.rec-value code { flex: 0 1 auto; max-height: 4.6em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.copy { flex: 0 0 auto; }
.rec-group { margin: 22px 0 6px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rec-group h3 { margin: 0; }

/* ---------------------------------------------------------------- key/value lists, secrets */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.kv dt { color: var(--ink-3); font-size: 13.5px; padding-top: 1px; }
.kv dd { margin: 0; }
.secret-box { display: flex; gap: 10px; align-items: center; background: var(--sunk); border: 1px dashed var(--line-2);
              border-radius: var(--r-m); padding: 14px; margin: 12px 0; flex-wrap: wrap; }
.secret-box code { background: transparent; font-size: 19px; padding: 0; flex: 1; letter-spacing: .02em; }
details.danger { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
details > summary { cursor: pointer; font-weight: 600; }
details[open] > summary { margin-bottom: 10px; }

/* ---------------------------------------------------------------- sign-in pages */
.solo { min-height: 100vh; display: grid; place-items: start center; padding: 9vh 16px 40px; }
.solo .brand { justify-content: center; margin: 0 0 22px; font-size: 22px; }
.solo .panel { width: 100%; max-width: 420px; padding: 26px 28px; }
.solo h1 { font-size: 26px; margin: 0 0 6px; }
.solo .after { text-align: center; margin-top: 14px; font-size: 13px; color: var(--ink-3); max-width: 420px; }

/* ---------------------------------------------------------------- admin: health, stats, charts */
.health { display: flex; flex-wrap: wrap; gap: 10px 26px; background: var(--surface); border: 1px solid var(--line);
          border-radius: var(--r-m); padding: 14px 18px; margin: 0 0 18px; }
.hitem { display: flex; gap: 9px; align-items: center; }
.hitem > span:last-child { display: flex; flex-direction: column; line-height: 1.25; }
.hitem b { font-size: 14px; }
.sdot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.sdot.ok { background: var(--ok); } .sdot.warn { background: #d99a00; } .sdot.bad { background: var(--bad); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 12px; }
.kpis + .kpis { margin-bottom: 18px; }
@media (max-width: 860px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); padding: 14px 16px;
       display: flex; flex-direction: column; gap: 2px; }
.kpi .v { font-family: var(--serif); font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi a { text-decoration: none; color: inherit; }
.spark { margin-top: 8px; }
.spark polyline { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-sent polyline { stroke: var(--s-sent); } .spark-sent circle { fill: var(--s-sent); }
.spark-received polyline { stroke: var(--s-received); } .spark-received circle { fill: var(--s-received); }
.spark-bounced polyline { stroke: var(--s-bounced); } .spark-bounced circle { fill: var(--s-bounced); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.sw-sent { background: var(--s-sent); } .sw-received { background: var(--s-received); } .sw-bounced { background: var(--s-bounced); }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart { display: block; height: auto; max-height: 240px; }
.chart .axis { fill: var(--ink-3); font-size: 11px; font-family: var(--sans); }
.bar-sent { fill: var(--s-sent); } .bar-received { fill: var(--s-received); } .bar-bounced { fill: var(--s-bounced); }
.chart rect:hover { opacity: .8; }
.barlist { list-style: none; margin: 0; padding: 0; }
.barlist li { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(60px, 1fr) 3ch; gap: 12px; align-items: center;
              padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.barlist li:last-child { border-bottom: 0; }
.barlist .addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track { height: 8px; background: var(--sunk); border-radius: 4px; overflow: hidden; }
.fill { display: block; height: 100%; background: var(--s-sent); border-radius: 4px; }
.minibar { display: inline-block; width: 46px; height: 6px; background: var(--sunk); border-radius: 3px; overflow: hidden;
           vertical-align: middle; margin-right: 6px; }
.minibar span { display: block; height: 100%; background: var(--s-sent); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-s); overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--ink-2); padding: 5px 12px; font-size: 13px; font-weight: 600; }
.seg button:hover { background: var(--sunk); color: var(--ink); }
.seg button.on { background: var(--green); color: var(--green-ink); }
.seg button:disabled { opacity: 1; }
.seg button.na { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--paper); padding: 5px 9px; border-radius: 6px;
       font-size: 12px; z-index: 10; white-space: nowrap; }

/* ---------------------------------------------------------------- phones and small tablets */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { position: sticky; top: 0; z-index: 5; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-top { padding: 12px 16px; }
  .nav-toggle-label { display: inline-flex; margin-left: auto; align-items: center; gap: 6px; font-weight: 600; font-size: 14px;
                      padding: 6px 12px; border: 1px solid var(--line-2); border-radius: var(--r-s); cursor: pointer; color: var(--ink); }
  .side .nav, .side .nav-foot { display: none; }
  #nav-toggle:checked ~ .nav, #nav-toggle:checked ~ .nav-foot { display: flex; }
  #nav-toggle:focus-visible + .side-top .nav-toggle-label { outline: 2px solid var(--focus); }
  .side { max-height: 100vh; overflow-y: auto; }
  .main { padding: 18px 16px 56px; }
  h1 { font-size: 25px; }
  .steps { grid-template-columns: 1fr 1fr; }
  .panel { padding: 16px; }
  .records td:nth-child(3) { width: auto; }
}
@media (max-width: 340px) { .steps { grid-template-columns: 1fr; } }
.t-close { display: none; }
#nav-toggle:checked + .side-top .t-open { display: none; }
#nav-toggle:checked + .side-top .t-close { display: inline; }
/* Tables become labelled rows on phones (labels come from the header row, app.js). */
@media (max-width: 640px) {
  table.stack tr:has(th) { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 3px 0; text-align: left; display: flex; gap: 12px; justify-content: space-between; align-items: baseline; }
  table.stack td.num { text-align: left; }
  table.stack td[data-label]::before { content: attr(data-label); color: var(--ink-3); font-size: 13px; flex: 0 0 auto; }
  table.stack td:first-child { display: block; font-size: 15px; padding-bottom: 6px; }
  table.stack td:first-child::before { display: none; }
  table.stack td:empty { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* collapsible panels: a visible Show/Hide control instead of the native marker */
details.panel > summary.panel-head { cursor: pointer; margin: 0; }
details.panel > summary.panel-head::-webkit-details-marker { display: none; }
details.panel > summary.panel-head::after { content: "Show"; margin-left: auto; font-family: var(--sans); font-size: 13px; font-weight: 600;
  color: var(--green); border: 1px solid var(--line-2); border-radius: var(--r-s); padding: 3px 10px; }
details.panel[open] > summary.panel-head { margin-bottom: 12px; }
details.panel[open] > summary.panel-head::after { content: "Hide"; }
/* One-click DNS set-up (Domain Connect) on the domain page */
.note.dc h3 { margin: 0 0 4px; font-size: 1rem; }
.note.dc p { margin: 0 0 8px; }
.note.dc .form-actions { margin-top: 10px; }
