/* AardMail admin — calm, single-purpose ops console.
   One file, no framework, system-ui. V1 tradeoff: this is an internal
   single-operator tool, so the bar is "legible and trustworthy at a glance",
   not on-brand polish. All server-rendered class hooks (.card/.ok/.bad/.muted/
   .num/.nav/.container/.inline/.test-result) are preserved. */
:root {
  color-scheme: light;
  /* status colors — referenced by server-rendered .ok/.bad */
  --ok: #16a34a;
  --bad: #dc2626;
  /* palette */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --ok-soft: #f0fdf4;
  --bad-soft: #fef2f2;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- top nav ---------- */
.nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: 56px;
  padding: 0 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.nav .brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-right: auto;
  text-decoration: none;
  color: var(--text);
}
.nav .brand-text { font-weight: 700; font-size: 1rem; letter-spacing: -.01em; line-height: 1; }
.nav .brand-text small {
  display: block;
  font-size: .68rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 3px;
}
.nav-links { display: flex; align-items: center; gap: .15rem; }
.nav-links a {
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  font-size: .9rem;
  padding: .4rem .65rem;
  border-radius: var(--radius-sm);
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #1e40af);
  display: inline-block;
  flex: none;
}

/* ---------- layout ---------- */
.container { max-width: 1000px; margin: 2rem auto; padding: 0 1.25rem; }
h1 { font-size: 1.45rem; font-weight: 700; margin: 0 0 .25rem; letter-spacing: -.02em; }
h2 {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 1.75rem 0 .75rem;
}
.page-head { margin-bottom: .5rem; }
.page-head p { margin: 0 0 1.5rem; color: var(--text-2); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .82rem; color: var(--text-2); }

/* ---------- stat cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.card .num { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.card .muted { color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.card.bad {
  border-color: #fecaca;
  background: linear-gradient(0deg, var(--bad-soft), var(--surface) 65%);
}
.card.bad .num { color: var(--bad); }

/* section card for forms */
.card.form-card { padding: 1.25rem; margin-bottom: 1.5rem; }

/* ---------- status pills + banners ----------
   .ok/.bad land on <span> (test results, status pills) and <p> (inline
   messages from render.ts inlineMessage). Element-scoped rules keep both
   contexts styled without touching server class output. */
span.ok, span.bad, span.off {
  display: inline-block;
  font-size: .78rem;
  font-weight: 600;
  padding: .12rem .55rem;
  border-radius: 999px;
  line-height: 1.5;
}
span.ok { color: var(--ok); background: var(--ok-soft); }
span.bad { color: var(--bad); background: var(--bad-soft); }
span.off { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); }
p.ok, p.bad {
  font-size: .85rem;
  font-weight: 500;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  margin: .75rem 0;
}
p.ok { color: var(--ok); background: var(--ok-soft); }
p.bad { color: var(--bad); background: var(--bad-soft); }

/* ---------- buttons ---------- */
button, .btn {
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  line-height: 1.2;
  padding: .5rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: background .12s, border-color .12s, box-shadow .12s, color .12s;
}
button:hover, .btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--bad); border-color: #fecaca; background: var(--surface); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ghost { border-color: transparent; color: var(--text-2); background: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: .3rem .55rem; font-size: .82rem; }
button:focus-visible, .btn:focus-visible,
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- forms ---------- */
form.inline { display: inline; }
label { display: block; font-size: .8rem; font-weight: 550; color: var(--text-2); margin-bottom: .3rem; }
input, textarea, select {
  font: inherit;
  display: block;
  width: 100%;
  max-width: 420px;
  padding: .5rem .65rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
input::placeholder { color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; }
legend {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: .5rem;
  padding: 0;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem 1rem; }
.form-grid label { margin-bottom: 0; }
.form-actions { margin-top: .25rem; }
/* ntfy / password forms use the <p><label>..</label></p> pattern */
form p { margin: 0 0 .75rem; }
form p label { margin-bottom: .3rem; }

/* ---------- tabs (Notify: ntfy / Lark) ---------- */
.tabs { display: flex; gap: .2rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: 0;
  color: var(--text-2);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: .5rem .9rem;
  margin-bottom: -1px; /* overlap the .tabs bottom border so the active tab merges with content */
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.tab-active { color: var(--text); background: var(--surface); border-color: var(--border); }

/* ---------- tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: .88rem;
}
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
thead th {
  background: var(--surface-2);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
/* Row actions: short buttons only, kept on one line so the cell never wraps.
   The test-send form lives in a full-width detail row below (.acct-detail). */
td .actions { display: flex; flex-wrap: nowrap; align-items: center; gap: .3rem; }
td .actions .btn, td .actions button { white-space: nowrap; }

/* Detail row under each account: full-width cell for the test-send form so a
   long recipient or error never wraps the actions cell above. */
.acct-detail > td { background: var(--surface-2); border-bottom: 1px solid var(--border); }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; }
.inline-form label { margin-bottom: 0; }
.inline-form input { width: auto; min-width: 220px; max-width: 320px; }
.test-result { display: inline-flex; align-items: center; min-height: 1.5rem; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
}
.login-card h1 { margin: .9rem 0 .15rem; }
.login-sub { margin: 0 0 1.25rem; }
.login-brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; }

/* ---------- API docs page ---------- */
.docs h2 { margin-top: 2rem; }
.docs h3 { margin-top: 1.25rem; }
pre { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem 1rem; overflow: auto; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9em; }
pre code { background: none; border: 0; padding: 0; }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .nav { padding: .5rem 1rem; gap: .75rem; height: auto; min-height: 56px; flex-wrap: wrap; }
  .nav .brand-text small { display: none; }
  .nav-links { gap: 0; flex-wrap: wrap; }
  .nav-links a { padding: .4rem .45rem; font-size: .85rem; }
  td .actions { flex-wrap: wrap; } /* let row actions wrap on narrow screens */
  .inline-form input { min-width: 160px; }
  table { font-size: .82rem; }
  th, td { padding: .45rem .55rem; }
}
