/* Mail Console — operator UI.
   Information-dense and scannable: state reads at a glance, colour carries
   meaning rather than decoration. */

:root {
  --paper:        #F5F7FA;
  --surface:      #FFFFFF;
  --sunk:         #EEF1F6;
  --ink:          #12203A;
  --ink-soft:     #55617A;
  --ink-faint:    #8792A8;
  --rule:         #DCE1EA;
  --accent:       #2A4B8D;
  --accent-hover: #223F78;
  --accent-soft:  #E5EBF6;
  --pass:         #237552;
  --pass-soft:    #E0F0E8;
  --warn:         #8A6216;
  --warn-soft:    #F8EEDA;
  --fail:         #AE342A;
  --fail-soft:    #F8E5E3;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --radius: 5px;
  --shadow: 0 1px 2px rgba(18, 32, 58, .06), 0 4px 14px rgba(18, 32, 58, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #0D1521;
    --surface:      #15202E;
    --sunk:         #1C2836;
    --ink:          #E5EAF2;
    --ink-soft:     #A6B2C3;
    --ink-faint:    #748094;
    --rule:         #293648;
    --accent:       #7BA3E0;
    --accent-hover: #94B6EC;
    --accent-soft:  #1A2B45;
    --pass:         #63C295;
    --pass-soft:    #142A21;
    --warn:         #D6B263;
    --warn-soft:    #2C2514;
    --fail:         #E5847A;
    --fail-soft:    #321A18;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }

/* The UA stylesheet hides [hidden] with display:none, but any author display
   rule outranks it — and several elements here set display:grid/flex. Without
   this, the modal backdrop and the login shell stay visible when hidden. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
.muted { color: var(--ink-soft); font-size: .9rem; }
.opt { color: var(--ink-faint); font-weight: 400; font-size: .82em; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 9px; }
/* Drawn as real SVG strokes — a CSS-border envelope flap disappears once
   clipped to a 1.5px line. */
.brand-mark {
  width: 18px; height: 18px;
  flex: none;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-name { font-weight: 600; letter-spacing: -.01em; }

/* ---------- controls ---------- */
button {
  font-family: inherit; font-size: .9rem; font-weight: 500;
  padding: 8px 15px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background .12s ease;
}
button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--ink-soft); border-color: var(--rule); }
button.ghost:hover { background: var(--sunk); color: var(--ink); }
button.danger { background: transparent; color: var(--fail); border-color: var(--rule); }
button.danger:hover { background: var(--fail-soft); border-color: var(--fail); }
button.tiny { padding: 4px 10px; font-size: .8rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label {
  display: block;
  font-size: .82rem; font-weight: 500;
  margin-bottom: 5px;
  color: var(--ink-soft);
}
input, select {
  width: 100%;
  font-family: inherit; font-size: .92rem;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- login ---------- */
.login-shell {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { font-size: 1.35rem; margin-top: 10px; }
.login-card .muted { margin-bottom: 6px; }
.login-card button { margin-top: 4px; padding: 10px; }

.form-error {
  font-size: .86rem;
  color: var(--fail);
  background: var(--fail-soft);
  border-radius: var(--radius);
  padding: 9px 11px;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 0 22px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; z-index: 10;
}
.tabs { display: flex; gap: 2px; margin-right: auto; }
.tab {
  background: transparent; border: none; color: var(--ink-soft);
  padding: 8px 13px; border-radius: var(--radius);
  font-weight: 500;
}
.tab:hover { background: var(--sunk); color: var(--ink); }
.tab.active { background: var(--accent-soft); color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 14px; }
.health {
  font-family: var(--mono); font-size: .75rem;
  padding: 3px 9px; border-radius: 100px;
  background: var(--sunk); color: var(--ink-faint);
  white-space: nowrap;
}
.health.ok   { background: var(--pass-soft); color: var(--pass); }
.health.bad  { background: var(--fail-soft); color: var(--fail); }

/* ---------- layout ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 32px 22px 80px; }
.view-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 22px;
}
.view-head h2 { font-size: 1.3rem; margin-bottom: 3px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 20px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.add-form { display: flex; flex-direction: column; gap: 14px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field { flex: 1 1 220px; }
.field.narrow { flex: 0 1 160px; }
.actions { display: flex; gap: 9px; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; gap: 11px; }

.item {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.item-head {
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
}
.item-title { font-weight: 600; font-size: 1rem; }
.item-sub {
  font-family: var(--mono); font-size: .78rem; color: var(--ink-faint);
  margin-top: 3px;
}
.item-actions { margin-left: auto; display: flex; gap: 7px; }

.badge {
  font-family: var(--mono); font-size: .72rem; font-weight: 500;
  padding: 2px 8px; border-radius: 100px;
  background: var(--sunk); color: var(--ink-faint);
  white-space: nowrap;
}
.badge.ok   { background: var(--pass-soft); color: var(--pass); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad  { background: var(--fail-soft); color: var(--fail); }

.empty {
  text-align: center; padding: 52px 20px;
  color: var(--ink-faint);
  border: 1px dashed var(--rule);
  border-radius: 7px;
}

/* ---------- DNS records ---------- */
.dns { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.dns-row {
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 11px 13px;
}
.dns-meta {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 7px; flex-wrap: wrap;
}
.dns-type {
  font-family: var(--mono); font-size: .72rem; font-weight: 500;
  background: var(--accent-soft); color: var(--accent);
  padding: 2px 7px; border-radius: 3px;
}
.dns-name { font-family: var(--mono); font-size: .8rem; word-break: break-all; }
.dns-value {
  font-family: var(--mono); font-size: .76rem; line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 9px 11px;
  word-break: break-all;
  max-height: 96px; overflow-y: auto;
}
.dns-note { font-size: .78rem; color: var(--ink-soft); margin-top: 7px; }
.copy { margin-left: auto; }

.reveal {
  font-family: var(--mono); font-size: .82rem;
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  padding: 12px 14px;
  word-break: break-all;
  margin: 12px 0;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 18, 30, .55);
  display: grid; place-items: center;
  padding: 22px;
}
.modal {
  background: var(--surface);
  border-radius: 9px;
  border: 1px solid var(--rule);
  padding: 26px;
  width: 100%; max-width: 660px;
  max-height: 84vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(10, 18, 30, .3);
}
.modal h3 { font-size: 1.15rem; margin-bottom: 6px; }
.modal .actions { margin-top: 20px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  font-size: .88rem;
  padding: 10px 18px; border-radius: 100px;
  box-shadow: 0 6px 22px rgba(10,18,30,.3);
  z-index: 100;
}

@media (max-width: 720px) {
  .topbar { gap: 14px; padding: 0 14px; height: auto; flex-wrap: wrap; padding-block: 10px; }
  .tabs { order: 3; width: 100%; }
  .wrap { padding: 22px 14px 60px; }
  .view-head { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
