/*
 * mailadmin portal — one stylesheet, no external sources.
 * Calm and factual: cool paper, slate ink, postal blue for actions. The one
 * decorative element is the airmail edge on top of the header.
 */
:root {
  --paper: #f3f5f6;
  --surface: #ffffff;
  --ink: #1b2a35;
  --muted: #55636e;
  --rule: #d4dce1;
  --rule-strong: #b7c3ca;
  --accent: #1f5b85;
  --accent-strong: #174769;
  --accent-soft: #e5eef5;
  --on-accent: #ffffff;
  --red: #a3302a;
  --red-soft: #fbeceb;
  --amber: #82560a;
  --amber-soft: #fcf2da;
  --green: #276a43;
  --green-soft: #e5f2ea;
  --info: #3c5874;
  --info-soft: #e9eef3;
  --focus: #e0a526;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --radius: 6px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #141b21;
    --surface: #1b242b;
    --ink: #e4eaee;
    --muted: #9fb0bb;
    --rule: #2e3b45;
    --rule-strong: #43535f;
    --accent: #6aa6d4;
    --accent-strong: #8dbde2;
    --accent-soft: #1f3344;
    --on-accent: #0e1a24;
    --red: #f08a82;
    --red-soft: #3a2220;
    --amber: #e7bf6a;
    --amber-soft: #352c17;
    --green: #7fcb9c;
    --green-soft: #1b3326;
    --info: #a9c1d8;
    --info-soft: #22303c;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap { width: 100%; max-width: 46rem; margin: 0 auto; padding-left: 1rem; padding-right: 1rem; }
.wrap.wide { max-width: 72rem; }

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-strong); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: 0.5rem 0.75rem; z-index: 10; }

/* ---------------------------------------------------------------- header */

header.site { background: var(--surface); border-bottom: 1px solid var(--rule); }
header.site::before {
  content: "";
  display: block;
  height: 5px;
  background: repeating-linear-gradient(135deg,
    var(--accent) 0 14px, transparent 14px 20px,
    var(--red) 20px 34px, transparent 34px 40px);
}
.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.5rem; }
.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--ink); text-decoration: none; font-weight: 600; letter-spacing: 0.005em; }
.brand img { flex: none; }
.brand:hover { color: var(--accent-strong); }
.lang { display: flex; gap: 0.15rem; font-size: 0.875rem; }
.lang a, .lang-current { padding: 0.2rem 0.45rem; border-radius: var(--radius); text-decoration: none; }
.lang-current { color: var(--muted); border: 1px solid var(--rule); }

.subnav { border-top: 1px solid var(--rule); }
.subnav .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.25rem 1rem; padding-top: 0.25rem; padding-bottom: 0.25rem; }
.sections { display: flex; flex-wrap: wrap; gap: 0.1rem; }
.sections a { padding: 0.45rem 0.6rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.sections a:hover { color: var(--ink); }
.sections a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.who { display: flex; align-items: center; gap: 0.6rem; font-size: 0.875rem; color: var(--muted); margin: 0; }
.who-name { overflow-wrap: anywhere; }

/* <main> carries .wrap too, which therefore sets only the side padding.
 * Addresses can be wider than a phone: anything in the content area may break inside a
 * word that does not fit, flex items and badges included, so the page never scrolls
 * sideways. Ordinary words never need it, so ordinary text is unchanged. */
main { flex: 1; padding-top: 1.5rem; padding-bottom: 3rem; overflow-wrap: anywhere; }

.site-footer { color: var(--muted); font-size: 0.8125rem; border-top: 1px solid var(--rule); padding: 1rem 0 1.5rem; }

/* ---------------------------------------------------------------- type */

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0 0 0.6rem; }
h1 { font-size: 1.85rem; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; margin-top: 2rem; }
h3 { font-size: 1.1rem; margin-top: 1.25rem; }
p { margin: 0 0 0.9rem; max-width: 42rem; }
.lead { font-size: 1.075rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
code, .mono { font-family: var(--mono); font-size: 0.9em; overflow-wrap: anywhere; }

.page-head { margin-bottom: 1.5rem; }
.page-head p { margin-bottom: 0; }
.crumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: 0.35rem; }
.crumbs a { color: var(--muted); }

/* ---------------------------------------------------------------- start page */

.ways { list-style: none; margin: 1.5rem 0 0; padding: 0; border-top: 1px solid var(--rule); }
.ways li { border-bottom: 1px solid var(--rule); }
.ways a { display: block; padding: 1.1rem 0.25rem; text-decoration: none; color: var(--ink); }
.ways a:hover .way-title { color: var(--accent-strong); text-decoration: underline; }
.way-title { display: block; font-family: var(--serif); font-size: 1.25rem; font-weight: 600; color: var(--accent); }
.way-text { display: block; color: var(--muted); margin-top: 0.15rem; }

/* ---------------------------------------------------------------- panels and rows */

.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.1rem 1.15rem; margin: 0 0 1.25rem; }
.panel > h2:first-child, .panel > h3:first-child, .check-item > h3:first-child { margin-top: 0; }
.panel-danger { border-color: color-mix(in srgb, var(--red) 45%, var(--rule)); }

.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.35rem 1rem; align-items: start; padding: 0.8rem 0.15rem; border-bottom: 1px solid var(--rule); }
.row-main { min-width: 0; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-title a { text-decoration: none; }
.row-title a:hover { text-decoration: underline; }
.row-meta { color: var(--muted); font-size: 0.875rem; display: flex; flex-wrap: wrap; gap: 0.2rem 0.9rem; margin-top: 0.15rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }
.row-detail { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- space between blocks
 * One rule for the whole portal: a card, a list, a check list, a notice, a form or a
 * check result keeps 1.25rem from the block above it, in the content area and inside a
 * card. A heading keeps its own smaller gap to what it introduces. Margins collapse, so
 * two cards in a row still stand 1.25rem apart, and a larger gap above (the page head,
 * the tabs) is kept. */
:is(main, .panel) > :not(h1, h2, h3) + :is(.panel, .rows, .check-list, .banner, .flash, .form, .filters, dl.kv, .check-result) { margin-top: 1.25rem; }

/* ---------------------------------------------------------------- domain sections */

.tabs { display: flex; flex-wrap: wrap; gap: 0.1rem 0.25rem; border-bottom: 1px solid var(--rule); margin: -0.5rem 0 1.5rem; }
.tabs a { padding: 0.5rem 0.65rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.targets { list-style: none; margin: 0.35rem 0 0; padding: 0; display: grid; gap: 0.3rem; }
.targets li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; overflow-wrap: anywhere; }
.inline-form { display: inline; }

@media (max-width: 36rem) {
  .row { grid-template-columns: minmax(0, 1fr); }
  .row-actions { justify-content: flex-start; }
}

dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.35rem 1rem; margin: 0 0 1rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 30rem) {
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
  dl.kv dd { margin-bottom: 0.5rem; }
}

.counts { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; margin: 0 0 1rem; padding: 0; list-style: none; color: var(--muted); }
.counts strong { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- badges */

.badge { display: inline-flex; align-items: center; gap: 0.3rem; max-width: 100%; padding: 0.05rem 0.5rem; border-radius: 0.75rem; font-size: 0.8125rem; font-weight: 600; line-height: 1.5; border: 1px solid transparent; white-space: normal; }
.badge::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; flex: none; }
.badge-green { color: var(--green); background: var(--green-soft); }
.badge-yellow { color: var(--amber); background: var(--amber-soft); }
.badge-red { color: var(--red); background: var(--red-soft); }
.badge-info { color: var(--info); background: var(--info-soft); }
.badge-muted { color: var(--muted); background: transparent; border-color: var(--rule); }
.badge-protected { color: var(--accent-strong); background: var(--accent-soft); }
.badge-protected::before { border-radius: 1px; width: 0.45rem; height: 0.55rem; }

/* ---------------------------------------------------------------- notices */

.flash, .banner { border-radius: var(--radius); padding: 0.75rem 0.95rem; margin: 0 0 1.25rem; border: 1px solid; }
.flash p:last-child, .banner p:last-child { margin-bottom: 0; }
.flash-ok { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.flash-error { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.flash-warn, .banner-warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.banner-info, .flash-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.banner-danger { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
/* how a mailbox receives mail: a badge, a short why, the switch */
.reception { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; margin: 0.35rem 0 0; }
.reception .hint { flex-basis: 100%; margin: 0; }
.banner strong, .flash strong { font-weight: 600; }

.message { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.4rem 1.25rem 0.6rem; max-width: 40rem; }
.message-error { border-left: 4px solid var(--red); }
.message-ok { border-left: 4px solid var(--green); }
.message-info { border-left: 4px solid var(--accent); }

/* ---------------------------------------------------------------- forms */

form { margin: 0; }
.form { display: grid; gap: 0.95rem; max-width: 30rem; }
.form.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem; max-width: none; }
.field { display: grid; gap: 0.3rem; }
.field label, .legend { font-weight: 600; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0; }
.field-error { color: var(--red); font-size: 0.875rem; font-weight: 600; margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
legend { font-weight: 600; padding: 0; margin-bottom: 0.3rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="date"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  min-height: 2.75rem;
}
textarea { min-height: 5rem; resize: vertical; }
input[aria-invalid="true"] { border-color: var(--red); }
.check { display: flex; gap: 0.55rem; align-items: flex-start; }
.check input { margin-top: 0.3rem; width: 1.1rem; height: 1.1rem; flex: none; }
.addr { display: flex; align-items: stretch; }
.addr input { flex: 1 1 8rem; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
/* a long domain wraps inside its box rather than pushing the field off a phone screen */
.addr span { display: flex; align-items: center; min-width: 0; max-width: 60%; padding: 0 0.7rem; border: 1px solid var(--rule-strong); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; background: var(--paper); color: var(--muted); }

.button, button.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.75rem; padding: 0.55rem 1.05rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--on-accent); background: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--radius);
}
.button:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--on-accent); }
.button.secondary { color: var(--accent); background: var(--surface); border-color: var(--rule-strong); }
.button.secondary:hover { border-color: var(--accent); color: var(--accent-strong); }
.button.danger { background: var(--red); border-color: var(--red); color: #fff; }
.button.danger:hover { filter: brightness(0.92); }
.button.small { min-height: 2.25rem; padding: 0.3rem 0.75rem; font-size: 0.875rem; }
.button[disabled] { opacity: 0.5; cursor: not-allowed; }
.link-button { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 0.15em; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin-top: 0.25rem; }

/* a busy form (public/app.js): the pressed button keeps its size, a spinner in its text colour
   takes the place of the label (the label stays for screen readers) */
.is-busy { position: relative; cursor: progress; -webkit-text-fill-color: transparent; text-decoration-color: transparent; }
.is-busy::after {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 1.1em; height: 1.1em; margin: -0.55em 0 0 -0.55em;
  border: 0.15em solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: busy-spin 0.8s linear infinite;
}
form[aria-busy="true"] [aria-disabled="true"] { cursor: progress; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------------------------------------------------------------- records to copy */

.record { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.5rem; align-items: start; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.55rem 0.65rem; margin: 0.25rem 0 0.75rem; }
.record code { white-space: pre-wrap; word-break: break-all; font-size: 0.85rem; }
.record .copy[hidden] { display: none; }
.secret-link { font-size: 0.95rem; }

/* ---------------------------------------------------------------- dns checks */

.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.check-item { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.9rem 1rem; }
.check-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; margin-bottom: 0.4rem; }
.check-head h3 { margin: 0; }

/* ---------------------------------------------------------------- bans */

.ban-logins { display: flex; flex-wrap: wrap; gap: 0.3rem 0.6rem; }
details { margin-top: 0.4rem; }
details summary { cursor: pointer; color: var(--accent); font-size: 0.875rem; }
.loglines { margin: 0.4rem 0 0; padding: 0.5rem 0.65rem; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); list-style: none; font-family: var(--mono); font-size: 0.78rem; }
.loglines li { white-space: pre-wrap; word-break: break-all; padding: 0.15rem 0; }
.loglines li + li { border-top: 1px dashed var(--rule); }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.6rem; align-items: end; margin-bottom: 1.25rem; }

.pager { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 1rem; }
.pager .current { color: var(--muted); }

@media (max-width: 36rem) {
  h1 { font-size: 1.5rem; }
  .bar { flex-wrap: wrap; padding-top: 0.4rem; padding-bottom: 0.4rem; }
  .brand span { font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  /* `*` does not reach pseudo-elements: the spinner stands still as an open ring */
  .is-busy::after { animation: none; }
}
