/* Pastor Mailer shared design system -- used by index.html and admin.html.
   Dark teal is the default; [data-theme="light"] on <html> swaps the tokens. */
:root {
  --bg: #0a0c0f;
  --bg-inset: #06070a;
  --surface: #14171b;
  --surface-2: #1a1e23;
  --surface-3: #222730;
  --border: rgba(240, 237, 230, 0.09);
  --border-strong: rgba(240, 237, 230, 0.18);
  --text-main: #f0ede6;
  --text-muted: #9aa0a8;
  --text-faint: #6b6e75;
  --primary: #2dd4bf;
  --primary-hover: #5eead4;
  --primary-dim: rgba(45, 212, 191, 0.14);
  --on-primary: #06120f;
  --danger: #f37272;
  --danger-dim: rgba(243, 114, 114, 0.12);
  --warning: #f0b43c;
  --warning-dim: rgba(240, 180, 60, 0.12);
  --success: #4fd68c;
  --success-dim: rgba(79, 214, 140, 0.12);
  --info: #5ec8f2;
  --info-dim: rgba(94, 200, 242, 0.12);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 232px;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.28);
  --shadow-md: 0 2px 4px rgb(0 0 0 / 0.3), 0 8px 16px -4px rgb(0 0 0 / 0.35);
  --shadow-lg: 0 24px 48px -12px rgb(0 0 0 / 0.55);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f6f8;
  --bg-inset: #eceff3;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --surface-3: #e7ebf0;
  --border: rgba(15, 23, 30, 0.1);
  --border-strong: rgba(15, 23, 30, 0.2);
  --text-main: #11181f;
  --text-muted: #55606b;
  --text-faint: #8a939c;
  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-dim: rgba(13, 148, 136, 0.12);
  --on-primary: #ffffff;
  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.1);
  --warning: #b45309;
  --warning-dim: rgba(180, 83, 9, 0.1);
  --success: #15803d;
  --success-dim: rgba(21, 128, 61, 0.1);
  --info: #0369a1;
  --info-dim: rgba(3, 105, 161, 0.1);
  --shadow-sm: 0 1px 2px rgb(15 23 30 / 0.08);
  --shadow-md: 0 2px 4px rgb(15 23 30 / 0.08), 0 8px 16px -4px rgb(15 23 30 / 0.1);
  --shadow-lg: 0 24px 48px -12px rgb(15 23 30 / 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

.mono { font-family: var(--mono); }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- icons ---------- */
.ic {
  width: 1.15em; height: 1.15em; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.2em;
}
.ic.sm { width: 0.95em; height: 0.95em; }
.ic.lg { width: 1.6em; height: 1.6em; }
.ic.xl { width: 2.6em; height: 2.6em; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidenav {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: var(--primary-dim); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
}
.brand-name { font-weight: 700; letter-spacing: -0.015em; font-size: 1rem; line-height: 1.15; }
.brand-sub { font-size: 0.7rem; color: var(--text-faint); font-family: var(--mono); letter-spacing: 0.02em; }

.nav-label {
  font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; color: var(--text-muted); font: inherit; font-weight: 500; font-size: 0.9rem;
  cursor: pointer; text-decoration: none; text-align: left;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text-main); }
.nav-item.active {
  background: var(--primary-dim); color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 28%, transparent);
}
.nav-item .ic { font-size: 1.05rem; }
.nav-item .ext { margin-left: auto; opacity: 0.55; }

.nav-spacer { flex: 1; }
.nav-foot { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.content { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 32px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.topbar .crumb { color: var(--text-faint); font-size: 0.82rem; }
.topbar-spacer { flex: 1; }
.btn.menu-btn { display: none; }

.page { padding: 28px 32px 80px; max-width: 1500px; width: 100%; }

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 600; background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border); white-space: nowrap;
}
.chip.ok { background: var(--success-dim); color: var(--success); border-color: transparent; }
.chip.warn { background: var(--warning-dim); color: var(--warning); border-color: transparent; }
.chip.bad { background: var(--danger-dim); color: var(--danger); border-color: transparent; }
.chip.info { background: var(--info-dim); color: var(--info); border-color: transparent; }
.chip.brand { background: var(--primary-dim); color: var(--primary); border-color: transparent; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.live .dot { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; text-transform: capitalize;
}
.badge.sent, .badge.info { background: var(--info-dim); color: var(--info); }
.badge.success { background: var(--success-dim); color: var(--success); }
.badge.error, .badge.failed { background: var(--danger-dim); color: var(--danger); }
.badge.skipped { background: var(--warning-dim); color: var(--warning); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.card-head h2, .card > h2 { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; }
.card-head h2 .ic { color: var(--primary); }
.card-head .grow { flex: 1; }
.card .sub { color: var(--text-muted); font-size: 0.84rem; margin-bottom: 18px; margin-top: 2px; }

.step { display: flex; align-items: center; gap: 11px; margin: 4px 0 14px; }
.step-num {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-dim); color: var(--primary);
  font-weight: 700; font-size: 0.78rem; font-family: var(--mono);
}
.step-title { font-weight: 700; font-size: 0.92rem; letter-spacing: -0.01em; }
.step-line { flex: 1; height: 1px; background: var(--border); }

/* ---------- send workspace ---------- */
.workspace { display: grid; grid-template-columns: minmax(380px, 460px) minmax(0, 1fr); gap: 24px; align-items: start; }
.panel-stack { display: flex; flex-direction: column; min-width: 0; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.25s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---------- forms ---------- */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
label, .label {
  font-size: 0.82rem; font-weight: 600; color: var(--text-main);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
label .opt { font-weight: 400; color: var(--text-faint); }
.hint { color: var(--text-muted); font-size: 0.78rem; line-height: 1.45; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="file"], textarea, select {
  width: 100%; padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.92rem; background: var(--surface-2); color: var(--text-main);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:hover, textarea:hover, select:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--border-strong)); }
input:focus-visible, textarea:focus-visible, select:focus-visible, input:focus, textarea:focus, select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim); background: var(--surface);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.45; }
select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa0a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type="file"] {
  padding: 8px; cursor: pointer; border-style: dashed;
}
input[type="file"]::file-selector-button {
  background: var(--primary-dim); color: var(--primary); border: none; padding: 7px 13px; border-radius: 7px;
  font-weight: 600; cursor: pointer; margin-right: 12px; font-family: inherit;
}
code {
  background: var(--surface-3); font-family: var(--mono); font-size: 0.85em; padding: 1px 6px; border-radius: 5px;
}

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

/* toggle switch */
.switch-group {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 15px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.switch-label { font-size: 0.88rem; font-weight: 600; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.slider { position: absolute; inset: 0; cursor: pointer; background: var(--surface-3); border: 1px solid var(--border-strong); transition: 0.25s var(--ease); border-radius: 24px; }
.slider::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: var(--text-muted); transition: 0.25s var(--ease); border-radius: 50%; }
.switch input:checked + .slider { background: var(--primary-dim); border-color: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); background: var(--primary); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--primary-dim); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 0.88rem; font-weight: 600; line-height: 1;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.12s var(--ease), box-shadow 0.15s var(--ease), color 0.15s var(--ease);
}
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.lg { padding: 14px 22px; font-size: 0.95rem; }
.btn.sm { padding: 7px 12px; font-size: 0.78rem; }

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: 0 6px 18px -6px var(--primary); }
.btn-secondary { background: var(--surface-2); color: var(--text-main); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text-main); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--danger-dim); border-color: var(--danger); }
.btn-icon { padding: 8px; width: 34px; height: 34px; }
.btn-icon.sm { width: 30px; height: 30px; padding: 6px; }

/* ---------- alerts ---------- */
.alert {
  display: flex; gap: 11px; align-items: flex-start; padding: 12px 15px; border-radius: var(--radius-sm);
  font-size: 0.85rem; margin-bottom: 18px; border: 1px solid transparent;
}
.alert .ic { margin-top: 2px; font-size: 1.1rem; }
.alert-warning { background: var(--warning-dim); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.alert-warning strong { color: inherit; }

/* ---------- template editor ---------- */
.drop-zone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 26px; text-align: center; color: var(--text-muted); cursor: pointer;
  transition: 0.2s var(--ease); background: var(--bg-inset);
  display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--primary); background: var(--primary-dim); color: var(--primary); }
.drop-zone .ic { opacity: 0.7; }
.drop-zone strong { display: block; color: var(--text-main); font-size: 0.92rem; }

#html-editor {
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.55; min-height: 240px; height: 300px;
  background: var(--bg-inset); white-space: pre; overflow: auto; margin-bottom: 18px; tab-size: 2;
}

.preview-frame { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; overflow: hidden; display: flex; flex-direction: column; min-height: 360px; }
.preview-bar {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); font-size: 0.74rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.preview-bar .lights { display: flex; gap: 6px; }
.preview-bar .lights i { width: 9px; height: 9px; border-radius: 50%; background: var(--surface-3); display: block; }
.preview-bar .grow { flex: 1; }
iframe.preview { width: 100%; flex: 1; min-height: 320px; border: none; background: #fff; }

/* ---------- progress / results ---------- */
.progress-wrapper { display: none; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.progress-top { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.ring { position: relative; width: 74px; height: 74px; flex-shrink: 0; }
.ring svg { width: 74px; height: 74px; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--surface-3); stroke-width: 7; }
.ring .bar { fill: none; stroke: var(--primary); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 201.06; stroke-dashoffset: 201.06; transition: stroke-dashoffset 0.35s var(--ease); }
.ring .pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 0.85rem; font-weight: 600; }
.progress-info { flex: 1; min-width: 0; }
.progress-title { font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.progress-sub { color: var(--text-muted); font-size: 0.82rem; font-family: var(--mono); margin-top: 2px; }
.progress-chips { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.table-container { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 600; color: var(--text-muted); position: sticky; top: 0; z-index: 2; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td.mono { font-family: var(--mono); color: var(--text-muted); font-size: 0.78rem; }
td.trunc { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- toasts ---------- */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; max-width: calc(100vw - 32px); }
.toast {
  min-width: 270px; max-width: 380px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface);
  box-shadow: var(--shadow-lg); border: 1px solid var(--border-strong); border-left: 3px solid var(--primary);
  display: flex; align-items: flex-start; gap: 12px; transform: translateX(120%); opacity: 0;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}
.toast.show { transform: none; opacity: 1; }
.toast.success { border-left-color: var(--success); }
.toast.success .toast-icon { color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--info); }
.toast.info { border-left-color: var(--info); }
.toast-title { font-weight: 700; font-size: 0.88rem; }
.toast-msg { font-size: 0.82rem; color: var(--text-muted); word-break: break-word; }
.toast-icon { font-size: 1.2rem; margin-top: 1px; }

/* ---------- auth overlay ---------- */
#auth-overlay {
  position: fixed; inset: 0; z-index: 1000; padding: 20px; transition: opacity 0.3s var(--ease);
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 0%, color-mix(in srgb, var(--primary) 12%, transparent), transparent),
    radial-gradient(700px 420px at 100% 100%, color-mix(in srgb, var(--info) 8%, transparent), transparent),
    var(--bg);
}
.auth-card {
  background: var(--surface); padding: 38px 36px; border-radius: 18px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 390px; border: 1px solid var(--border); text-align: center;
}
.auth-card .brand-mark { width: 54px; height: 54px; border-radius: 15px; margin: 0 auto 16px; font-size: 1.6rem; }
.auth-card h2 { margin-bottom: 4px; font-weight: 800; font-size: 1.4rem; letter-spacing: -0.025em; }
.auth-card p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 24px; }
.auth-card .form-group { text-align: left; }
.auth-card .error-text { color: var(--danger); font-size: 0.82rem; margin-top: 10px; min-height: 18px; }

/* ---------- admin ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-grid.two { grid-template-columns: repeat(2, 1fr); }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stat-card .stat-label { font-size: 0.74rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card .stat-ic { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.stat-card .stat-ic.sent { background: var(--info-dim); color: var(--info); }
.stat-card .stat-ic.failed { background: var(--danger-dim); color: var(--danger); }
.stat-card .value { font-size: 2rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.stat-card svg.spark { display: block; width: 100%; height: 30px; margin-top: 10px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > .card { margin-bottom: 20px; }

.status-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 0.9rem; font-weight: 500; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.dot.connected { background: var(--success); box-shadow: 0 0 0 3px var(--success-dim); }
.dot.pending { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-dim); }
.dot.error { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-dim); }

.code-box { background: var(--primary-dim); border: 1px dashed color-mix(in srgb, var(--primary) 45%, transparent); border-radius: var(--radius-sm); padding: 20px; text-align: center; margin-bottom: 14px; display: none; }
.code-box .code { font-family: var(--mono); font-size: 1.7rem; font-weight: 700; letter-spacing: 0.12em; margin-bottom: 8px; color: var(--primary); }
.code-box a { color: var(--primary); font-weight: 600; }
.code-box .hint { margin-top: 6px; }

.account-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.account-row:last-child { border-bottom: none; padding-bottom: 0; }
.account-row:first-child { padding-top: 0; }
.avatar { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--text-muted); font-weight: 700; font-size: 0.85rem; }
.avatar.graph { background: var(--info-dim); color: var(--info); }
.avatar.gmail { background: var(--danger-dim); color: var(--danger); }
.avatar.smtp { background: var(--warning-dim); color: var(--warning); }
.account-info { flex: 1; min-width: 0; }
.account-info .name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; }
.account-info .meta { color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }
.account-actions { display: flex; gap: 6px; flex-shrink: 0; }

.gauge-wrap { width: 200px; flex-shrink: 0; }
.gauge-track { background: var(--surface-3); border-radius: 6px; height: 8px; overflow: hidden; }
.gauge-fill { height: 100%; background: var(--success); transition: width 0.4s var(--ease); border-radius: 6px; }
.gauge-fill.warn { background: var(--warning); }
.gauge-fill.crit { background: var(--danger); }
.gauge-label { font-size: 0.74rem; color: var(--text-muted); margin-top: 5px; text-align: right; font-weight: 600; font-family: var(--mono); }
.cap-edit { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.cap-edit input { width: 96px; padding: 6px 9px; font-size: 0.78rem; }

.subject-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipient-cell { color: var(--text-muted); }
.time-cell { color: var(--text-faint); font-size: 0.76rem; white-space: nowrap; }

.chart-wrap { height: 150px; }
.chart-caption { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--text-faint); margin-top: 6px; }

.empty { color: var(--text-faint); font-size: 0.85rem; text-align: center; padding: 28px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty .ic { font-size: 1.8rem; opacity: 0.55; }

.sig-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sig-preview {
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-inset); padding: 16px;
  font-size: 0.85rem; min-height: 120px; white-space: normal; overflow-wrap: anywhere;
}
.sig-preview .mail-body { color: var(--text-muted); margin-bottom: 12px; }
.sig-preview .sig { color: var(--text-main); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidenav {
    position: fixed; z-index: 60; inset: 0 auto 0 0; width: min(280px, 84vw); height: 100vh;
    transform: translateX(-102%); transition: transform 0.25s var(--ease); box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidenav { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgb(0 0 0 / 0.5); z-index: 50; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .page { padding: 18px 16px 70px; }
  .grid-2, .sig-layout { grid-template-columns: 1fr; }
  .gauge-wrap { width: 120px; }
  .account-row { flex-wrap: wrap; }
  #toast-container { left: 16px; right: 16px; bottom: 16px; }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .row { flex-direction: column; }
  .stat-card .value { font-size: 1.6rem; }
}

/* ---------- notification center ---------- */
.notif-btn { position: relative; }
.notif-badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--primary); color: var(--on-primary); font-size: 0.66rem; font-weight: 700; font-family: var(--mono);
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--bg); line-height: 1;
}
.notif-badge.sev-error { background: var(--danger); color: #fff; }
.notif-badge.sev-warning { background: var(--warning); color: #1a1200; }
.notif-btn.ring .ic { animation: bell 0.7s var(--ease) 1; transform-origin: 50% 0; }
@keyframes bell { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(14deg); } 40% { transform: rotate(-12deg); } 60% { transform: rotate(8deg); } 80% { transform: rotate(-5deg); } }

#notif-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); z-index: 90; opacity: 0; pointer-events: none; transition: opacity 0.2s var(--ease); }
#notif-backdrop.open { opacity: 1; pointer-events: auto; }
#notif-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 91;
  background: var(--surface); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; transform: translateX(104%); transition: transform 0.25s var(--ease);
}
#notif-panel.open { transform: none; }
.notif-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 12px; }
.notif-head h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; flex: 1; display: flex; align-items: center; gap: 9px; }
.notif-head h2 .ic { color: var(--primary); }
.notif-filters { display: flex; gap: 6px; padding: 0 20px 12px; flex-wrap: wrap; }
.notif-filter {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-muted); font: inherit; font-size: 0.78rem; font-weight: 600; cursor: pointer;
  display: inline-flex; gap: 6px; align-items: center;
}
.notif-filter:hover { color: var(--text-main); }
.notif-filter.active { background: var(--primary-dim); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 35%, transparent); }
.notif-filter .n { font-family: var(--mono); opacity: 0.8; }
.notif-actions { display: flex; gap: 8px; padding: 0 20px 12px; border-bottom: 1px solid var(--border); }
.notif-list { flex: 1; overflow-y: auto; padding: 8px 12px 24px; }
.notif-item {
  display: flex; gap: 12px; padding: 14px 10px; border-radius: var(--radius-sm); border: 1px solid transparent;
  margin-bottom: 4px; cursor: default; position: relative; transition: background 0.15s var(--ease);
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: color-mix(in srgb, var(--primary-dim) 55%, transparent); }
.notif-item.unread::before { content: ""; position: absolute; left: 2px; top: 22px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.notif-ic { width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sev-error .notif-ic { background: var(--danger-dim); color: var(--danger); }
.sev-warning .notif-ic { background: var(--warning-dim); color: var(--warning); }
.sev-info .notif-ic { background: var(--info-dim); color: var(--info); }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-weight: 700; font-size: 0.88rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notif-count { font-family: var(--mono); font-size: 0.68rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-muted); }
.notif-msg { font-size: 0.83rem; color: var(--text-main); margin-top: 3px; overflow-wrap: anywhere; }
.notif-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--border-strong); overflow-wrap: anywhere; }
.notif-body details { margin-top: 8px; }
.notif-body summary { font-size: 0.74rem; font-weight: 600; color: var(--text-muted); cursor: pointer; user-select: none; }
.notif-body summary:hover { color: var(--text-main); }
.notif-body pre {
  margin-top: 6px; padding: 10px 12px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--mono); font-size: 0.72rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto;
}
.notif-meta { font-size: 0.72rem; color: var(--text-faint); margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.notif-x { align-self: flex-start; }
.notif-empty { padding: 56px 20px; text-align: center; color: var(--text-faint); display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 0.88rem; }
.notif-empty .ic { font-size: 2rem; opacity: 0.55; }

.stat-sub { display: flex; gap: 18px; margin-top: 6px; font-size: 0.78rem; color: var(--text-muted); }
.stat-sub b { color: var(--text-main); font-family: var(--mono); font-weight: 600; margin-left: 4px; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 0.74rem; color: var(--text-muted); }
.legend .lg { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-left: 8px; }
.legend .lg.sent { background: #2dd4bf; }
.legend .lg.failed { background: var(--danger); }
.fail-reason { margin-top: 4px; font-size: 0.72rem; color: var(--danger); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
