:root {
  --bg: #f6f7f9; --card: #fff; --fg: #1c2024; --muted: #6b7280;
  --line: #e5e7eb; --accent: #2563eb; --danger: #dc2626; --ok: #16a34a;
  --warn: #d97706;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
header {
  display: flex; align-items: center; gap: 14px; padding: 14px 22px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
header h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
header .spacer { flex: 1; }
nav { display: flex; gap: 4px; }
nav a {
  padding: 6px 12px; border-radius: 7px; color: var(--muted);
  text-decoration: none; font-size: 14px;
}
nav a:hover { background: #f3f4f6; color: var(--fg); }
nav a.active { background: #eff6ff; color: var(--accent); font-weight: 600; }
.dot {
  width: 9px; height: 9px; border-radius: 50%; background: #d1d5db;
  display: inline-block; margin-right: 6px;
}
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--danger); }
.status { display: flex; align-items: center; color: var(--muted); font-size: 13px; }
main { max-width: 1000px; margin: 0 auto; padding: 22px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px 10px;
}
.card h2 { font-size: 15px; margin: 0 0 14px; }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.row.wrap { flex-wrap: wrap; }
.row .at { color: var(--muted); }
input, select, button {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; color: inherit; min-width: 0;
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.row input { flex: 1; }
hr.divider { border: none; border-top: 1px solid var(--line); margin: 0 0 14px; }
button {
  cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent);
  white-space: nowrap;
}
button:hover { filter: brightness(1.06); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { background: #fff; color: var(--fg); border-color: var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-top: 1px solid var(--line); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); border-top: none; }
tbody tr:hover { background: #fafafa; }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
th.actions, td.actions { text-align: right; white-space: nowrap; }
button.link {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--accent); padding: 4px;
  border-radius: 6px; vertical-align: middle;
}
button.link:hover { background: #eff6ff; filter: none; }
button.link.danger { color: var(--danger); }
button.link.danger:hover { background: #fef2f2; }
button.link .icon { width: 17px; height: 17px; display: block; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 8px; }
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 4px 6px;
}
.pager-btns { display: flex; gap: 8px; }
.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 10; max-width: 380px;
  padding: 11px 14px; border-radius: 8px; color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.18);
  font-size: 14px; white-space: pre-wrap;
}
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }

/* logs page */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.filters input, .filters select { padding: 6px 9px; }
.filters input#mailboxFilter { width: 230px; }
.toggle { display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--fg); cursor: pointer; }
.toggle input { width: auto; }
.logwrap { display: flex; flex-direction: column; }
.logbox {
  height: 62vh; min-height: 320px; overflow: auto; background: #0f172a; color: #e2e8f0;
  border-radius: 8px; padding: 8px 10px;
  font: 12.5px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.logbox .empty { color: #94a3b8; }
.logline { display: flex; gap: 10px; padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.logline .lt { color: #7dd3fc; flex: none; }
.logline .lp { flex: none; color: #cbd5e1; width: 118px; overflow: hidden; text-overflow: ellipsis; }
.logline .lm { color: #e2e8f0; }
.logline.other .lm { color: #cbd5e1; }
.badge {
  flex: none; display: inline-block; min-width: 46px; text-align: center; border-radius: 5px;
  padding: 1px 5px; font-size: 10.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
}
.badge.smtp { background: #1d4ed8; color: #dbeafe; }
.badge.imap { background: #047857; color: #d1fae5; }
.badge.pop3 { background: #b45309; color: #fef3c7; }
.badge.dovecot { background: #475569; color: #e2e8f0; }
.badge.other { background: #334155; color: #cbd5e1; }
.logfoot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 4px 4px; }

/* status page */
main .card + .card { margin-top: 18px; }
table.kv { width: 100%; }
table.kv th {
  text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--muted);
  font-weight: 500; width: 38%; padding: 7px 10px 7px 0; vertical-align: top;
}
table.kv td { padding: 7px 0; border-top: 1px solid var(--line); }
table.kv tr:first-child th, table.kv tr:first-child td { border-top: none; }
table.kv td code { font-size: 12.5px; }
code {
  font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #f1f5f9; border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 5px; color: var(--fg);
}
.small { font-size: 12.5px; }
.badge.ok    { background: #dcfce7; color: #166534; }
.badge.warn  { background: #fef3c7; color: #92400e; }
.badge.bad   { background: #fee2e2; color: #991b1b; }
.badge.ok, .badge.warn, .badge.bad {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
}
