/* Postmaster - one stylesheet, design tokens first. Light and dark are each their own set of steps. */

:root {
  color-scheme: light;
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --border: #e3e6ec;
  --border-strong: #d0d5de;
  --text: #0f1219;
  --text-2: #4a5263;
  --text-3: #7a8294;
  --accent: #5847e0;
  --accent-hover: #4a39d0;
  --accent-soft: rgba(88, 71, 224, 0.09);
  --accent-ink: #ffffff;
  --focus: rgba(88, 71, 224, 0.4);
  --ok: #0ca30c;
  --warn: #e39b00;
  --serious: #ec835a;
  --fail: #d03b3b;
  --info: #2a78d6;
  --ok-soft: rgba(12, 163, 12, 0.09);
  --warn-soft: rgba(250, 178, 25, 0.14);
  --fail-soft: rgba(208, 59, 59, 0.09);
  --info-soft: rgba(42, 120, 214, 0.09);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #e9ebef;
  --axis: #c3c7cf;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.16);
  --overlay: rgba(15, 18, 25, 0.38);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 236px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0b0d11;
    --surface: #15181e;
    --surface-2: #1a1e25;
    --surface-3: #222731;
    --border: #262b34;
    --border-strong: #343a46;
    --text: #eceef2;
    --text-2: #b3b9c4;
    --text-3: #868d9b;
    --accent: #8d82ff;
    --accent-hover: #a49bff;
    --accent-soft: rgba(141, 130, 255, 0.14);
    --accent-ink: #0b0d11;
    --focus: rgba(141, 130, 255, 0.5);
    --ok-soft: rgba(12, 163, 12, 0.16);
    --warn-soft: rgba(250, 178, 25, 0.14);
    --fail-soft: rgba(208, 59, 59, 0.18);
    --info-soft: rgba(57, 135, 229, 0.16);
    --warn: #fab219;
    --fail: #e05252;
    --info: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --grid: #252a32;
    --axis: #3a404b;
    --shadow: none;
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
    --overlay: rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0d11;
  --surface: #15181e;
  --surface-2: #1a1e25;
  --surface-3: #222731;
  --border: #262b34;
  --border-strong: #343a46;
  --text: #eceef2;
  --text-2: #b3b9c4;
  --text-3: #868d9b;
  --accent: #8d82ff;
  --accent-hover: #a49bff;
  --accent-soft: rgba(141, 130, 255, 0.14);
  --accent-ink: #0b0d11;
  --focus: rgba(141, 130, 255, 0.5);
  --ok-soft: rgba(12, 163, 12, 0.16);
  --warn-soft: rgba(250, 178, 25, 0.14);
  --fail-soft: rgba(208, 59, 59, 0.18);
  --info-soft: rgba(57, 135, 229, 0.16);
  --warn: #fab219;
  --fail: #e05252;
  --info: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #252a32;
  --axis: #3a404b;
  --shadow: none;
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.55);
  --overlay: rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-3); }
.secondary { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* --- Boot and sign-in ---------------------------------------------------------------------------------------- */

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent 60%),
  radial-gradient(700px 400px at 110% 110%, var(--info-soft), transparent 60%), var(--bg); }
.signin-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px 28px; box-shadow: var(--shadow-lg); }
.signin-card h1 { font-size: 20px; margin: 18px 0 4px; letter-spacing: -0.01em; }
.signin-card p { margin: 0 0 22px; color: var(--text-2); }
.signin-card form { display: grid; gap: 14px; }
.signin-card .btn { width: 100%; justify-content: center; height: 40px; }

.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #6d5cff, #3d8bfd); box-shadow: 0 6px 18px rgba(93, 80, 230, 0.35); }
.brand-mark .icon { width: 20px; height: 20px; stroke-width: 2; }

/* --- Forms and buttons ----------------------------------------------------------------------------------------- */

label.field { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.input, .select {
  height: 36px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); width: 100%; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-3); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.code { font-family: var(--mono); letter-spacing: 0.3em; text-align: center; font-size: 18px; height: 44px; }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { padding-left: 34px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--fail); }
.btn.danger:hover { background: var(--fail-soft); border-color: var(--fail); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; gap: 5px; }
.btn.icon-only { width: 34px; padding: 0; justify-content: center; }
.btn.sm.icon-only { width: 28px; }

.segmented { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 7px; color: var(--text-2); font-weight: 500; cursor: pointer; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
:root[data-theme="dark"] .segmented button[aria-pressed="true"] { background: var(--border-strong); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .segmented button[aria-pressed="true"] { background: var(--border-strong); } }

.form-error { color: var(--fail); font-size: 13px; min-height: 0; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.form-row > * { flex: 1 1 200px; }
.form-row > .btn { flex: none; }

/* --- Layout ---------------------------------------------------------------------------------------------------- */

.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 18px 12px; border-right: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; }
.brand b { display: block; font-size: 15px; letter-spacing: -0.01em; }
.brand span { display: block; font-size: 12px; color: var(--text-3); }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: 9px;
  color: var(--text-2); font-weight: 500; text-decoration: none; transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.nav a[aria-current="page"] .icon { color: var(--accent); }
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; display: flex; gap: 6px; align-items: center; padding: 10px 4px 0; border-top: 1px solid var(--border); }
.sidebar-foot .who { flex: 1; min-width: 0; padding-left: 6px; font-size: 13px; color: var(--text-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { width: 100%; max-width: 1320px; margin: 0 auto; padding: 28px 32px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; font-weight: 650; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { flex: 1 1 260px; max-width: 420px; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.stack { display: grid; gap: 16px; }
.page-stack { display: grid; gap: 16px; }
.toolbar .grow { flex: 1; }
.card-body.toolbar { margin: 0; padding-bottom: 12px; }
details.card > summary { list-style: none; cursor: pointer; padding-bottom: 14px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary { padding-bottom: 0; }

.backdrop { display: none; }

@media (max-width: 1100px) {
  .grid.two, .grid.split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 270px; transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: var(--overlay); }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; height: 54px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .topbar b { font-size: 15px; }
  .content { padding: 18px 16px 40px; }
  .page-head h1 { font-size: 20px; }
}

/* --- Cards and figures ----------------------------------------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-head p { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.card-body { padding: 14px 18px 18px; }
.card-body.flush { padding: 10px 0 4px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; display: block; color: inherit; }
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); }
.kpi-label { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; }
.kpi-label .swatch { width: 10px; height: 10px; border-radius: 3px; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 6px; line-height: 1.15; }
.kpi-sub { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }

.verdict { display: flex; gap: 16px; align-items: flex-start; padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.verdict::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--text-3); }
.verdict.ok::before { background: var(--ok); }
.verdict.warn::before { background: var(--warn); }
.verdict.fail::before { background: var(--fail); }
.verdict .status-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.verdict h2 { margin: 0; font-size: 16px; letter-spacing: -0.01em; }
.verdict p { margin: 5px 0 0; color: var(--text-2); max-width: 80ch; }
.verdict .verdict-actions { margin-left: auto; display: flex; gap: 8px; align-self: center; }
@media (max-width: 700px) { .verdict { flex-wrap: wrap; } .verdict .verdict-actions { margin-left: 0; } }

.status-icon.ok { background: var(--ok-soft); color: var(--ok); }
.status-icon.warn { background: var(--warn-soft); color: var(--warn); }
.status-icon.fail { background: var(--fail-soft); color: var(--fail); }
.status-icon.info, .status-icon.unknown { background: var(--info-soft); color: var(--info); }

/* --- Pills, badges, callouts ------------------------------------------------------------------------------------ */

.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px 0 7px; border-radius: 999px; font-size: 12.5px; font-weight: 500; color: var(--text); background: var(--surface-3); white-space: nowrap; }
.pill .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.pill.ok { background: var(--ok-soft); } .pill.ok .icon { color: var(--ok); }
.pill.warn { background: var(--warn-soft); } .pill.warn .icon { color: var(--warn); }
.pill.fail { background: var(--fail-soft); } .pill.fail .icon { color: var(--fail); }
.pill.info { background: var(--info-soft); } .pill.info .icon { color: var(--info); }
.pill.muted { color: var(--text-2); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }
.badge.accent { background: var(--accent); color: var(--accent-ink); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); background: var(--surface-3); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }

.callout { border-radius: 10px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); display: grid; gap: 4px; }
.callout b { font-weight: 600; }
.callout p { margin: 0; color: var(--text-2); }
.callout.fail { background: var(--fail-soft); border-color: transparent; }
.callout.warn { background: var(--warn-soft); border-color: transparent; }
.callout.info { background: var(--info-soft); border-color: transparent; }
.callout.ok { background: var(--ok-soft); border-color: transparent; }
.callout .fix { margin-top: 4px; color: var(--text); }

/* --- Tables ---------------------------------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; }
.cell-main { font-weight: 500; }
.cell-sub { color: var(--text-3); font-size: 12.5px; }
.cell-clip { max-width: 360px; }
.empty { padding: 36px 20px; text-align: center; color: var(--text-3); }
.empty .icon { width: 28px; height: 28px; margin-bottom: 8px; color: var(--text-3); }
.empty b { display: block; color: var(--text-2); font-weight: 600; margin-bottom: 2px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; color: var(--text-3); font-size: 13px; border-top: 1px solid var(--border); }

.dir { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.dir .icon { width: 16px; height: 16px; }

/* --- Lists ----------------------------------------------------------------------------------------------------- */

.list { display: grid; }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 18px; border-top: 1px solid var(--border); color: inherit; }
.list-item:first-child { border-top: 0; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .status-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.list-item .status-icon .icon { width: 16px; height: 16px; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; }
.list-item .detail { color: var(--text-2); font-size: 13px; margin-top: 1px; }

/* --- Chart ----------------------------------------------------------------------------------------------------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 240px; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .column { cursor: default; }
.chart .column:focus { outline: none; }
.chart .column .hit { fill: transparent; }
.chart .column:hover .hit, .chart .column:focus-visible .hit { fill: var(--surface-3); }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .s3 { fill: var(--series-3); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .s1, .swatch.s1 { background: var(--series-1); }
.legend .s2, .swatch.s2 { background: var(--series-2); }
.legend .s3, .swatch.s3 { background: var(--series-3); }
.tooltip { position: absolute; pointer-events: none; z-index: 5; min-width: 150px; padding: 9px 11px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); font-size: 12.5px; }
.tooltip .t-head { color: var(--text-2); margin-bottom: 5px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-row i { width: 12px; height: 2px; border-radius: 2px; }
.tooltip .t-row b { font-weight: 650; min-width: 22px; font-variant-numeric: tabular-nums; }
.tooltip .t-row span { color: var(--text-2); }

/* --- Message detail, timeline ------------------------------------------------------------------------------------ */

.facts { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 7px 14px; margin: 0; }
.facts dt { color: var(--text-3); font-size: 13px; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.recipient { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; }
.recipient-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.reply { font-family: var(--mono); font-size: 12px; color: var(--text-2); background: var(--surface-2); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 74px 70px minmax(0, 1fr); gap: 10px; padding: 6px 0; border-top: 1px dashed var(--border); font-size: 12.5px; }
.timeline li:first-child { border-top: 0; }
.timeline time { color: var(--text-3); font-variant-numeric: tabular-nums; }
.timeline .prog { color: var(--text-2); font-weight: 500; }
.timeline .txt { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; color: var(--text); }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 18px 0 8px; }

/* --- Drawer, dialog, toasts --------------------------------------------------------------------------------------- */

.drawer-backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 50; animation: fade .15s ease; }
.drawer { position: fixed; z-index: 51; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .18s ease; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { padding: 18px; overflow-y: auto; display: grid; gap: 14px; align-content: start; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }

dialog.modal { border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(520px, calc(100% - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.modal.wide { width: min(900px, calc(100% - 32px)); }
dialog.modal::backdrop { background: var(--overlay); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 6px; }
.modal-head h2 { margin: 0; font-size: 16px; flex: 1; }
.modal-body { padding: 8px 18px 18px; display: grid; gap: 12px; color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
pre.source { margin: 0; max-height: 65vh; overflow: auto; font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: 10px; padding: 12px; color: var(--text); }

.toasts { position: fixed; z-index: 60; right: 16px; bottom: 16px; display: grid; gap: 8px; }
.toast { display: flex; align-items: center; gap: 9px; padding: 10px 14px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 500; animation: slide .18s ease; max-width: min(420px, calc(100vw - 32px)); }
.toast.fail { background: var(--fail); color: #fff; }

/* --- Checks ---------------------------------------------------------------------------------------------------- */

.checks { display: grid; }
.check { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 13px 18px; border-top: 1px solid var(--border); }
.check:first-child { border-top: 0; }
.check .status-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.check .status-icon .icon { width: 16px; height: 16px; stroke-width: 2.2; }
.check-title { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; justify-content: space-between; }
.check-title b { font-weight: 600; }
.check-value { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); overflow-wrap: anywhere; }
.check-detail { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.check-fix { margin-top: 8px; display: flex; gap: 8px; align-items: flex-start; font-size: 13px; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.check-fix .txt { flex: 1; overflow-wrap: anywhere; }
.check-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; }

/* --- Mailbox --------------------------------------------------------------------------------------------------- */

.mailbox { display: grid; grid-template-columns: 200px minmax(260px, 380px) minmax(0, 1fr); height: calc(100vh - 150px); min-height: 520px; overflow: hidden; }
.mailbox > section { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.folders { border-right: 1px solid var(--border); padding: 10px 8px; overflow-y: auto; }
.folders select { margin-bottom: 8px; }
.folder { display: flex; align-items: center; gap: 9px; width: 100%; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; font-weight: 500; text-align: left; }
.folder:hover { background: var(--surface-3); color: var(--text); }
.folder[aria-current="true"] { background: var(--accent-soft); color: var(--text); }
.folder .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-list { border-right: 1px solid var(--border); }
.mail-list .search { padding: 10px; border-bottom: 1px solid var(--border); }
.mail-list .search .icon { left: 20px; }
.mail-items { overflow-y: auto; flex: 1; }
.mail-item { display: grid; gap: 2px; width: 100%; padding: 11px 14px 11px 22px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: inherit; text-align: left; cursor: pointer; position: relative; }
.mail-item:hover { background: var(--surface-2); }
.mail-item[aria-current="true"] { background: var(--accent-soft); }
.mail-item .row1 { display: flex; gap: 8px; align-items: baseline; }
.mail-item .from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.mail-item .date { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.mail-item .subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item .snippet { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item.unread .from, .mail-item.unread .subject { color: var(--text); font-weight: 600; }
.mail-item.unread::before { content: ""; position: absolute; left: 9px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.reader { overflow-y: auto; }
.reader-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.reader-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.reader-meta { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 3px 10px; font-size: 13px; }
.reader-meta dt { color: var(--text-3); }
.reader-meta dd { margin: 0; overflow-wrap: anywhere; }
.reader-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.reader-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.reader-body { padding: 14px 20px 20px; display: grid; gap: 12px; }
.mail-frame { width: 100%; height: 62vh; min-height: 360px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; }
.attachment { display: inline-flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); font-size: 13px; max-width: 100%; }
.attachment:hover { background: var(--surface-2); text-decoration: none; }
.attachment .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.mobile-back { display: none; }
@media (max-width: 1100px) {
  .mailbox { grid-template-columns: 180px minmax(0, 1fr); }
  .mailbox .reader { display: none; }
  .mailbox.reading .mail-list { display: none; }
  .mailbox.reading .reader { display: flex; }
  .mobile-back { display: inline-flex; }
}
@media (max-width: 700px) {
  .mailbox { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 0; overflow: visible; }
  .folders { border-right: 0; border-bottom: 1px solid var(--border); display: flex; gap: 4px; overflow-x: auto; }
  .folders select { margin: 0 8px 0 0; width: auto; }
  .folder { width: auto; flex: none; }
  .mail-list { border-right: 0; }
  .mail-items { max-height: none; }
  .mail-frame { height: 70vh; }
}

/* --- Live log -------------------------------------------------------------------------------------------------- */

.log { height: 420px; overflow-y: auto; background: var(--surface-2); border-top: 1px solid var(--border); font: 12px/1.6 var(--mono); padding: 8px 0; border-radius: 0 0 var(--radius) var(--radius); }
.log-line { display: grid; grid-template-columns: 70px 96px minmax(0, 1fr); gap: 10px; padding: 0 14px 0 12px; border-left: 3px solid transparent; }
.log-line time { color: var(--text-3); }
.log-line .prog { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-line .txt { overflow-wrap: anywhere; color: var(--text); }
.log-line.ok { border-left-color: var(--ok); }
.log-line.warn { border-left-color: var(--warn); }
.log-line.error { border-left-color: var(--fail); background: var(--fail-soft); }
@media (max-width: 700px) { .log-line { grid-template-columns: 62px minmax(0, 1fr); } .log-line .prog { display: none; } }

.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.service { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.service .status-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.service .status-icon .icon { width: 15px; height: 15px; stroke-width: 2.2; }
.service .grow { min-width: 0; }
.service small { display: block; color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.qr { width: 196px; height: 196px; border-radius: 10px; border: 1px solid var(--border); background: #fff; padding: 6px; }
.totp-setup { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 600px) { .totp-setup { grid-template-columns: minmax(0, 1fr); } }
.secret { font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; overflow-wrap: anywhere; }
