:root {
  --color-bg: #e7ebf1;
  --color-surface: #ffffff;
  --color-border: #d5dbe3;
  --color-text: #1f2937;
  --color-muted: #5b6472;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-success: #059669;
  --color-success-bg: #d1fae5;
  --color-error: #dc2626;
  --color-error-bg: #fee2e2;
  --color-warning: #b45309;
  --color-warning-bg: #fef3c7;
  --radius: 6px;
  --shadow-sm:
    0 1px 3px rgba(15, 23, 42, 0.09), 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md:
    0 6px 16px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.08);
  --shadow-lg:
    0 20px 48px rgba(15, 23, 42, 0.22), 0 6px 16px rgba(15, 23, 42, 0.12);
}

:root[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-border: #334155;
  --color-text: #e5e7eb;
  --color-muted: #94a3b8;
  --color-primary: #3b82f6;
  --color-primary-dark: #60a5fa;
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.16);
  --color-error: #f87171;
  --color-error-bg: rgba(248, 113, 113, 0.16);
  --color-warning: #fbbf24;
  --color-warning-bg: rgba(251, 191, 36, 0.14);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.65), 0 6px 16px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-border: #334155;
    --color-text: #e5e7eb;
    --color-muted: #94a3b8;
    --color-primary: #3b82f6;
    --color-primary-dark: #60a5fa;
    --color-success: #10b981;
    --color-success-bg: rgba(16, 185, 129, 0.16);
    --color-error: #f87171;
    --color-error-bg: rgba(248, 113, 113, 0.16);
    --color-warning: #fbbf24;
    --color-warning-bg: rgba(251, 191, 36, 0.14);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.65), 0 6px 16px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

*,
*::before,
*::after {
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

body.dashboard-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---- Auth pages ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
}

.auth-card h1 {
  margin-top: 0;
  font-size: 1.25rem;
}

.auth-card label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.auth-card input {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: var(--color-surface);
  color: var(--color-text);
}

.auth-card button {
  margin-top: 1.25rem;
  width: 100%;
  padding: 0.6rem;
  border: none;
  border-radius: var(--radius);
  background: var(--color-primary);
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.auth-card button:hover {
  background: var(--color-primary-dark);
}

.auth-card button.btn-link {
  width: auto;
  margin-top: 0;
  padding: 0;
  background: none;
  color: var(--color-primary);
  box-shadow: none;
}

.auth-card button.btn-link:hover {
  background: none;
  text-decoration: underline;
}

.alert {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
}

.alert-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

/* ---- Navigation bar ---- */
.topbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  column-gap: 1.5rem;
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.topbar h1 {
  margin: 0;
  font-size: 1.15rem;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-self: start;
}

.topbar-title {
  margin: 0;
  font-size: 1.15rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--color-muted);
  justify-self: end;
}

.btn-link {
  color: var(--color-primary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-size: inherit;
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

/* ---- Main content area ---- */
.dashboard-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 40px 20px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 30px;
  color: var(--color-text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---- Cards ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 2rem;
}

.card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--color-primary);
}

.card-description {
  font-size: 14px;
  color: var(--color-muted);
  margin: 0 0 20px;
  line-height: 1.6;
}

.card-cta {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 500;
  font-size: 14px;
  color: #fff;
  background: var(--color-primary);
  text-decoration: none;
  cursor: pointer;
  border: none;
}

.card-cta:hover {
  background: var(--color-primary-dark);
}

/* ---- Tables ---- */
.table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

table th,
table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}

table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-surface);
  color: var(--color-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

table tbody tr:hover {
  background: rgba(37, 99, 235, 0.05);
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.badge-error {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.badge-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

/* ---- Loading states (System Status) ---- */
.spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  vertical-align: -0.15em;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

.status-placeholder {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  font-size: 0.9rem;
  color: var(--color-text);
  border-top: 4px solid var(--color-border);
}

.status-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

/* ---- System Status rows ---- */
.status-legend {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.status-card {
  padding: 0;
  overflow: hidden;
}

.status-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--color-border);
  border-left: 4px solid transparent;
  font-size: 0.9rem;
  color: var(--color-text);
}

.status-row:last-child {
  border-bottom: none;
}

.status-row-icon {
  min-width: 20px;
  text-align: center;
  font-weight: bold;
  margin-top: 0.1rem;
}

.status-row-body {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.status-details {
  color: var(--color-muted);
}

.status-details code,
.status-note code {
  font-size: 0.85em;
}

.status-link {
  margin-left: 0.4rem;
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.status-domain {
  margin-bottom: 1.5rem;
  border-top: 4px solid var(--color-border);
}

.status-domain-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text);
  user-select: none;
  border-bottom: 1px solid var(--color-border);
}

.status-domain-count {
  margin-left: 0.5rem;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.status-refresh {
  margin: 0;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.status-table {
  margin-top: 0.75rem;
}

.status-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.status-table th {
  text-align: left;
  font-weight: 600;
  color: var(--color-muted);
  padding: 0 0.75rem 0.35rem 0;
}

.status-table td {
  padding: 0.35rem 0.75rem 0.35rem 0;
  border-top: 1px solid var(--color-border);
}

.status-table .muted {
  color: var(--color-muted);
}

.status-note {
  margin: 0.5rem 0 0;
  color: var(--color-muted);
  font-size: 0.8rem;
}

/* Expandable row in Mail Server Health (e.g. the list of pending updates) */
.status-expand > summary {
  cursor: pointer;
  list-style: none;
}

.status-expand > summary::-webkit-details-marker {
  display: none;
}

.status-expand-hint {
  margin-left: 0.4rem;
  color: var(--color-primary);
  font-size: 0.85rem;
  white-space: nowrap;
}

.status-expand-hint::after {
  content: "Show list ▸";
}

.status-expand[open] .status-expand-hint::after {
  content: "Hide list ▾";
}

/* ---- Buttons ---- */
.btn {
  padding: 0.45rem 0.9rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn-secondary:hover {
  background: rgba(37, 99, 235, 0.2);
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  filter: brightness(0.85);
}

button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--color-border) !important;
  color: var(--color-muted) !important;
}

button:disabled:hover,
.btn:disabled:hover {
  position: relative;
  filter: none !important;
}

button:disabled::after,
.btn:disabled::after {
  content: ' ✗';
  font-weight: bold;
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--color-muted);
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--color-text);
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-muted);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius);
}

.modal-close:hover {
  color: var(--color-text);
  background: rgba(37, 99, 235, 0.1);
}

.modal-actions {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ---- Lists ---- */
.list-unstyled {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-unstyled li {
  padding: 0.75rem 0;
}

/* ---- Links ---- */
a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Utility classes ---- */
.flex {
  display: flex;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gap-1 {
  gap: 1rem;
}

.mt-1 {
  margin-top: 1rem;
}

.mt-2 {
  margin-top: 2rem;
}

.mb-1 {
  margin-bottom: 1rem;
}

.mb-2 {
  margin-bottom: 2rem;
}

.text-muted {
  color: var(--color-muted);
}

.text-center {
  text-align: center;
}

/* ---- User Menu ---- */
.user-menu {
  position: relative;
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
  font: inherit;
  color: var(--color-muted);
}

.user-menu-toggle:hover {
  background: rgba(37, 99, 235, 0.1);
}

.user-menu-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  line-height: 1.35;
}

.user-menu-line1 {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.user-menu-line1 strong {
  color: var(--color-text);
}

.user-menu-line2 {
  font-size: 0.75rem;
  color: var(--color-muted);
}

.user-menu-chevron {
  flex: 0 0 auto;
  color: var(--color-muted);
  transition: transform 0.2s ease;
}

.user-menu-toggle[aria-expanded="true"] .user-menu-chevron {
  transform: rotate(180deg);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  padding: 0.3rem;
  z-index: 150;
}

.user-menu-item {
  display: block;
  box-sizing: border-box;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--color-text);
  text-decoration: none;
}

.user-menu-item:hover {
  background: rgba(37, 99, 235, 0.1);
}

.user-menu-item-danger {
  color: var(--color-error);
}

.user-menu-item-danger:hover {
  background: var(--color-error-bg);
}

.user-menu-divider {
  height: 1px;
  background: var(--color-border);
  margin: 0.3rem 0;
}

/* ---- Theme Switch ---- */
.theme-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0.3rem 0.4rem 0.5rem;
  padding: 2px;
  background: rgba(37, 99, 235, 0.05);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.theme-switch-btn {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-muted);
}

.theme-switch-btn:hover {
  background: rgba(37, 99, 235, 0.1);
}

.theme-switch-btn.is-active {
  background: var(--color-primary);
  color: #fff;
}

/* ---- Toast Notifications (from kelly-portal) ---- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 260px;
  max-width: 420px;
  padding: 0.6rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  color: var(--color-text);
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-active {
  opacity: 1;
  transform: translateX(0);
}

.toast-exit {
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-icon {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1;
}

.toast-message {
  flex: 1 1 auto;
  line-height: 1.4;
}

.toast-close {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
}

.toast-close:hover {
  color: var(--color-text);
}

.toast-success {
  border-left: 3px solid var(--color-success);
}

.toast-success .toast-icon {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.toast-error {
  border-left: 3px solid var(--color-error);
}

.toast-error .toast-icon {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.toast-warning {
  border-left: 3px solid var(--color-warning);
}

.toast-warning .toast-icon {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.toast-info {
  border-left: 3px solid var(--color-primary);
}

.toast-info .toast-icon {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
}

/* ---- Icon Buttons & Action Menus ---- */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--color-muted);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
}

.btn-icon-danger:hover {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.action-menu {
  position: relative;
  display: inline-block;
}

.action-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--color-muted);
  transition: all 0.2s ease;
}

.action-menu-toggle:hover {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-text);
}

.action-menu-dropdown {
  position: fixed;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  padding: 0.4rem;
  z-index: 1000;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.action-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--color-text);
  text-align: left;
  transition: all 0.2s ease;
}

.action-menu-item:hover {
  background: rgba(37, 99, 235, 0.1);
  color: var(--color-primary);
}

.action-menu-item.action-menu-item-danger:hover {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.action-menu-icon {
  width: 16px;
  height: 16px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ---- Password field (password_policy.php password_field(), password-field.js) ---- */
.password-input-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.password-input-row input {
  flex: 1 1 12rem;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.password-btn {
  flex: 0 0 auto;
}

.password-meter {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.password-meter span {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
}

.password-meter[data-level="1"] span:nth-child(-n+1) { background: var(--color-error); }
.password-meter[data-level="2"] span:nth-child(-n+2) { background: var(--color-warning); }
.password-meter[data-level="3"] span:nth-child(-n+3) { background: var(--color-success); }
.password-meter[data-level="4"] span { background: var(--color-success); }

.password-meter-label {
  min-height: 1.1rem;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.password-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  margin: 0.35rem 0 0.4rem;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.password-rules li::before {
  content: "○ ";
}

.password-rules li.met {
  color: var(--color-success);
}

.password-rules li.met::before {
  content: "✓ ";
}

.password-hint {
  display: block;
  margin: 0.2rem 0 0.4rem;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.password-hint a {
  color: var(--color-primary);
  text-decoration: none;
}

.password-match {
  min-height: 1.1rem;
  margin-top: 0.35rem;
  font-size: 0.85rem;
}

.password-match[data-state="ok"] { color: var(--color-success); }
.password-match[data-state="bad"] { color: var(--color-error); }

.badge-admin {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  vertical-align: middle;
  color: var(--color-primary);
  background: rgba(37, 99, 235, 0.12);
}

.modal-subtitle {
  margin: -0.25rem 0 1rem;
  color: var(--color-muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

/* ---- Server setup checklist (domain page) and Certificates page ---- */
.section-title {
  margin: 2rem 0 1rem;
  font-size: 1.1rem;
  color: var(--color-text);
}

.setup-action {
  display: inline-block;
  margin: 0.4rem 0 0 0.5rem;
  vertical-align: middle;
}

.cert-table td {
  vertical-align: top;
}

/* ---- Avatars (billing/avatar.php): a photo, or initials on one of twelve colours ---- */
.avatar { display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; overflow: hidden; background: var(--color-border); font-weight: 700; color: #fff; vertical-align: middle; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 30px; height: 30px; font-size: 0.7rem; }
.avatar-md { width: 38px; height: 38px; font-size: 0.85rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.15rem; }
.avatar-xl { width: 112px; height: 112px; font-size: 2.3rem; box-shadow: var(--shadow-md); }
.avatar-initials { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.avatar-hue-0 { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.avatar-hue-1 { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.avatar-hue-2 { background: linear-gradient(135deg, #14b8a6, #0ea5e9); }
.avatar-hue-3 { background: linear-gradient(135deg, #10b981, #14b8a6); }
.avatar-hue-4 { background: linear-gradient(135deg, #84cc16, #10b981); }
.avatar-hue-5 { background: linear-gradient(135deg, #f59e0b, #f97316); }
.avatar-hue-6 { background: linear-gradient(135deg, #f97316, #ef4444); }
.avatar-hue-7 { background: linear-gradient(135deg, #ef4444, #ec4899); }
.avatar-hue-8 { background: linear-gradient(135deg, #ec4899, #d946ef); }
.avatar-hue-9 { background: linear-gradient(135deg, #d946ef, #8b5cf6); }
.avatar-hue-10 { background: linear-gradient(135deg, #64748b, #334155); }
.avatar-hue-11 { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.client-cell { display: flex; align-items: center; gap: 0.6rem; }
.client-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.client-head-text { display: flex; flex-direction: column; gap: 0.1rem; margin-right: auto; }
.client-head-text strong { font-size: 1.15rem; }
.client-photo { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; font-size: 0.85rem; }
.client-photo form { margin: 0; }
.photo-card { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; padding: 1.5rem; max-width: 640px; }
.photo-card > div { flex: 1 1 260px; }
.photo-form label { position: relative; display: inline-block; }

/* ---- Photo crop dialog (crop.js) ---- */
.crop-dialog { width: min(26rem, calc(100vw - 2rem)); padding: 0; border: 1px solid var(--color-border); border-radius: 14px; background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-lg); }
.crop-dialog::backdrop { background: rgba(15, 23, 42, 0.6); }
.crop-inner { padding: 1.25rem; margin: 0; }
.crop-canvas { display: block; width: 100%; aspect-ratio: 1; margin: 0.75rem 0; border-radius: 50%; background: var(--color-bg); cursor: grab; touch-action: none; }
.crop-canvas.is-dragging { cursor: grabbing; }
.crop-zoom { width: 100%; margin-bottom: 1rem; accent-color: var(--color-primary); }

/* ---- Edit dialogs (data-dialog, shared.js) ---- */
.edit-dialog { width: min(34rem, calc(100vw - 2rem)); padding: 0; border: 1px solid var(--color-border); border-radius: 14px; background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-lg); text-align: left; white-space: normal; }
.edit-dialog::backdrop { background: rgba(15, 23, 42, 0.6); }
.edit-inner { padding: 1.25rem 1.5rem; margin: 0; }
.edit-inner h3 { margin: 0 0 1rem; }
.edit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 1rem; }
.edit-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }

/* ---- Stats (stats.php, stats.js): ported from Wombat-Email's panel. Series colours in a fixed order
   (checked for colour-blind separation), each stepped for its theme; green, amber and red stay for state. */
:root { --c0: #2a78d6; --c1: #eb6834; --c2: #1baf7a; --c3: #eda100; --c4: #e87ba4; --c5: #6250d6; }
:root[data-theme="dark"] { --c0: #3987e5; --c1: #d95926; --c2: #199e70; --c3: #c98500; --c4: #d55181; --c5: #9085e9; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) { --c0: #3987e5; --c1: #d95926; --c2: #199e70; --c3: #c98500; --c4: #d55181; --c5: #9085e9; }
}
.stats-page h2 { margin: 0; }
.st-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.st-lead { margin: 0.25rem 0 0; color: var(--color-muted); font-size: 0.85rem; }
.st-head-right { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.st-seg { display: flex; }
.st-seg a { padding: 4px 10px; border: 1px solid var(--color-border); margin-left: -1px; background: var(--color-surface); color: var(--color-text);
  font: 400 0.8rem ui-monospace, "SF Mono", Menlo, monospace; text-decoration: none; }
.st-seg a:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.st-seg a:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.st-seg a:hover { color: var(--color-primary); }
.st-seg a[aria-current] { position: relative; color: var(--color-primary); border-color: var(--color-primary); font-weight: 600; background: rgba(37, 99, 235, 0.09); }
.st-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 0 2px; margin: 0 0 1.25rem; border-bottom: 1px solid var(--color-border); font-size: 0.85rem; }
.st-tabs a { padding: 6px 10px; color: var(--color-text); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.st-tabs a:hover { color: var(--color-primary); }
.st-tabs a[aria-current="page"] { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.st-tabs-label { margin-left: 0.75rem; padding: 0 0.25rem 0 0.75rem; border-left: 1px solid var(--color-border); font-size: 0.72rem; color: var(--color-muted); white-space: nowrap; }
.st-side { margin: 1.5rem 0 0.75rem; font-size: 1.1rem; color: var(--color-text); }
.st-side span { font-size: 0.8rem; font-weight: 400; color: var(--color-muted); margin-left: 0.4rem; }
.st-h { margin: 1.5rem 0 0.5rem; font-size: 1rem; color: var(--color-text); }
.st-note { color: var(--color-muted); font-size: 0.85rem; }
.st-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
@media (max-width: 1040px) { .st-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 520px) { .st-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.st-tile { display: block; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 10px 12px; color: var(--color-text); text-decoration: none; transition: box-shadow .15s, transform .15s; }
.st-tile:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--color-primary); }
.st-tile b { display: block; font-size: 1.25rem; font-weight: 600; white-space: nowrap; }
.st-tile span { display: block; font-size: 0.72rem; color: var(--color-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
@media (max-width: 1080px) { .st-grid { grid-template-columns: minmax(0, 1fr); } }
.st-card, .stats-page .chart.large { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 10px 14px; }
.st-card h3 { display: flex; align-items: center; margin: 0 0 4px; font-size: 0.9rem; color: var(--color-text); }
.st-more { margin-left: auto; font-size: 0.8rem; font-weight: 400; color: var(--color-primary); text-decoration: none; }
.st-card .chart { margin: 0; }
.st-table td.n, .st-table th.n { text-align: right; font-variant-numeric: tabular-nums; }
.st-mark { font-weight: 700; } .st-mark.ok { color: var(--color-success); } .st-mark.warn { color: var(--color-warning); }
.st-mark.bad { color: var(--color-error); } .st-mark.unknown { color: var(--color-muted); }
.st-wait { padding: 1.25rem; }
.stats-page .chart { margin: 0 0 12px; outline-offset: 3px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 2px 16px; margin-bottom: 4px; font-size: 0.72rem; color: var(--color-muted); }
.leg { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.leg b { color: var(--color-text); font-weight: 600; }
.key { display: inline-block; width: 12px; height: 2px; border-radius: 1px; background: var(--c0); flex: none; }
.chart-plot { position: relative; min-height: 150px; font-size: 0.8rem; color: var(--color-muted); }
.chart.large .chart-plot { min-height: 230px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg .grid { stroke: var(--color-border); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-svg .axis { stroke: var(--color-border); stroke-width: 1; }
.chart-svg .tick { fill: var(--color-muted); font: 400 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-variant-numeric: tabular-nums; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .area { stroke: none; fill-opacity: .16; }
.chart-svg .cross { stroke: var(--color-muted); stroke-width: 1; }
.chart-svg .dot { stroke: var(--color-surface); stroke-width: 2; }
.chart-svg .hit { fill: transparent; cursor: crosshair; }
.s0 { stroke: var(--c0); fill: var(--c0); } .key.s0 { background: var(--c0); }
.s1 { stroke: var(--c1); fill: var(--c1); } .key.s1 { background: var(--c1); }
.s2 { stroke: var(--c2); fill: var(--c2); } .key.s2 { background: var(--c2); }
.s3 { stroke: var(--c3); fill: var(--c3); } .key.s3 { background: var(--c3); }
.s4 { stroke: var(--c4); fill: var(--c4); } .key.s4 { background: var(--c4); }
.s5 { stroke: var(--c5); fill: var(--c5); } .key.s5 { background: var(--c5); }
.chart-svg .line.s0, .chart-svg .line.s1, .chart-svg .line.s2, .chart-svg .line.s3, .chart-svg .line.s4, .chart-svg .line.s5 { fill: none; }
.chart-tip { position: absolute; z-index: 2; pointer-events: none; min-width: 150px; padding: 4px 8px; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); font-size: 0.72rem; color: var(--color-muted); white-space: nowrap; }
.tip-time { margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: 6px; line-height: 1.6; }
.tip-row b { min-width: 52px; color: var(--color-text); font-weight: 600; font-variant-numeric: tabular-nums; }
