/* ===================================================
   Domain Sentinel — Redesigned UI
   Modern dark-sidebar-free, top-nav layout
   =================================================== */

:root {
  /* Neutral palette */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Brand / Primary */
  --primary-50:  #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;

  /* Semantic */
  --red-50:  #fef2f2;
  --red-100: #fee2e2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-700: #b91c1c;

  --amber-50:  #fffbeb;
  --amber-100: #fef3c7;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;

  --green-50:  #f0fdf4;
  --green-100: #dcfce7;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-700: #15803d;

  /* Surfaces */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.03);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.03);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Font */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary-600); text-decoration: none; }
table { border-collapse: collapse; }
.hidden { display: none !important; }

/* ===================================================
   LOGIN SCREEN
   =================================================== */
.login-screen {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
}
.login-backdrop {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
}
.login-backdrop::after {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(59,130,246,0.15), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(99,102,241,0.1), transparent 50%);
}
.login-card {
  position: relative; z-index: 1;
  width: min(400px, 100%);
  padding: 36px 32px 28px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.1);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.logo-icon {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 56px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #fff;
  margin-bottom: 16px;
}
.login-logo h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-subtitle {
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}
.login-fields {
  display: grid; gap: 16px;
}
.field { display: grid; gap: 6px; }
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.input-wrap {
  position: relative;
}
.input-icon {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}
.input-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-wrap input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
  background: #fff;
}
.input-wrap input::placeholder { color: var(--text-tertiary); }
.login-footer {
  margin: 16px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ===================================================
   APP SHELL — TOP NAV LAYOUT
   =================================================== */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Bar ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon {
  display: flex;
  align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #fff;
}
.brand-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-item:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--primary-50);
  color: var(--primary-700);
  font-weight: 600;
}
.nav-item svg { flex-shrink: 0; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 4px;
  border-radius: var(--radius-md);
  background: var(--gray-100);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.avatar--sm {
  width: 24px; height: 24px;
  font-size: 11px;
  border-radius: 6px;
}

/* ── Content Area ── */
.content {
  flex: 1;
  padding: 20px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ── Pages ── */
.page { display: none; }
.page.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===================================================
   BUTTONS
   =================================================== */
.btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  gap: 6px;
  padding: 0 16px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary-600);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-700); }
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-outline:hover { background: var(--gray-100); }
.btn-ghost {
  background: var(--gray-100);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--gray-200);
  color: var(--text-primary);
}
.btn-danger {
  background: var(--red-600);
  color: #fff;
}
.btn-danger:hover { background: var(--red-700); }
.btn-sm  { height: 32px; padding: 0 12px; font-size: 12px; }
.btn-xs  { height: 26px; padding: 0 8px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg  { height: 42px; padding: 0 20px; font-size: 14px; }
.btn-block { width: 100%; }

/* ===================================================
   CARDS  (no overflow: hidden)
   =================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 0;
}
.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-primary);
}
.card-header h3 svg { color: var(--text-tertiary); }
.card-subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.4;
}
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.card-body {
  padding: 16px 20px 20px;
}
.card-body.no-padding {
  padding: 12px 0 0;
}

/* ===================================================
   STATUS HERO BANNER
   =================================================== */
.status-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid;
}
.status-hero--success {
  background: var(--green-50);
  border-color: var(--green-100);
  color: var(--green-700);
}
.status-hero--warning {
  background: var(--amber-50);
  border-color: var(--amber-100);
  color: var(--amber-700);
}
.status-hero--danger {
  background: var(--red-50);
  border-color: var(--red-100);
  color: var(--red-700);
}
.status-hero-icon {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.7);
}
.status-hero-body {
  flex: 1;
  min-width: 0;
}
.status-hero-body strong {
  display: block;
  font-size: 14px;
}
.status-hero-body span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  opacity: 0.85;
}

/* ===================================================
   STATS ROW
   =================================================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.stats-row--compact {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}
.stat-card {
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.stat-card--mini { padding: 14px 16px; }
.stat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
}
.stat-icon--blue  { background: var(--primary-50); color: var(--primary-600); }
.stat-icon--red   { background: var(--red-50); color: var(--red-600); }
.stat-icon--amber { background: var(--amber-50); color: var(--amber-600); }
.stat-icon--green { background: var(--green-50); color: var(--green-600); }
.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: 8px;
  line-height: 1;
}
.stat-value-button {
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
}
.stat-value-button:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.stat-value-button:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 4px;
  border-radius: 8px;
}
.stat-value--danger  { color: var(--red-600); }
.stat-value--warning { color: var(--amber-600); }
.stat-value--small   { font-size: 20px; }
.stat-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ===================================================
   OVERVIEW COLUMNS
   =================================================== */
.overview-columns {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
  gap: 16px;
}
@media (max-width: 1100px) {
  .overview-columns { grid-template-columns: 1fr; }
}

/* ===================================================
   ALERT LIST
   =================================================== */
.alert-list {
  display: flex;
  flex-direction: column;
}
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.alert-item:last-child { border-bottom: none; }
.alert-item:hover { background: var(--gray-50); }
.alert-item--critical { }
.alert-item--warning { }
.alert-severity {
  flex-shrink: 0;
  padding-top: 4px;
}
.severity-dot {
  display: block;
  width: 8px; height: 8px;
  border-radius: 50%;
}
.severity-dot--critical {
  background: var(--red-500);
  box-shadow: 0 0 0 3px var(--red-100);
}
.severity-dot--warning {
  background: var(--amber-500);
  box-shadow: 0 0 0 3px var(--amber-100);
}
.severity-dot--success {
  background: var(--green-500);
  box-shadow: 0 0 0 3px var(--green-100);
}
.alert-body { flex: 1; min-width: 0; }
.alert-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.alert-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-tertiary);
}
.alert-time {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-tertiary);
  padding-top: 2px;
}

/* ===================================================
   BADGES & TAGS
   =================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge--sm { height: 18px; padding: 0 6px; font-size: 10px; }
.badge--success {
  background: var(--green-50);
  color: var(--green-700);
}
.badge--warning {
  background: var(--amber-50);
  color: var(--amber-700);
}
.badge--danger {
  background: var(--red-50);
  color: var(--red-700);
}
.badge--muted {
  background: var(--gray-100);
  color: var(--gray-500);
}
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.tag--sm { height: 20px; padding: 0 6px; font-size: 10px; }
.tag--blue {
  background: var(--primary-50);
  color: var(--primary-700);
}
.tag--red {
  background: var(--red-50);
  color: var(--red-700);
}
.tag--amber {
  background: var(--amber-50);
  color: var(--amber-700);
}
.tag--muted {
  background: var(--gray-100);
  color: var(--gray-500);
}

/* ===================================================
   DATA TABLES
   =================================================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th,
.data-table td {
  padding: 10px 20px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table th {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--gray-50);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.data-table td strong {
  font-weight: 600;
  color: var(--text-primary);
}
.data-table--hoverable tbody tr {
  transition: background 0.1s;
}
.data-table--hoverable tbody tr:hover {
  background: var(--gray-50);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.row--critical {
  background: var(--red-50) !important;
}
.row--critical:hover {
  background: #fde8e8 !important;
}
.row--warning {
  background: var(--amber-50) !important;
}
.domain-cell strong { display: block; }
.domain-cell small {
  display: block;
  margin-top: 2px;
  color: var(--text-tertiary);
  font-size: 11px;
}
.domain-cell {
  max-width: 260px;
}
.domain-cell strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.action-group {
  display: flex;
  gap: 4px;
}

/* ===================================================
   BREADCRUMB & PAGE TOOLBAR
   =================================================== */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb-item {
  font-size: 14px;
  color: var(--text-tertiary);
  font-weight: 500;
}
.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 700;
}
.breadcrumb-sep {
  color: var(--text-tertiary);
  font-size: 12px;
}
.toolbar-actions {
  display: flex;
  gap: 8px;
}
.toolbar-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ===================================================
   GROUPS PAGE LAYOUT
   =================================================== */
.groups-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
}
@media (max-width: 900px) {
  .groups-layout { grid-template-columns: 1fr; }
}
.groups-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 72px;
  align-self: start;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
}
.search-box {
  position: relative;
}
.search-box svg {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary);
}
.search-box input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.search-box input:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.search-box input::placeholder { color: var(--text-tertiary); }
.group-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px;
  box-shadow: var(--shadow-sm);
}
.group-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.12s;
}
.group-nav-item:hover { background: var(--gray-50); }
.group-nav-item.active {
  background: var(--primary-50);
}
.group-nav-main {
  min-width: 0;
}
.group-nav-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-nav-item.active .group-nav-name { color: var(--primary-700); }
.group-nav-count {
  display: block;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 1px;
}
.groups-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
}
.groups-main .card-body.no-padding {
  overflow-x: auto;
}

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.info-block {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--gray-50);
}
.info-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.info-value { margin-top: 6px; }

/* Download Platform */
.download-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.download-platform {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.platform-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
}
.platform-header strong {
  font-size: 14px;
  margin-right: 8px;
}
.platform-icon {
  display: flex;
  align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--gray-200);
  color: var(--text-secondary);
}
.platform-details {
  padding: 12px 16px;
}
.detail-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  font-size: 12px;
}
.detail-row + .detail-row { border-top: 1px solid var(--gray-100); }
.detail-label {
  flex-shrink: 0;
  width: 70px;
  color: var(--text-tertiary);
  font-weight: 600;
}
.detail-value {
  flex: 1;
  min-width: 0;
  color: var(--text-secondary);
}

/* Table Filter */
.table-filter {
  display: flex;
  gap: 2px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  padding: 3px;
}
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.12s;
}
.filter-btn:hover { color: var(--text-primary); }
.filter-btn.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.filter-btn .count {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.6;
}
.filter-btn .count.danger { color: var(--red-600); opacity: 1; }
.filter-btn .count.warning { color: var(--amber-600); opacity: 1; }

/* ===================================================
   TEMPLATES
   =================================================== */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
  gap: 16px;
}
@media (max-width: 960px) {
  .templates-grid { grid-template-columns: 1fr; }
}
.template-editor {
  width: 100%;
  min-height: 160px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.template-editor:focus {
  outline: none;
  border-color: var(--primary-400);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
  background: #fff;
}
.template-vars {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.template-var {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.template-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

/* ===================================================
   TASKS PAGE
   =================================================== */
.tasks-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Running task */
.running-task {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.running-task-info strong { font-size: 14px; }
.running-task-info span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}
.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--gray-200);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-400), var(--primary-600));
  transition: width 0.4s ease;
}
.running-task-stats {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}
.pulse-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green-500);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===================================================
   ACCOUNTS PAGE
   =================================================== */
.accounts-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===================================================
   TOAST
   =================================================== */
.toast {
  position: fixed;
  right: 20px; bottom: 20px;
  min-width: 200px;
  max-width: 400px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--gray-900);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

/* ===================================================
   MODAL
   =================================================== */
/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.45);
}

/* ── Modal card (matches .modal in HTML) ── */
.modal-overlay > .modal {
  width: 100%;
  max-width: 520px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  animation: fadeIn 0.2s ease;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-tertiary);
  font-size: 22px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
}

.modal-body .field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}
.modal-body .field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.modal-body .field .required {
  color: var(--red-500);
}
.modal-body .field input[type="text"],
.modal-body .field input[type="password"],
.modal-body .field textarea {
  width: 100%;
  padding: 0 12px;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  color: var(--text-primary);
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.modal-body .field textarea {
  height: auto;
  min-height: 100px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}
.modal-body .field input:focus,
.modal-body .field textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
  background: #fff;
}
.modal-body .field input::placeholder,
.modal-body .field textarea::placeholder {
  color: var(--text-tertiary);
}

/* Inline checkbox field */
.modal-body .field--inline {
  margin-bottom: 14px;
}
.modal-body .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.modal-body .checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary-600);
  cursor: pointer;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
}

/* ===================================================
   EMPTY STATE
   =================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-tertiary);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
}
.empty-state svg {
  margin-bottom: 12px;
  color: var(--gray-300);
}
.empty-state strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===================================================
   UTILITIES
   =================================================== */
.text-muted    { color: var(--text-tertiary); }
.text-sm       { font-size: 12px; }
.text-danger   { color: var(--red-600) !important; }
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===================================================
   Supplemental styles — dynamic classes from app.js
   =================================================== */

/* ── Status banner (overview) ── */
.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  gap: 16px;
}
.status-banner strong {
  font-size: 15px;
}
.status-banner-message {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: 0.85;
}
.status-success {
  background: var(--green-50);
  border: 1px solid var(--green-500);
  color: var(--green-700);
}
.status-danger {
  background: var(--red-50);
  border: 1px solid var(--red-500);
  color: var(--red-700);
}
.status-warning {
  background: var(--amber-50);
  border: 1px solid var(--amber-500);
  color: var(--amber-700);
}

/* ── Stat card tones ── */
.stat-note {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-tertiary);
}
.tone-critical .stat-value { color: var(--red-600); }
.tone-warning  .stat-value { color: var(--amber-600); }
.tone-normal   .stat-value { color: var(--green-600); }

/* ── Badge neutral ── */
.badge--neutral {
  background: var(--gray-100);
  color: var(--gray-600);
}

/* ── Alert queue rank ── */
.alert-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--red-100);
  color: var(--red-600);
}

/* ── Group nav meta ── */
.group-nav-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ── Group detail info ── */
.group-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.drilldown-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.drilldown-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.group-info-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.info-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  background: var(--gray-50);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
}
.info-pill strong {
  font-weight: 600;
  color: var(--text-primary);
}

/* ── Download grid ── */
.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 12px;
}
.download-cell {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--gray-50);
}
.download-cell dt {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}
.download-cell dd {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-all;
}

/* ── Template card ── */
.template-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}
.template-card h4 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.template-card .template-key {
  font-size: 12px;
  color: var(--primary-600);
  font-family: monospace;
}
.template-card .template-desc {
  margin: 6px 0 12px;
  font-size: 13px;
  color: var(--text-tertiary);
}
.template-card textarea {
  width: 100%;
  min-height: 140px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--gray-50);
  color: var(--text-primary);
  font-size: 13px;
  font-family: monospace;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
}
.template-card textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
  background: #fff;
}
.template-card .template-vars {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.template-card .template-vars .badge {
  font-family: monospace;
  font-size: 11px;
}
.template-card .template-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

/* ── Task items ── */
.task-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child {
  border-bottom: none;
}
.task-item-detail {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

/* ── Severity row highlights ── */
.severity-critical {
  background: var(--red-50) !important;
}
.severity-warning {
  background: var(--amber-50) !important;
}
.severity-muted {
  opacity: 0.5;
}

/* ── Nested table in overview ── */
.data-table--nested {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table--nested th,
.data-table--nested td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table--nested th {
  font-weight: 600;
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ── Expanded overview row ── */
.expanded-row td {
  padding: 0 !important;
  background: var(--gray-50);
}

/* ── Button group ── */
.btn-group {
  display: inline-flex;
  gap: 4px;
}

/* ── Force notify label (topbar) ── */
.force-notify-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.force-notify-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--primary-600);
  cursor: pointer;
}

/* ── Templates grid layout ── */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 16px;
}
