:root {
  --brand: #0f6cbd;
  --brand-hover: #115ea3;
  --brand-dark: #0b3a64;
  --brand-soft: #eff6fc;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --sidebar: #fafafa;
  --ink: #242424;
  --muted: #616161;
  --subtle: #8a8886;
  --line: #e1dfdd;
  --line-strong: #c8c6c4;
  --green: #107c10;
  --green-soft: #dff6dd;
  --violet: #5c2d91;
  --violet-soft: #f3f0f8;
  --red: #a4262c;
  --red-soft: #fde7e9;
  --amber: #8a5700;
  --amber-soft: #fff4ce;
  --hover: #f8f8f8;
  --table-head: #fafafa;
  --input-bg: #ffffff;
  --topbar: #0f6cbd;
  --topbar-height: 48px;
  --sidebar-width: 236px;
  --content-max-width: 1440px;
  font-family: "Segoe UI", "Segoe UI Web", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 28px; font-weight: 600; line-height: 1.25; letter-spacing: -.02em; }
h2 { margin-bottom: 3px; font-size: 17px; font-weight: 600; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  height: var(--topbar-height);
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(280px, 620px) minmax(280px, 1fr);
  align-items: center;
  background: var(--topbar);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.topbar-left, .topbar-actions { min-width: 0; display: flex; align-items: center; height: 100%; }
.topbar-left { gap: 4px; }
.topbar-actions { justify-content: flex-end; padding-right: 12px; gap: 4px; }
.app-launcher {
  width: 48px; height: 48px; display: grid; grid-template-columns: repeat(3, 3px);
  grid-auto-rows: 3px; gap: 3px; place-content: center;
}
.app-launcher i { width: 3px; height: 3px; background: #fff; border-radius: 50%; }
.brand { display: flex; align-items: center; gap: 9px; height: 100%; padding: 0 12px 0 4px; color: #fff; font-size: 15px; font-weight: 600; white-space: nowrap; }
.brand:hover, .topbar-link:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; display: inline-grid; place-items: center;
  background: #fff; color: var(--brand); border-radius: 2px; font-size: 15px; font-weight: 700;
}
.brand-mark.has-image { background: transparent; border-radius: 0; }
.brand-mark.large { width: 40px; height: 40px; font-size: 20px; }
.brand-mark img, .brand-preview img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.global-search {
  position: relative; width: 100%; height: 32px; display: flex; align-items: center;
  background: #fff; border-radius: 2px; color: #424242;
}
.global-search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: #605e5c; }
.global-search input {
  width: 100%; height: 100%; padding: 0 12px 0 34px; border: 0; outline: 0;
  background: transparent; color: var(--ink); font: inherit;
}
.global-search input::placeholder { color: #6b6b6b; }
.topbar-link { display: flex; align-items: center; gap: 6px; height: 100%; padding: 0 10px; color: #fff; font-size: 13px; }
.topbar-link svg, .icon-button svg { width: 17px; height: 17px; }
.admin-name { margin-left: 8px; font-size: 12px; opacity: .95; }
.avatar {
  width: 28px; height: 28px; display: grid; place-items: center; margin: 0 5px;
  border: 1px solid rgba(255,255,255,.75); border-radius: 50%; font-size: 12px; font-weight: 600;
}
.topbar-actions form { height: 100%; }
.icon-button {
  width: 40px; height: 100%; display: grid; place-items: center; padding: 0;
  border: 0; background: transparent; color: inherit; cursor: pointer;
}
.icon-button:hover { background: rgba(255,255,255,.12); }

.app-shell { min-height: 100vh; padding-top: var(--topbar-height); }
.sidebar {
  position: fixed; inset: var(--topbar-height) auto 0 0; z-index: 50;
  width: var(--sidebar-width); display: flex; flex-direction: column;
  background: var(--sidebar); border-right: 1px solid var(--line); overflow-y: auto;
}
.sidebar nav { flex: 1; padding: 12px 8px; }
.nav-section {
  margin: 16px 12px 5px; color: var(--muted); font-size: 11px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.sidebar nav > a {
  min-height: 40px; display: flex; align-items: center; gap: 12px;
  padding: 8px 11px; border-left: 3px solid transparent; color: var(--ink);
  font-size: 14px;
}
.sidebar nav > a:hover { background: var(--hover); text-decoration: none; }
.sidebar nav > a.active { border-left-color: var(--brand); background: #e8f1f8; color: #0b5a9d; font-weight: 600; }
.sidebar nav > a svg { width: 18px; height: 18px; flex: 0 0 auto; }
.sidebar nav > a .external { width: 13px; height: 13px; margin-left: auto; color: var(--muted); }
.sidebar-foot {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-top: 1px solid var(--line); background: var(--surface);
  color: var(--ink);
}
.sidebar-foot:hover { background: var(--hover); text-decoration: none; }
.sidebar-foot strong, .sidebar-foot small { display: block; font-size: 12px; }
.sidebar-foot small { color: var(--muted); margin-top: 1px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.warning { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }

.workspace { min-height: calc(100vh - var(--topbar-height)); margin-left: var(--sidebar-width); }
main { width: 100%; max-width: var(--content-max-width); margin-inline: auto; padding: 28px 32px 60px; }
main.centered { max-width: none; min-height: 100vh; display: grid; place-items: center; padding: 28px; background: #f3f6fb; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.breadcrumb { margin-bottom: 9px; color: var(--brand); font-size: 12px; }
.muted, small { color: var(--muted); }
.overline { margin-bottom: 10px; color: rgba(255,255,255,.8); font-size: 11px; font-weight: 700; letter-spacing: .13em; }
.overline.blue { color: var(--brand); }

.panel {
  overflow: hidden; background: var(--surface); border: 1px solid var(--line);
  border-radius: 2px; box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.panel-head {
  min-height: 64px; display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 15px 20px; border-bottom: 1px solid var(--line);
}
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats article {
  min-height: 132px; display: flex; align-items: flex-start; gap: 16px; padding: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.stat-icon {
  width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 2px;
}
.stat-icon svg { width: 23px; height: 23px; }
.stat-icon.blue { color: var(--brand); background: var(--brand-soft); }
.stat-icon.violet { color: var(--violet); background: var(--violet-soft); }
.stat-icon.green { color: var(--green); background: var(--green-soft); }
.stat-icon.amber { color: var(--amber); background: var(--amber-soft); }
.stats article > div:last-child { min-width: 0; display: grid; }
.stats span { color: var(--muted); }
.stats strong { margin: 2px 0; font-size: 30px; font-weight: 600; line-height: 1.2; }
.stats a, .stats small { font-size: 12px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(320px, .7fr) minmax(460px, 1.3fr); gap: 20px; align-items: start; }
.quick-actions { padding: 8px 0; }
.quick-actions > a {
  display: flex; align-items: center; gap: 13px; min-height: 64px; padding: 10px 20px;
  color: var(--ink); border-bottom: 1px solid #f0f0f0;
}
.quick-actions > a:last-child { border-bottom: 0; }
.quick-actions > a:hover { background: var(--hover); text-decoration: none; }
.quick-actions strong, .quick-actions small { display: block; }
.quick-actions small { margin-top: 2px; }
.quick-icon {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); border-radius: 2px; font-size: 20px;
}
.quick-icon.alias { background: var(--violet-soft); color: var(--violet); }
.quick-icon.mail { background: var(--green-soft); color: var(--green); font-size: 16px; }
.quick-icon.domain { background: var(--green-soft); color: var(--green); }
.quick-icon.flow { background: var(--amber-soft); color: var(--amber); }
.activity-list article { min-height: 58px; display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid #f0f0f0; }
.activity-list article:last-child { border-bottom: 0; }
.activity-list p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.activity-list time { color: var(--subtle); font-size: 11px; }
.activity-icon { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

.command-bar {
  min-height: 52px; display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.command-count { margin-left: auto; padding-right: 8px; color: var(--muted); font-size: 12px; }
.button, button {
  min-height: 32px; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 5px 13px; border: 1px solid transparent; border-radius: 2px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.button.primary, button.primary { background: var(--brand); color: #fff; }
.button.primary:hover, button.primary:hover { background: var(--brand-hover); text-decoration: none; }
.button.secondary { border-color: var(--line-strong); background: var(--input-bg); color: var(--ink); }
.button.quiet { background: transparent; color: var(--ink); }
.button.quiet:hover { background: #f3f2f1; text-decoration: none; }
.button.full { width: 100%; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { min-height: 44px; padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--table-head); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--hover); }
.identity-cell { min-width: 0; display: flex; align-items: center; gap: 11px; }
.identity-cell strong, .identity-cell small { display: block; overflow-wrap: anywhere; }
.identity-cell p { margin: 2px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.resource-avatar {
  width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); border-radius: 50%; font-size: 12px; font-weight: 700;
}
.resource-avatar.violet { background: var(--violet-soft); color: var(--violet); }
.resource-avatar.shared { border-radius: 3px; background: var(--violet-soft); color: var(--violet); }
.row-action { white-space: nowrap; font-size: 12px; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; min-width: 220px; }
.row-actions .row-action + .row-action { padding-left: 12px; border-left: 1px solid var(--line); }
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge.ok { color: #0b6a0b; background: var(--green-soft); }
.badge.danger { color: var(--red); background: var(--red-soft); }
.badge.off { color: #605e5c; background: #edebe9; }
.badge.shared-badge { color: var(--violet); background: var(--violet-soft); }
.badge.personal-badge { color: var(--brand); background: var(--brand-soft); }
.meter { width: 120px; height: 4px; overflow: hidden; margin: 6px 0 2px; background: #edebe9; border-radius: 2px; }
.meter span { display: block; height: 100%; background: var(--brand); }

.stack { display: grid; gap: 19px; }
label { display: grid; gap: 6px; color: var(--ink); font-size: 13px; font-weight: 600; }
input, textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 2px;
  background: var(--input-bg); color: var(--ink); font: inherit; outline: none;
}
input { min-height: 36px; }
select { min-height: 36px; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.form-panel { max-width: 760px; padding: 0 24px 24px; }
.form-section-title { margin: 0 -24px 24px; padding: 17px 24px; border-bottom: 1px solid var(--line); }
.form-section-title p { margin: 3px 0 0; color: var(--muted); }
.form-panel .panel-head { margin: 0 -28px 24px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 5px; }
.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-radius: 2px 0 0 2px; }
.input-suffix span {
  display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-strong);
  border-left: 0; border-radius: 0 2px 2px 0; background: #f3f2f1; color: var(--muted); font-weight: 400;
}
.address-builder { display: grid; grid-template-columns: 1fr minmax(190px, auto); }
.address-builder input { border-radius: 2px 0 0 2px; }
.address-builder select { padding: 0 30px 0 10px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 2px 2px 0; }
.resource-avatar.domain { background: var(--green-soft); color: var(--green); }
.button.compact { min-height: 28px; padding: 3px 8px; font-size: 12px; }
.two-column { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(440px, 1.2fr); gap: 20px; align-items: start; }
.two-column .form-panel { padding: 0 20px 20px; }
.two-column .form-panel .panel-head { margin: 0 -20px 20px; }
.alias-list article { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.alias-list article:last-child { border-bottom: 0; }
.danger-link { min-height: 28px; padding: 3px 7px; border: 0; background: transparent; color: var(--red); font-size: 12px; }
.danger-link:hover { background: var(--red-soft); }

.mailbox-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.mailbox-summary article { min-height: 88px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); }
.mailbox-summary strong, .mailbox-summary small { display: block; }
.mailbox-summary strong { margin: 3px 0; font-size: 19px; overflow-wrap: anywhere; }
.mailbox-summary small { font-size: 12px; }
.mailbox-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.vacation-note { padding: 12px 14px; color: var(--muted); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 28%, transparent); font-size: 12px; }
.single-toggle { grid-template-columns: 18px 1fr; align-items: start; gap: 11px; padding: 13px 14px; border: 1px solid var(--line); cursor: pointer; }
.single-toggle input { width: 16px; min-height: 16px; margin: 2px 0 0; accent-color: var(--brand); }
.single-toggle strong, .single-toggle small { display: block; }
.single-toggle small { margin-top: 2px; font-weight: 400; }
.delegation-grid { display: grid; grid-template-columns: minmax(320px, .72fr) minmax(480px, 1.28fr); gap: 20px; align-items: start; }
.delegation-list article { min-height: 72px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.delegation-list article:last-child { border-bottom: 0; }
.delegation-rights { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.shared-explainer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.shared-explainer article { padding: 15px 17px; background: var(--surface); border: 1px solid var(--line); }
.shared-explainer strong, .shared-explainer small { display: block; }
.shared-explainer small { margin-top: 3px; }

.result-list > a {
  min-height: 58px; display: grid; grid-template-columns: 34px 1fr auto; align-items: center;
  gap: 12px; padding: 10px 18px; color: var(--ink); border-bottom: 1px solid var(--line);
}
.result-list > a:last-child { border-bottom: 0; }
.result-list > a:hover { background: #fafcff; text-decoration: none; }
.result-list strong, .result-list small { display: block; }
.search-results { margin-bottom: 18px; }
.search-empty { max-width: 480px; margin: 80px auto; text-align: center; color: var(--muted); }
.search-empty svg { width: 52px; height: 52px; margin-bottom: 15px; color: var(--brand); }
.search-empty h2 { color: var(--ink); font-size: 20px; }
.empty { padding: 32px 20px; color: var(--muted); text-align: center; }
.flash { padding: 11px 14px; margin-bottom: 16px; border: 1px solid; border-radius: 2px; font-weight: 600; }
.flash.success { color: #0b5d1e; background: #f1faf2; border-color: #9fd89f; }
.flash.error { color: #8f1d23; background: #fff4f4; border-color: #f1aeb5; }

.theme-toggle .theme-icon-light,
.theme-toggle .theme-icon-dark { display: none; }
[data-theme-mode="light"] .theme-toggle .theme-icon-auto,
[data-theme-mode="dark"] .theme-toggle .theme-icon-auto { display: none; }
[data-theme-mode="light"] .theme-toggle .theme-icon-light,
[data-theme-mode="dark"] .theme-toggle .theme-icon-dark { display: block; }

.period-switch { display: inline-flex; padding: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; }
.period-switch a { padding: 6px 12px; color: var(--muted); font-size: 12px; font-weight: 600; }
.period-switch a:hover { background: var(--hover); text-decoration: none; }
.period-switch a.active { background: var(--brand); color: #fff; }
.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric-grid article { min-height: 112px; display: grid; align-content: start; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.metric-grid article.metric-warning { border-top-color: #f5a623; }
.metric-grid article.metric-danger { border-top-color: var(--red); }
.metric-grid span, .metric-grid small { color: var(--muted); }
.metric-grid strong { margin: 3px 0; font-size: 27px; font-weight: 600; }
.metric-grid small { font-size: 11px; }
.flow-chart-panel, .mail-queue { margin-bottom: 20px; }
.chart-legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.chart-legend i { width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; }
.chart-legend .received, .chart-bars .received { background: var(--brand); }
.chart-legend .sent, .chart-bars .sent { background: var(--green); }
.chart-legend .failed, .chart-bars .failed { background: var(--red); }
.flow-chart { height: 210px; display: flex; align-items: stretch; gap: 8px; padding: 22px 24px 14px; overflow-x: auto; }
.chart-day { min-width: 38px; flex: 1; display: grid; grid-template-rows: 1fr auto; gap: 7px; text-align: center; }
.chart-bars { min-height: 150px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; border-bottom: 1px solid var(--line); }
.chart-bars i { width: min(9px, 25%); min-height: 2px; border-radius: 2px 2px 0 0; }
.chart-day small { font-size: 10px; white-space: nowrap; }
.queue-reason, .event-summary { max-width: 540px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.event-date { white-space: nowrap; color: var(--muted); font-size: 12px; }
code { color: var(--ink); font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; }
.badge.event-accepted { color: var(--brand); background: var(--brand-soft); }
.badge.event-received, .badge.event-sent { color: var(--green); background: var(--green-soft); }
.badge.event-deferred { color: var(--amber); background: var(--amber-soft); }
.badge.event-bounced, .badge.event-rejected { color: var(--red); background: var(--red-soft); }
.healthy-empty { color: var(--green); font-weight: 600; }

.settings-shell { display: grid; grid-template-columns: 230px minmax(0, 820px); gap: 20px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-height) + 20px); display: grid; padding: 8px; background: var(--surface); border: 1px solid var(--line); }
.settings-nav a { display: grid; gap: 2px; padding: 11px 12px; border-left: 3px solid transparent; color: var(--ink); }
.settings-nav a:hover { background: var(--hover); text-decoration: none; }
.settings-nav a.active { border-left-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.settings-nav small { font-size: 11px; font-weight: 400; }
.settings-content { display: grid; gap: 20px; }
.settings-section { scroll-margin-top: calc(var(--topbar-height) + 20px); }
.settings-content { display: grid; gap: 20px; }
.health-summary, .dns-results { padding: 0 20px 20px; border-top: 1px solid var(--line); }
.health-summary > strong { display: block; padding: 16px 0 8px; }
.health-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.health-row span:first-child, .dns-result-head div { display: grid; }
.dns-results { display: grid; gap: 12px; padding-top: 16px; }
.dns-results article { padding: 14px; border: 1px solid var(--line); background: var(--hover); }
.dns-result-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dns-results dl { display: grid; grid-template-columns: 80px 1fr; gap: 6px 12px; margin: 12px 0 0; }
.dns-results dt { color: var(--muted); font-size: 12px; }
.dns-results dd { display: flex; flex-wrap: wrap; gap: 5px; margin: 0; min-width: 0; }
.dns-results code { padding: 2px 5px; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--line); border-radius: 2px; }
.dns-help { margin: 10px 0 0; color: var(--amber); font-size: 12px; }
.settings-form { padding: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
input[type="color"] { width: 100%; min-height: 40px; padding: 4px; }
.brand-preview { width: 38px; height: 38px; display: grid; place-items: center; color: #fff; border-radius: 3px; font-weight: 700; }
.remove-icon { grid-template-columns: 18px 1fr; align-items: center; gap: 10px; padding: 10px 12px; background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); color: var(--red); }
.remove-icon input { width: 16px; min-height: 16px; accent-color: var(--red); }
.toggle-list { display: grid; border: 1px solid var(--line); }
.toggle-list label { grid-template-columns: 18px 1fr; align-items: start; gap: 11px; padding: 13px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle-list label:last-child { border-bottom: 0; }
.toggle-list input { width: 16px; min-height: 16px; margin: 2px 0 0; accent-color: var(--brand); }
.toggle-list strong, .toggle-list small { display: block; }
.toggle-list small { margin-top: 2px; font-weight: 400; }

.service-overview { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.service-overview article { min-height: 84px; display: flex; align-items: center; gap: 13px; padding: 17px 20px; background: var(--surface); border: 1px solid var(--line); }
.service-overview article:not(:first-child) { display: grid; align-content: center; gap: 2px; }
.service-overview strong { font-size: 18px; }
.service-overview small { display: block; }
.health-ring { width: 48px; height: 48px; display: grid; place-items: center; border: 4px solid var(--green); border-radius: 50%; color: var(--green); font-weight: 700; }
.service-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.service-card { position: relative; padding: 20px; background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--brand-soft) 16%, var(--surface))); transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.service-card:hover { transform: translateY(-1px); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); box-shadow: 0 7px 22px rgba(0,0,0,.08); }
.service-card-head { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 14px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.service-card-head h2 { margin: 0; }
.service-card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.service-logo-frame { position: relative; width: 52px; height: 52px; display: grid; place-items: center; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 3px 10px rgba(0,0,0,.08); }
.service-logo-frame.custom-brand { padding: 0; background: transparent; border-color: transparent; box-shadow: none; }
.service-logo-frame img { width: 100%; height: 100%; object-fit: contain; }
.service-logo-frame i { position: absolute; right: -3px; bottom: -3px; width: 13px; height: 13px; border: 3px solid var(--surface); border-radius: 50%; }
.service-logo-frame.up i { background: var(--green); }
.service-logo-frame.down i { background: var(--red); }
.error-badge { color: var(--red); background: var(--red-soft); }
.service-card dl { margin: 0; }
.service-card dl > div { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.service-card dt { color: var(--muted); font-size: 12px; }
.service-card dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.service-ports { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 14px; }
.port-chip { padding: 4px 8px; border-radius: 12px; font-size: 11px; }
.port-chip.listening { color: var(--green); background: var(--green-soft); }
.port-chip.closed { color: var(--red); background: var(--red-soft); }
.external-check { margin-bottom: 20px; }
.privacy-note { padding: 11px 20px; color: var(--muted); background: var(--brand-soft); border-bottom: 1px solid var(--line); font-size: 12px; }
.badge.port-open { color: var(--green); background: var(--green-soft); }
.badge.port-closed { color: var(--red); background: var(--red-soft); }
.badge.port-unknown { color: var(--amber); background: var(--amber-soft); }
.external-check td small { display: block; margin-top: 2px; }
.check-meta { padding: 10px 16px; color: var(--muted); border-top: 1px solid var(--line); font-size: 11px; }

[data-density="compact"] main { padding-top: 20px; }
[data-density="compact"] th,
[data-density="compact"] td { padding-top: 7px; padding-bottom: 7px; }
[data-density="compact"] .service-card { padding: 14px; }
[data-density="compact"] .service-card dl > div { padding: 5px 0; }

[data-theme="dark"] {
  color-scheme: dark;
  --brand: #479ef5;
  --brand-hover: #62abf5;
  --brand-dark: #0f548c;
  --brand-soft: #092c47;
  --bg: #1b1a19;
  --surface: #252423;
  --sidebar: #201f1e;
  --ink: #f3f2f1;
  --muted: #c8c6c4;
  --subtle: #a19f9d;
  --line: #3b3a39;
  --line-strong: #605e5c;
  --green: #54b054;
  --green-soft: #123b18;
  --violet: #c8a7ea;
  --violet-soft: #352545;
  --red: #f1707b;
  --red-soft: #4a1d21;
  --amber: #f2c661;
  --amber-soft: #44330c;
  --hover: #323130;
  --table-head: #2d2c2b;
  --input-bg: #292827;
  --topbar: #0b3a64;
}
[data-theme="dark"] .sidebar nav > a.active { background: #12344f; color: #75baff; }
[data-theme="dark"] .input-suffix span { background: #323130; }
[data-theme="dark"] .quick-actions > a,
[data-theme="dark"] .activity-list article { border-bottom-color: var(--line); }
[data-theme="dark"] .flash.success { color: #9de49d; background: #142d18; border-color: #347c34; }
[data-theme="dark"] .flash.error { color: #ffb3ba; background: #3b171a; border-color: #8f3940; }
[data-theme="dark"] main.centered { background: #15191f; }
[data-theme="dark"] .login-layout { background: var(--surface); border-color: var(--line); box-shadow: 0 18px 55px rgba(0,0,0,.45); }
[data-theme="dark"] .service-logo-frame { background: #f7f7f7; border-color: #4b4a49; }
[data-theme="dark"] .service-logo-frame.custom-brand { background: transparent; border-color: transparent; }
[data-theme="dark"] .service-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* Pantallas ultrapanorámicas (21:9): más aire sin estirar el contenido. */
@media (min-width: 1700px) and (min-aspect-ratio: 2 / 1) {
  :root { --content-max-width: 1680px; }
  main { padding-inline: 44px; }
  .topbar { grid-template-columns: minmax(340px, 1fr) minmax(520px, 760px) minmax(340px, 1fr); }
  .stats { gap: 20px; }
  .dashboard-grid { grid-template-columns: minmax(460px, .8fr) minmax(680px, 1.2fr); gap: 24px; }
  .service-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
  .settings-shell { grid-template-columns: 240px minmax(0, 900px); max-width: 1180px; }
  .flow-chart { gap: 12px; }
}

.login-layout {
  width: min(980px, 100%); min-height: 580px; display: grid; grid-template-columns: 1.08fr .92fr;
  overflow: hidden; background: #fff; border: 1px solid #d6dbe5; border-radius: 4px;
  box-shadow: 0 18px 55px rgba(16, 47, 91, .16);
}
.login-brand-panel {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  padding: 46px; color: #fff; background: linear-gradient(145deg, #0f6cbd 0%, #164a7a 58%, #092d4e 100%);
}
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 18px; font-weight: 600; }
.login-copy { position: relative; z-index: 2; max-width: 420px; margin-bottom: 60px; }
.login-copy h1 { max-width: 390px; margin-bottom: 18px; font-size: 38px; font-weight: 500; line-height: 1.12; }
.login-copy > p:last-child { max-width: 390px; color: rgba(255,255,255,.78); font-size: 16px; }
.login-pattern i { position: absolute; border: 1px solid rgba(255,255,255,.12); border-radius: 50%; }
.login-pattern i:nth-child(1) { width: 320px; height: 320px; right: -150px; bottom: -90px; }
.login-pattern i:nth-child(2) { width: 220px; height: 220px; right: -100px; bottom: -40px; }
.login-pattern i:nth-child(3) { width: 460px; height: 460px; right: -220px; bottom: -150px; }
.login-card { align-self: center; padding: 56px 50px; }
.login-card h2 { margin-bottom: 7px; font-size: 28px; font-weight: 600; }
.login-card > .muted { margin-bottom: 30px; }
.webmail-login-link { display: inline-block; margin-top: 24px; font-size: 13px; }

@media (max-width: 1000px) {
  .topbar { grid-template-columns: 240px minmax(260px, 1fr) auto; }
  .topbar-link span, .admin-name { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats article:last-child { grid-column: auto; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .two-column { grid-template-columns: 1fr; }
  .delegation-grid { grid-template-columns: 1fr; }
  .settings-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .service-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --sidebar-width: 58px; }
  .topbar { grid-template-columns: auto 1fr auto; }
  .brand span:last-child { display: none; }
  .app-launcher { width: 42px; }
  .topbar-actions { padding-right: 4px; }
  .avatar { display: none; }
  .sidebar nav { padding: 8px 4px; }
  .nav-section, .sidebar nav > a span, .sidebar nav > a .external, .sidebar-foot div { display: none; }
  .sidebar nav > a { justify-content: center; min-height: 46px; padding: 8px; border-left-width: 2px; }
  .sidebar-foot { justify-content: center; padding: 16px 0; }
  main { padding: 22px 18px 50px; }
  .stats { grid-template-columns: 1fr; }
  .stats article:last-child { grid-column: auto; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .login-layout { min-height: 0; grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 220px; padding: 30px; }
  .login-copy { margin: 35px 0 0; }
  .login-copy h1 { max-width: 500px; font-size: 28px; }
  .login-copy > p:last-child { display: none; }
  .login-card { padding: 38px 30px; }
  .activity-list time { display: none; }
  .activity-list article { grid-template-columns: 12px 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .chart-legend { display: none; }
  .settings-shell { grid-template-columns: 1fr; }
  .settings-nav { position: static; grid-template-columns: repeat(2, 1fr); }
  .service-overview { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .global-search { margin-right: 4px; }
  .global-search input::placeholder { color: transparent; }
  .topbar-link { display: none; }
  th, td { padding: 10px 12px; }
  .command-count { display: none; }
  .login-brand-panel { display: none; }
  .login-layout { display: block; }
  .metric-grid { grid-template-columns: 1fr; }
  .address-builder { grid-template-columns: 1fr; }
  .address-builder input, .address-builder select { border: 1px solid var(--line-strong); border-radius: 2px; }
  .domains-layout thead { display: none; }
  .domains-layout table,
  .domains-layout tbody,
  .domains-layout tr,
  .domains-layout td { display: block; width: 100%; }
  .domains-layout tbody tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .domains-layout tbody tr:last-child { border-bottom: 0; }
  .domains-layout td { padding: 6px 0; border: 0; }
  .domains-layout td form { display: inline-block; }
  .settings-nav { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .mailbox-summary { grid-template-columns: 1fr; }
  .shared-explainer { grid-template-columns: 1fr; }
  .row-actions { min-width: 190px; }
  .service-card-head { grid-template-columns: 52px 1fr; }
  .service-card-head .badge { grid-column: 2; justify-self: start; }
  .service-card dl > div { grid-template-columns: 1fr; gap: 2px; }
  .service-card dd { text-align: left; }
}
