:root {
  --bg: #0b0c0f;
  --bg2: #111318;
  --bg3: #181b22;
  --border: #1e2330;
  --border2: #2a3040;
  --text: #d4dae8;
  --text2: #8892a4;
  --text3: #5a6478;
  --accent: #4ade80;
  --accent2: #22c55e;
  --red: #f87171;
  --yellow: #fbbf24;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --font: "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", monospace;
  --radius: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* Subtle grid background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.3;
  pointer-events: none;
  z-index: 0;
}

/* Desktop full-width settings */
.layout {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  background: var(--bg2);
}

.sidebar {
  width: 220px;
  height: 100vh;
  background: #171821;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 200;
  overflow-y: auto;
}

.main {
  margin-left: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-width: 0;
  overflow-y: auto;
  background: var(--bg2);
}

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.2);
}

.logo-text {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
}
.logo-sub {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--mono);
}

.nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  padding: 10px 18px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--text3);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  color: var(--text2);
  cursor: pointer;
  border-left: 2px solid transparent;
  font-size: 13.5px;
  transition: all 0.15s;
}

.nav-item:hover {
  color: var(--text);
  background: var(--bg3);
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(74, 222, 128, 0.05);
  font-weight: 500;
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.smtp-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s infinite;
}

.status-dot.off {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ── Topbar ── */
.topbar {
  height: 56px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 15px;
  font-weight: 500;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--text);
  font: 13px var(--font);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--border2);
  background: #1e2330;
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0c0f;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent2);
  border-color: var(--accent2);
  color: #0b0c0f;
}

.btn-danger {
  border-color: rgba(248, 113, 113, 0.3);
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(248, 113, 113, 0.1);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
.btn svg {
  width: 14px;
  height: 14px;
}

/* ── Content ── */
.content {
  padding: 28px;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.card-body {
  padding: 20px;
}

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.stat-card.green::after {
  background: var(--accent);
}
.stat-card.blue::after {
  background: var(--blue);
}
.stat-card.yellow::after {
  background: var(--yellow);
}
.stat-card.red::after {
  background: var(--red);
}

.stat-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  font-family: var(--mono);
  line-height: 1;
}
.stat-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 6px;
  font-family: var(--mono);
}

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
}

tbody tr {
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child {
  border-bottom: none;
}
tbody tr:hover {
  background: var(--bg3);
}

td {
  padding: 11px 16px;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--mono);
}

.badge-green {
  background: rgba(74, 222, 128, 0.1);
  color: var(--accent);
}
.badge-red {
  background: rgba(248, 113, 113, 0.1);
  color: var(--red);
}
.badge-yellow {
  background: rgba(251, 191, 36, 0.1);
  color: var(--yellow);
}
.badge-blue {
  background: rgba(96, 165, 250, 0.1);
  color: var(--blue);
}
.badge-gray {
  background: rgba(90, 100, 120, 0.15);
  color: var(--text3);
}

.actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Toggle switch */
.toggle {
  width: 36px;
  height: 20px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 100px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text3);
  transition: all 0.2s;
}

.toggle.on {
  background: rgba(74, 222, 128, 0.15);
  border-color: var(--accent2);
}
.toggle.on::after {
  left: 18px;
  background: var(--accent);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  width: 480px;
  max-width: 96vw;
  transform: translateY(16px);
  transition: transform 0.2s;
  box-shadow: var(--shadow);
}

.modal-overlay.open .modal {
  transform: none;
}

.modal-header {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 14px;
  font-weight: 600;
}
.modal-body {
  padding: 20px;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s;
}

.close-btn:hover {
  background: var(--bg3);
  color: var(--text);
}

/* ── Form ── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.form-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

.form-control {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font: 13px var(--mono);
  padding: 8px 12px;
  transition: border-color 0.15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent2);
}
.form-control::placeholder {
  color: var(--text3);
}

textarea.form-control {
  resize: vertical;
  min-height: 72px;
  font-family: var(--font);
  font-size: 13px;
}

/* ── Log viewer ── */
.log-terminal {
  background: #070809;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
  height: 380px;
  overflow-y: auto;
  padding: 14px;
  line-height: 1.7;
}

.log-line {
  display: flex;
  gap: 12px;
}
.log-ts {
  color: var(--text3);
  flex-shrink: 0;
}
.log-msg.info {
  color: var(--text2);
}
.log-msg.error {
  color: var(--red);
}
.log-msg.warn {
  color: var(--yellow);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text3);
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  margin-bottom: 6px;
}
.empty-sub {
  font-size: 12px;
}

/* ── Chart ── */
.mini-chart {
  height: 56px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 0 2px;
}

.bar {
  flex: 1;
  border-radius: 2px 2px 0 0;
  background: rgba(74, 222, 128, 0.25);
  min-height: 2px;
  transition: height 0.3s;
}

/* ── Pages ── */
.page {
  display: none;
}
.page.active {
  display: block;
}

/* ── Toast ── */
.toasts {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  pointer-events: all;
  max-width: 320px;
}

.toast.success {
  border-left: 3px solid var(--accent);
}
.toast.error {
  border-left: 3px solid var(--red);
}
.toast.info {
  border-left: 3px solid var(--blue);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ── Settings grid ── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.dns-record {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 8px;
  color: var(--accent);
}

/* ── Auth overlay ── */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 8, 10, 0.92);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 20px;
}
.auth-overlay.open {
  display: flex;
}

.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 32px 28px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b0c0f;
  box-shadow: 0 0 24px rgba(74, 222, 128, 0.25);
}
.auth-icon svg {
  width: 22px;
  height: 22px;
}

.auth-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}
.auth-sub {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}
.auth-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 14px;
  line-height: 1.6;
}
.auth-hint code {
  background: var(--bg3);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  color: var(--accent);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text3);
}

/* ── Reset Desktop Overrides from Figma Theme ── */
@media (min-width: 1025px) {
  .layout {
    width: 100%;
    min-height: 100vh;
    background: var(--bg2);
    border-radius: 0;
    box-shadow: none;
  }

  .sidebar {
    position: fixed;
    width: 220px;
    min-height: 100vh;
  }

  .main {
    margin-left: 220px;
  }
}

/* ── Hamburger toggle (mobile only) ── */
.menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  flex-shrink: 0;
}
.menu-toggle:hover {
  background: #1e2330;
}
.menu-toggle svg {
  width: 20px;
  height: 20px;
}

/* ── Sidebar backdrop (mobile only) ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 199;
}
.sidebar-backdrop.open {
  display: block;
}

/* ── Activity row (was inline grid) ── */
.activity-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Topbar layout helper ── */
.topbar-left {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

/* ─── Tablet ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .activity-row {
    grid-template-columns: 1fr;
  }
  .content {
    padding: 20px;
  }
}

/* ─── Tablet & narrow desktop: hide sidebar, switch wide tables to cards ── */
/* Wide tables (Routes 7-col, Logs 8-col) don't fit a 1024px laptop with a    */
/* 220px sidebar, so we collapse the sidebar to off-canvas + render the      */
/* tables as a vertical card list at this breakpoint.                        */
@media (max-width: 1024px) {
  .menu-toggle {
    display: inline-flex;
  }

  /* Off-canvas sidebar */
  .sidebar {
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.55);
  }
  .sidebar.open {
    transform: none;
  }

  .main {
    margin-left: 0;
  }

  /* Tables → card list */
  .table-wrap {
    overflow: visible;
  }
  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }
  thead {
    display: none;
  }

  tbody tr {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 12px;
    padding: 6px 4px;
  }
  tbody tr:hover {
    background: var(--bg3);
  }
  tbody tr.tr-empty {
    background: transparent;
    border: none;
    margin: 0;
    padding: 0;
  }

  tbody td {
    border: none;
    padding: 8px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 32px;
    max-width: 100%;
    overflow: hidden;
  }
  tbody td::before {
    content: attr(data-label);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text3);
    font-weight: 600;
    flex-shrink: 0;
  }
  tbody td:not([data-label])::before {
    display: none;
  }
  tbody td[data-label] {
    max-width: none;
  }
  /* Right-side value: allow truncate */
  tbody td > span,
  tbody td .actions {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  tbody td .actions {
    justify-content: flex-end;
    flex-wrap: wrap;
  }
}

/* ─── Mobile (phones only) ───────────────────────────────────────── */
@media (max-width: 720px) {
  body::before {
    background-size: 32px 32px;
    opacity: 0.18;
  }

  /* Topbar — compact, icon-only buttons */
  .topbar {
    height: 52px;
    padding: 0 14px;
  }
  .topbar-title {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
  }
  .topbar-right {
    gap: 6px;
  }
  .topbar-right .btn {
    padding: 8px 10px;
  }
  .topbar-right .btn-label {
    display: none;
  } /* icon-only */
  .topbar-right .btn svg {
    width: 16px;
    height: 16px;
  }

  /* Content & cards */
  .content {
    padding: 14px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-card {
    padding: 14px;
  }
  .stat-value {
    font-size: 22px;
  }
  .stat-label {
    font-size: 10px;
  }
  .activity-row {
    gap: 12px;
    margin-bottom: 16px;
  }

  .card-header {
    padding: 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .card-body {
    padding: 14px;
  }

  /* Forms — 16px prevents iOS zoom-on-focus */
  .form-control {
    font-size: 16px;
    padding: 10px 12px;
  }
  textarea.form-control {
    font-size: 14px;
  }
  .form-group {
    margin-bottom: 14px;
  }

  /* Bigger toggle switch */
  .toggle {
    width: 44px;
    height: 24px;
  }
  .toggle::after {
    width: 18px;
    height: 18px;
    top: 2px;
    left: 2px;
  }
  .toggle.on::after {
    left: 22px;
  }

  /* Buttons — easier tap targets */
  .btn {
    padding: 9px 14px;
  }
  .btn-sm {
    padding: 7px 12px;
    font-size: 12.5px;
  }

  /* Modal → bottom sheet */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    width: 100%;
    max-width: 100vw;
    border-radius: 14px 14px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    transform: translateY(40px);
  }
  .modal-overlay.open .modal {
    transform: none;
  }
  .modal-header {
    padding: 14px 16px;
  }
  .modal-body {
    padding: 16px;
  }
  .modal-footer {
    padding: 12px 16px;
  }
  .modal-footer .btn {
    flex: 1;
    justify-content: center;
    padding: 11px 14px;
  }

  /* Toasts */
  .toasts {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  .toast {
    max-width: none;
  }

  /* Tighter card list on phones */
  tbody tr {
    margin: 8px;
  }
  tbody td {
    padding: 7px 12px;
  }

  /* SMTP terminal */
  .log-terminal {
    height: 320px;
    font-size: 11.5px;
    padding: 10px;
  }
  .log-line {
    gap: 8px;
  }

  /* Auth */
  .auth-card {
    padding: 26px 20px 22px;
    max-width: 100%;
  }
  .auth-overlay {
    padding: 16px;
  }

  /* DNS page records */
  .dns-record {
    font-size: 11.5px;
    padding: 10px 12px;
    word-break: break-word;
  }
}

/* ─── Very small phones ──────────────────────────────────────────── */
@media (max-width: 380px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .topbar-title {
    font-size: 13.5px;
  }
  .topbar-right .btn {
    padding: 7px 9px;
  }
  .content {
    padding: 12px;
  }
}

/* ── Figma Dashboard Dark theme ──────────────────────────────────────────── */
:root {
  --bg: #30313a;
  --bg2: #171821;
  --bg3: #21222d;
  --bg4: #11121a;
  --border: #2a2b36;
  --border2: #343541;
  --text: #ffffff;
  --text2: #a0a0a0;
  --text3: #87888c;
  --accent: #a9dfd8;
  --accent2: #86cec5;
  --red: #ff7474;
  --yellow: #feb95a;
  --blue: #20aef3;
  --purple: #f2c8ed;
  --font: "Inter", sans-serif;
  --radius: 10px;
  --shadow: 0 30px 60px rgba(0, 0, 0, 0.2);
}

body {
  background: var(--bg2);
  color: var(--text);
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

body::before {
  display: none;
}

.layout {
  width: 100%;
  height: 100vh;
  background: var(--bg2);
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  display: flex;
}

.sidebar {
  position: relative;
  z-index: 200;
  width: 220px;
  height: 100vh;
  overflow-y: auto;
  flex: 0 0 220px;
  background: #171821;
  border-right: 1px solid var(--border);
}

.sidebar-logo {
  height: 72px;
  padding: 20px 14px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo .logo-mark {
  justify-content: flex-start;
  padding-left: 10px;
}
.logo-icon,
.logo-sub {
  display: flex;
}
.logo-text {
  width: auto;
  text-align: left;
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
  font-weight: 600;
}

.nav {
  padding: 12px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-section {
  display: block;
  margin-top: 10px;
}

.nav-item {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  color: var(--text3);
  font-size: 13px;
  font-weight: 500;
  gap: 9px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(169, 223, 216, 0.08);
  color: var(--accent);
}
.nav-item.active {
  background: var(--accent);
  color: var(--bg2);
  border-left: 0;
  font-weight: 700;
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 16px 14px 22px;
  margin-top: auto;
}

.smtp-status {
  background: rgba(169, 223, 216, 0.08);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text2);
  font-size: 11px;
}

.status-dot {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(169, 223, 216, 0.8);
}

.main {
  margin-left: 0;
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg2);
}

.topbar {
  height: 72px;
  background: var(--bg2);
  border-bottom: 0;
  padding: 14px 24px 8px;
  gap: 18px;
}

.topbar-left {
  max-width: 170px;
}
.topbar-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.search-box {
  flex: 1;
  min-width: 160px;
  height: 44px;
  max-width: 504px;
  background: var(--bg3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d2d2d2;
  padding: 0 14px;
}

.search-box svg {
  width: 14px;
  height: 14px;
  color: #d2d2d2;
}

.search-box input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 500 12px var(--font);
  min-width: 0;
}

.search-box input::placeholder {
  color: #d2d2d2;
}

.topbar-right {
  gap: 10px;
}

.topbar-profile {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 60% 35%, #ffd5a8 0 18%, transparent 19%),
    linear-gradient(135deg, #a9dfd8, #feb95a);
  border: 2px solid rgba(255, 255, 255, 0.08);
}

.content {
  padding: 20px 24px 24px;
  overflow: auto;
}

.page.active {
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0.85;
  }
  to {
    opacity: 1;
  }
}

#page-dashboard.active {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(238px, 0.68fr);
  gap: 12px;
  align-items: start;
}

.stats-grid {
  grid-column: 1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 48px 14px 14px;
  position: relative;
}

.stats-grid::before {
  content: "Mail Flow Summary";
  position: absolute;
  left: 14px;
  top: 15px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.stats-grid::after {
  content: "Live routing overview";
  position: absolute;
  left: 14px;
  top: 35px;
  color: var(--text2);
  font-size: 10px;
  font-weight: 500;
}

.stat-card {
  background: var(--bg2);
  border: 0;
  min-height: 107px;
  padding: 44px 12px 10px;
  border-radius: var(--radius);
}

.stat-card::after {
  display: none;
}
.stat-card::before {
  display: none;
}

.stat-card.green {
  color: var(--yellow);
}
.stat-card.blue {
  color: var(--accent);
}
.stat-card.yellow {
  color: var(--purple);
}
.stat-card.red {
  color: var(--blue);
}

.stat-icon {
  position: absolute;
  left: 12px;
  top: 11px;
  width: 26px;
  height: 26px;
  border: 1.5px solid currentColor;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

.stat-icon svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.stat-label {
  color: #e8e8e8;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
  margin: 4px 0 0;
}

.stat-value {
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.1;
}

.stat-sub {
  color: currentColor;
  font-family: var(--font);
  font-size: 8px;
  font-weight: 700;
  margin-top: 5px;
}

.activity-row {
  grid-column: 2;
  grid-row: span 2;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 0;
}

#page-dashboard > .card {
  grid-column: 1;
}

.card {
  background: var(--bg3);
  border: 0;
  border-radius: var(--radius);
}

.card-header {
  padding: 14px 14px 10px;
  border-bottom: 0;
}

.card-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.card-body {
  padding: 12px 14px 16px;
}

.mini-chart {
  height: 132px;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 4px 0;
}

.bar {
  background: linear-gradient(180deg, var(--accent), rgba(169, 223, 216, 0.16));
  border-radius: 4px 4px 0 0;
  max-width: 16px;
}

table {
  color: var(--text);
  font-size: 12px;
}

thead th {
  background: transparent;
  border-bottom: 0;
  color: var(--text3);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  padding: 8px 16px;
}

tbody tr {
  border-bottom: 0;
}
tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}
td {
  padding: 10px 16px;
}

.mono {
  font-family: var(--font);
  font-size: 12px;
}

.badge {
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font);
  font-size: 10px;
}

.badge-green {
  color: var(--yellow);
  background: rgba(254, 185, 90, 0.12);
  border: 1px solid rgba(254, 185, 90, 0.45);
}
.badge-red {
  color: var(--red);
  background: rgba(255, 116, 116, 0.1);
  border: 1px solid rgba(255, 116, 116, 0.35);
}
.badge-yellow {
  color: var(--purple);
  background: rgba(242, 200, 237, 0.1);
  border: 1px solid rgba(242, 200, 237, 0.35);
}
.badge-blue {
  color: var(--blue);
  background: rgba(32, 174, 243, 0.1);
  border: 1px solid rgba(32, 174, 243, 0.35);
}
.badge-gray {
  color: var(--text3);
  background: rgba(135, 136, 140, 0.12);
  border: 1px solid rgba(135, 136, 140, 0.28);
}

.btn {
  border: 0;
  background: var(--bg3);
  color: var(--text2);
  border-radius: 6px;
  font: 600 12px var(--font);
}

.btn:hover {
  background: #2b2c38;
  color: var(--text);
}
.btn-primary,
.btn-primary:hover {
  background: var(--accent);
  color: var(--bg2);
}
.btn-danger {
  color: var(--red);
  background: rgba(255, 116, 116, 0.08);
}

.toggle {
  background: #2b2b36;
  border: 0;
}

.toggle.on {
  background: rgba(169, 223, 216, 0.24);
  border-color: transparent;
}

.toggle.on::after {
  background: var(--accent);
}

.form-control {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-family: var(--font);
}

.form-control:focus {
  border-color: var(--accent);
}
.form-label {
  color: #e8e8e8;
}
.form-hint {
  color: var(--text3);
}

.log-terminal,
.dns-record {
  background: var(--bg2);
  border-color: var(--border);
}

.modal,
.auth-card,
.toast {
  background: var(--bg3);
  border-color: var(--border2);
}

.modal-header,
.modal-footer {
  border-color: var(--border);
}

.empty-state {
  color: var(--text3);
}
.empty-title {
  color: var(--text2);
}

.empty-icon {
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  font-size: 0;
  opacity: 0.92;
  position: relative;
}

.empty-icon::before {
  content: "";
  position: absolute;
  inset: 4px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3E%3Cg%20fill='none'%20stroke='black'%20stroke-linecap='round'%20stroke-linejoin='round'%20stroke-width='2'%3E%3Crect%20x='3'%20y='5'%20width='18'%20height='14'%20rx='2'/%3E%3Cpath%20d='m3%207%209%206%209-6'/%3E%3C/g%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3E%3Cg%20fill='none'%20stroke='black'%20stroke-linecap='round'%20stroke-linejoin='round'%20stroke-width='2'%3E%3Crect%20x='3'%20y='5'%20width='18'%20height='14'%20rx='2'/%3E%3Cpath%20d='m3%207%209%206%209-6'/%3E%3C/g%3E%3C/svg%3E")
    center / contain no-repeat;
}

#page-logs .empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#page-logs .empty-icon {
  display: block;
  margin-inline: auto;
}

#page-logs .empty-icon::before {
  inset: auto;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
}

@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    min-height: 100vh;
    width: 220px;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: none;
  }
  .main {
    margin-left: 0;
  }
  #page-dashboard.active {
    grid-template-columns: 1fr;
  }
  .stats-grid,
  .activity-row,
  #page-dashboard > .card {
    grid-column: 1;
  }
  .activity-row {
    grid-row: auto;
  }
}

@media (max-width: 720px) {
  body {
    padding: 0;
  }
  html,
  body {
    background: var(--bg2);
    overflow-x: hidden;
  }
  .layout {
    width: 100vw;
    min-height: 100dvh;
    border-radius: 0;
  }
  .topbar {
    height: auto;
    padding: 12px;
    flex-wrap: wrap;
  }
  .topbar-left {
    max-width: none;
  }
  .search-box {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  .topbar-profile {
    display: none;
  }
  .content {
    padding: 12px;
  }
  #page-logs {
    width: 100%;
  }
  #page-logs .card {
    width: min(100%, 382px);
    margin-inline: auto;
  }
  #page-logs .card-header {
    justify-content: center;
    gap: 14px;
    text-align: center;
  }
  #page-logs .card-header > div {
    justify-content: center;
    flex-wrap: wrap;
  }
  #page-logs tr.tr-empty,
  #page-logs tr.tr-empty td {
    width: 100%;
  }
  #page-logs tr.tr-empty td {
    display: block;
    padding-inline: 0;
    overflow: visible;
  }
  #page-logs .empty-state {
    width: 100%;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-top: 48px;
    gap: 14px;
  }
  .stat-card {
    min-height: 102px;
    padding: 46px 10px 10px;
  }
  .stat-label {
    line-height: 1.25;
    min-height: 26px;
  }
  .stat-value {
    font-size: 16px;
  }
  .stat-sub {
    line-height: 1.25;
    white-space: normal;
  }
  .mini-chart {
    height: 122px;
    gap: 5px;
  }
  .bar {
    max-width: none;
  }
  .card-body {
    padding: 10px 14px 14px;
  }
  .empty-state {
    padding: 34px 14px !important;
  }
  .empty-icon {
    width: 36px;
    height: 36px;
    margin-bottom: 10px;
  }
  .card-header {
    align-items: flex-start;
  }
}


/* ── Inbox row state ─────────────────────────────────────────────────────── */
tbody tr.row-unread {
  background: rgba(169, 223, 216, 0.04);
}
tbody tr.row-unread:hover {
  background: rgba(169, 223, 216, 0.08);
}
.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(169, 223, 216, 0.7);
}

/* ── Sidebar nav badge (unread count) ────────────────────────────────────── */
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--bg2);
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  line-height: 1;
}
.nav-item.active .nav-badge {
  background: var(--bg2);
  color: var(--accent);
}

/* ── Email detail modal ──────────────────────────────────────────────────── */
.modal.modal-lg {
  max-width: 820px;
  width: min(820px, 95vw);
}
.email-meta {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}
.email-meta .meta-row {
  display: flex;
  gap: 12px;
  font-size: 12.5px;
  align-items: baseline;
}
.email-meta .meta-key {
  color: var(--text3);
  width: 80px;
  flex-shrink: 0;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
  font-weight: 600;
  padding-top: 2px;
}
.email-meta .meta-val {
  color: var(--text);
  word-break: break-word;
  flex: 1;
}
.email-meta code {
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
}

.email-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.email-tab {
  background: transparent;
  border: 0;
  color: var(--text3);
  padding: 8px 14px;
  font: 600 12px var(--font);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.email-tab:hover {
  color: var(--text2);
}
.email-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.email-body {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 280px;
  max-height: 60vh;
  overflow: auto;
  padding: 0;
}
.email-iframe {
  width: 100%;
  min-height: 50vh;
  border: 0;
  background: #fff;
  border-radius: var(--radius);
  display: block;
}
.email-text {
  margin: 0;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 720px) {
  .modal.modal-lg {
    max-width: 100vw;
    width: 100%;
  }
  .email-meta .meta-key {
    width: 64px;
  }
  .email-iframe {
    min-height: 56vh;
  }
}


/* ── Alias + domain composite input ──────────────────────────────────────── */
.alias-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.alias-row .form-control {
  flex: 1;
  min-width: 0;
}
.alias-row #routeAlias {
  flex: 1 1 50%;
}
.alias-row #routeDomain {
  flex: 1 1 50%;
}
.alias-row .alias-at {
  align-self: center;
  color: var(--text3);
  font-family: var(--mono);
  font-size: 16px;
  padding: 0 2px;
}

/* ── DNS Setup: per-domain check cards ───────────────────────────────────── */
.dns-domain-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.dns-domain-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.dns-domain-name {
  font-weight: 700;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
}
.dns-checks {
  display: grid;
  gap: 6px;
  font-size: 12.5px;
}
.dns-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text2);
  flex-wrap: wrap;
}
.dns-detail {
  color: var(--text3);
  font-family: var(--mono);
  font-size: 11.5px;
}
.dns-status {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.dns-status.ok {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(169, 223, 216, 0.7);
}
.dns-status.fail {
  background: var(--red);
  box-shadow: 0 0 6px rgba(255, 116, 116, 0.55);
}
.dns-status.pending {
  background: var(--text3);
  opacity: 0.5;
}

@media (max-width: 720px) {
  .alias-row {
    flex-direction: column;
    gap: 8px;
  }
  .alias-row .alias-at {
    display: none;
  }
}
