@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Plus Jakarta Sans', var(--font-sans);
  --font-mono: 'JetBrains Mono', monospace;

  /* Palette */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Emerald Security Primary */
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --primary-200: #a7f3d0;
  --primary-500: #10b981;
  --primary-600: #059669;
  --primary-700: #047857;
  --primary-800: #065f46;

  /* Semantics */
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --border: #e2e8f0;
  --border-focus: #10b981;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  --sidebar-bg: #090e17;
  --sidebar-border: #172033;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #131c2e;
  --sidebar-active: #1e293b;
  --sidebar-active-text: #f8fafc;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.06);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

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

body {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }

p.sub, p.muted {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-600);
  margin-bottom: 4px;
}

/* Base Shells & Layouts */
[hidden], .admin-shell[hidden], section[hidden], div[hidden], aside[hidden], main[hidden], span[hidden] {
  display: none !important;
}

.shell, .admin-shell {
  display: flex;
  min-height: 100vh;
  background-color: var(--bg);
}

/* Sidebar Navigation */
.admin-nav, aside {
  width: 260px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 20;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  text-decoration: none;
  padding: 4px 10px 24px;
  letter-spacing: -0.01em;
}

.brand span, .brand .brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  color: #fff;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.console-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  margin: 18px 10px 8px;
}

.admin-nav button, aside nav button, .bottom button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  color: #94a3b8;
  border: 0;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.admin-nav button:hover, aside nav button:hover, .bottom button:hover {
  background-color: var(--sidebar-hover);
  color: #f1f5f9;
}

.admin-nav button.active, aside nav button.active {
  background-color: var(--sidebar-active);
  color: #ffffff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary-500);
}

.nav-foot, .bottom {
  margin-top: auto;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 16px;
}

.nav-foot span, #who {
  display: block;
  color: #f1f5f9;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  padding: 0 10px;
}

.nav-foot button, .bottom .link-button {
  width: 100%;
  background: transparent;
  color: #64748b;
  border: 0;
  padding: 6px 10px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.nav-foot button:hover {
  color: #ef4444;
}

/* Main Content Area */
.admin-main, main {
  margin-left: 260px;
  width: calc(100% - 260px);
  padding: 36px 40px 60px;
  max-width: 1440px;
}

.portal {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px;
  margin-left: auto;
  width: 100%;
}

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

.admin-main header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.admin-main header h1 {
  margin-top: 4px;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--primary-50);
  border: 1px solid var(--primary-200);
  color: var(--primary-700);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 9999px;
}

.live i, .side-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--primary-500);
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Metric Cards */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric, .card, .panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.metric {
  padding: 20px 22px;
}

.metric span {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.metric strong {
  display: block;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  margin: 8px 0 2px;
}

.metric p {
  color: var(--text-muted);
  font-size: 13px;
}

/* Panels and Cards */
.panel, .card {
  padding: 24px;
  margin-bottom: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--slate-100);
}

.panel-head h2, .panel h2 {
  font-size: 18px;
  font-weight: 700;
}

.panel-head p, .panel p.sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-top: 2px;
}

.two-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* Hero Section */
.hero {
  padding: 28px 32px;
  margin: 24px 0;
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 50%, #e0f2fe 100%);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: var(--shadow-sm);
}

.shield {
  font-size: 32px;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: #ffffff;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.hero h2 {
  color: var(--primary-700);
  font-size: 22px;
}

.hero .last {
  margin-left: auto;
  color: var(--slate-500);
  font-size: 13px;
  font-weight: 500;
}

/* Grid Layouts */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
}

/* Rows & Activity Lists */
.app-row, .activity-row, .line, .stat, .setting {
  display: flex;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--slate-100);
  gap: 14px;
}

.app-row:last-child, .activity-row:last-child, .line:last-child, .stat:last-child, .setting:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.app-row:first-child, .activity-row:first-child, .line:first-child, .stat:first-child, .setting:first-child {
  padding-top: 0;
}

.app-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--slate-100);
  color: var(--slate-700);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid var(--slate-200);
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fef2f2;
  color: #ef4444;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: bold;
}

.activity-icon.allowed {
  background: #ecfdf5;
  color: #059669;
}

.audit {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--slate-100);
}

.audit:last-child {
  border-bottom: 0;
}

.audit b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-50);
  color: var(--primary-600);
  font-size: 12px;
  margin-top: 2px;
}

.time, .status-dot {
  font-size: 12.5px;
  color: var(--text-muted);
}

.grow {
  flex: 1;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border: 1px solid #047857;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  cursor: pointer;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: all 0.15s ease;
  text-decoration: none;
}

.button:hover {
  background: linear-gradient(180deg, #059669 0%, #047857 100%);
  box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button.secondary {
  background: #ffffff;
  color: var(--slate-700);
  border: 1px solid var(--slate-300);
  box-shadow: var(--shadow-sm);
}

.button.secondary:hover {
  background: var(--slate-50);
  border-color: var(--slate-400);
  color: var(--slate-900);
}

.button.danger {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  border-color: #b91c1c;
  color: #ffffff;
}

.button.danger:hover {
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
}

.link-button, .text-action {
  background: transparent;
  border: 0;
  color: var(--primary-600);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.link-button:hover, .text-action:hover {
  color: var(--primary-700);
  background-color: var(--primary-50);
}

/* Status Pills & Tags */
.pill, .tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.pill.active, .pill.protected, .pill.enabled, .pill.owner, .pill.guardian, .pill.trialing, .pill.connected, .pill.configured, .pill.secured, .pill.standalone-bus, .pill.subscription-activated, .pill.subscription-updated, .tag.allowed {
  background-color: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.pill.past-due, .pill.paused, .pill.off, .pill.configure, .pill.not-set, .pill.subscription-past-due, .tag.waiting {
  background-color: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.pill.canceled, .pill.no-plan, .pill.subscription-canceled, .tag.blocked, .tag {
  background-color: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

/* Data Tables */
.data-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background: var(--slate-50);
  color: var(--slate-600);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--slate-100);
  font-size: 13.5px;
  color: var(--slate-800);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tr:hover td {
  background-color: #f8fafc;
}

.data-table code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--slate-100);
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
}

.data-table small, .line small, .audit small {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

/* Search and Universal Inputs */
input:not([type=checkbox]):not([type=radio]):not([type=button]):not([type=submit]),
select,
textarea,
.search {
  width: 100% !important;
  box-sizing: border-box !important;
  display: block;
  border: 1px solid var(--slate-300);
  background-color: #ffffff;
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search {
  max-width: 260px !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
}

input:not([type=checkbox]):not([type=radio]):not([type=button]):not([type=submit]):focus,
select:focus,
textarea:focus,
.search:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

input::placeholder, textarea::placeholder {
  color: var(--slate-400);
}

/* Social Login Buttons */
.social-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100% !important;
  box-sizing: border-box;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  transition: all 0.15s ease;
}

.social-btn:hover {
  background: var(--slate-50);
  border-color: var(--slate-400);
  box-shadow: var(--shadow-sm);
}

.social-btn svg {
  flex-shrink: 0;
}

.social-btn.github-btn {
  background: #1e293b;
  color: #ffffff;
  border-color: #334155;
}

.social-btn.github-btn:hover {
  background: #0f172a;
  border-color: #1e293b;
}

.divider {
  display: flex;
  align-items: center;
  margin: 18px 0;
  color: var(--slate-400);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--slate-200);
}

.divider span {
  padding: 0 12px;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--slate-200);
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-500);
  cursor: pointer;
  text-align: center;
}

.auth-tab.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-600);
}

/* Form Groups inside Modals & Cards */
.form-group {
  margin-top: 16px;
}

.form-group:first-child {
  margin-top: 0;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-3-1 {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 12px;
}

label, .form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--slate-500);
  margin-top: 4px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-2xl);
  animation: scaleUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--slate-100);
}

.modal-header h2, .modal-box h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--slate-900);
}

.modal-header p, .modal-box p.muted {
  font-size: 13.5px;
  color: var(--slate-500);
  margin-top: 2px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--slate-100);
}

/* Authentication / Sign In Card */
.login {
  max-width: 440px;
  margin: 10vh auto;
}

.login .card {
  padding: 36px 32px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-xl);
}

.login h1 {
  font-size: 24px;
  margin: 6px 0 6px;
}

.login .button {
  margin-top: 24px;
  width: 100%;
  padding: 12px;
  font-size: 14px;
}

/* Choice selector */
.choice {
  display: flex;
  align-items: center;
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--slate-200);
  padding: 14px 16px;
  margin-top: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: all 0.15s ease;
}

.choice:hover {
  background: var(--slate-50);
  border-color: var(--slate-300);
}

.choice.selected {
  border: 2px solid var(--primary-500);
  background: var(--primary-50);
  color: var(--primary-800);
  font-weight: 600;
}

.choice input {
  accent-color: var(--primary-600);
  margin-right: 12px;
}

/* Toggle Switch */
.toggle {
  width: 44px;
  height: 24px;
  border-radius: 9999px;
  background-color: var(--slate-300);
  border: 0;
  padding: 2px;
  cursor: pointer;
  position: relative;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.toggle::after {
  content: '';
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.toggle.on {
  background-color: var(--primary-600);
}

.toggle.on::after {
  transform: translateX(20px);
}

/* Toast */
#toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background-color: var(--slate-900);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-xl);
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 1000;
  border: 1px solid var(--slate-700);
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--slate-400);
  font-size: 13.5px;
}

.loading {
  padding: 30px;
  text-align: center;
  color: var(--slate-500);
  font-weight: 500;
}

.status-list {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.status-list div {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.status-list strong {
  font-size: 18px;
  font-family: var(--font-display);
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .metric-grid, .two-panels {
    grid-template-columns: 1fr;
  }
  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .admin-nav, aside {
    width: 64px;
    padding: 16px 8px;
  }
  .admin-nav .brand {
    font-size: 0;
    padding: 0 4px 20px;
    justify-content: center;
  }
  .admin-nav button, aside nav button, .bottom button {
    justify-content: center;
    padding: 10px 0;
    font-size: 0;
  }
  .admin-nav button span, aside nav button span, .console-label, .nav-foot, .side-status {
    display: none;
  }
  .admin-main, main {
    margin-left: 64px;
    width: calc(100% - 64px);
    padding: 24px 16px;
  }
}

/* ==========================================================
   Shimmer Skeleton Loaders
   ========================================================== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 37%, #f1f5f9 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-title {
  height: 22px;
  width: 60%;
  margin-bottom: 12px;
  border-radius: 6px;
}

.skeleton-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skeleton-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-table {
  width: 100%;
  border-collapse: collapse;
}

.skeleton-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid #f1f5f9;
}

/* ==========================================================
   SweetAlert2 Custom Enterprise Theme
   ========================================================== */
div:where(.swal2-container) .swal2-popup {
  font-family: var(--font-sans) !important;
  border-radius: 16px !important;
  padding: 24px 28px !important;
  box-shadow: 0 20px 30px -10px rgba(15, 23, 42, 0.18), 0 10px 15px -3px rgba(15, 23, 42, 0.08) !important;
  border: 1px solid #e2e8f0 !important;
  background: #ffffff !important;
}

div:where(.swal2-container) .swal2-title {
  font-family: var(--font-display) !important;
  font-size: 20px !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  letter-spacing: -0.02em !important;
}

div:where(.swal2-container) .swal2-html-container {
  color: #475569 !important;
  font-size: 14px !important;
  line-height: 1.55 !important;
}

div:where(.swal2-container) button.swal2-styled.swal2-confirm {
  background: linear-gradient(135deg, #059669, #047857) !important;
  color: #ffffff !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  padding: 10px 22px !important;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25) !important;
}

div:where(.swal2-container) button.swal2-styled.swal2-cancel {
  background: #f1f5f9 !important;
  color: #475569 !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  padding: 10px 20px !important;
  border: 1px solid #cbd5e1 !important;
}

div:where(.swal2-container) button.swal2-styled.swal2-deny {
  background: #ef4444 !important;
  color: #ffffff !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  font-size: 14px !important;
}

div:where(.swal2-container).swal2-toast-shown .swal2-popup.swal2-toast {
  padding: 12px 18px !important;
  border-radius: 12px !important;
  background: #0f172a !important;
  color: #ffffff !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3) !important;
  border: 1px solid #1e293b !important;
}

div:where(.swal2-container).swal2-toast-shown .swal2-popup.swal2-toast .swal2-title {
  color: #f8fafc !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
}

div:where(.swal2-container).swal2-toast-shown .swal2-popup.swal2-toast .swal2-html-container {
  color: #cbd5e1 !important;
  font-size: 12.5px !important;
}



/* ==========================================================
   Instant Authenticated State (Zero FOUC Login Flash)
   ========================================================== */
.has-admin-token #login, 
.has-portal-token #login, 
.has-guardian-token #login {
  display: none !important;
}
.has-admin-token #console {
  display: flex !important;
}
.has-portal-token #dashboard, 
.has-guardian-token #dashboard {
  display: block !important;
}

/* ==========================================================
   Admin Smooth Scrollbar & Collapse Transition
   ========================================================== */
.admin-nav {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scroll-behavior: smooth !important;
  scrollbar-width: thin !important;
  scrollbar-color: #334155 transparent !important;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1), padding 0.22s ease !important;
}

.admin-nav::-webkit-scrollbar {
  width: 5px !important;
}

.admin-nav::-webkit-scrollbar-track {
  background: transparent !important;
}

.admin-nav::-webkit-scrollbar-thumb {
  background-color: #334155 !important;
  border-radius: 9999px !important;
}

.admin-nav::-webkit-scrollbar-thumb:hover {
  background-color: #475569 !important;
}

.admin-main {
  transition: margin-left 0.22s cubic-bezier(0.4, 0, 0.2, 1), width 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Sidebar Collapsed State */
.admin-shell.sidebar-collapsed .admin-nav {
  width: 70px !important;
  padding: 20px 8px !important;
}

.admin-shell.sidebar-collapsed .admin-main {
  margin-left: 70px !important;
  width: calc(100% - 70px) !important;
}

.admin-shell.sidebar-collapsed .admin-nav .brand img {
  height: 28px !important;
  max-width: 48px !important;
  object-fit: contain !important;
}

.admin-shell.sidebar-collapsed .console-label {
  display: none !important;
}

.admin-shell.sidebar-collapsed .admin-nav button {
  justify-content: center !important;
  padding: 10px 0 !important;
}

.admin-shell.sidebar-collapsed .admin-nav button span:nth-child(2),
.admin-shell.sidebar-collapsed .admin-nav button .btn-label {
  display: none !important;
}

.admin-shell.sidebar-collapsed .nav-foot span#who {
  display: none !important;
}

.admin-shell.sidebar-collapsed .nav-foot {
  padding-top: 12px !important;
}

.admin-shell.sidebar-collapsed .nav-foot button {
  font-size: 0 !important;
  padding: 8px 0 !important;
}

.admin-shell.sidebar-collapsed .nav-foot button::before {
  content: "🚪";
  font-size: 14px;
}

.sidebar-toggle-btn {
  background: #131c2e;
  color: #94a3b8;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 14px;
  transition: all 0.15s ease;
}

.sidebar-toggle-btn:hover {
  background: #1e293b;
  color: #ffffff;
  border-color: #334155;
}

/* Email Templates Gallery & Live Preview */
.template-item {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: 8px;
}

.template-item:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.template-item.active {
  border-color: #10b981;
  background: #ecfdf5;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.12);
}

.preview-iframe {
  width: 100%;
  height: 620px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
}


/* -------------------------------------------------------------
   UNIFIED ENTERPRISE SITE HEADER & FOOTER
------------------------------------------------------------- */
.site-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
}
.site-header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.site-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}
.site-logo-img {
  height: 34px;
  width: auto;
  object-fit: contain;
  display: block;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}
.site-nav a {
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  color: #475569;
  transition: color 0.15s ease;
}
.site-nav a:hover {
  color: #059669;
}
.site-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.site-header-actions .button {
  padding: 8px 18px;
  font-size: 13.5px;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
}

/* Site Footer */
.site-footer {
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 60px 24px 32px;
  color: #64748b;
  font-size: 13.5px;
  margin-top: auto;
}
.site-footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 48px;
}
.site-footer-col h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0f172a;
  margin: 0 0 16px;
}
.site-footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.site-footer-col li {
  margin-bottom: 10px;
}
.site-footer-col a {
  color: #64748b;
  text-decoration: none;
  transition: color 0.15s;
}
.site-footer-col a:hover {
  color: #059669;
}
.site-footer-bottom {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  border-top: 1px solid #f1f5f9;
  padding-top: 24px;
  font-size: 13px;
  color: #94a3b8;
}
.site-footer-bottom a {
  color: #64748b;
  text-decoration: none;
}
.site-footer-bottom a:hover {
  color: #059669;
}

/* Rich Text Article Content Typography */
.article-content {
  font-size: 17px;
  color: #334155;
  line-height: 1.85;
}
.article-content h1, .article-content h2, .article-content h3, .article-content h4 {
  color: #0f172a;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 36px 0 16px;
  line-height: 1.3;
}
.article-content h1 { font-size: 28px; }
.article-content h2 { font-size: 24px; border-bottom: 1px solid #f1f5f9; padding-bottom: 8px; }
.article-content h3 { font-size: 20px; }
.article-content p { margin-bottom: 22px; }
.article-content ul, .article-content ol { margin: 0 0 24px 28px; padding: 0; }
.article-content li { margin-bottom: 8px; }
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(15,23,42,0.08);
  margin: 24px 0;
  display: block;
}
.article-content blockquote {
  border-left: 4px solid #059669;
  background: #f8fafc;
  padding: 16px 22px;
  border-radius: 0 10px 10px 0;
  margin: 28px 0;
  font-style: italic;
  color: #1e293b;
}
.article-content pre {
  background: #0f172a;
  color: #f8fafc;
  padding: 18px;
  border-radius: 10px;
  overflow-x: auto;
  font-family: JetBrains Mono, monospace;
  font-size: 14px;
  margin: 24px 0;
}
.article-content code {
  background: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: JetBrains Mono, monospace;
  font-size: 14px;
}
.article-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
}
.article-content th, .article-content td {
  border: 1px solid #e2e8f0;
  padding: 10px 14px;
  text-align: left;
}
.article-content th {
  background: #f8fafc;
  font-weight: 700;
  color: #0f172a;
}

@media (max-width: 860px) {
  .site-nav { display: none; }
  .site-footer-inner { grid-template-columns: 1fr 1fr; gap: 30px; }
}
@media (max-width: 540px) {
  .site-footer-inner { grid-template-columns: 1fr; }
}


/* -------------------------------------------------------------
   ADMIN AUTHENTICATION SHELL & CONSOLE MUTUAL EXCLUSION
------------------------------------------------------------- */
html.has-admin-token #login {
  display: none !important;
}
html.has-admin-token #console {
  display: flex !important;
}
html:not(.has-admin-token) #login {
  display: flex !important;
}
html:not(.has-admin-token) #console {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 20%, #f0fdf4 0%, #f8fafc 100%);
  width: 100%;
}

.login .card {
  max-width: 440px;
  width: 100%;
  padding: 36px;
  box-shadow: 0 20px 25px -5px rgba(15,23,42,0.1), 0 8px 10px -6px rgba(15,23,42,0.04);
  border-radius: 16px;
  background: #ffffff;
}

/* Admin Mobile Layout & Drawer */
.admin-mobile-topbar {
  display: none;
}
.sidebar-backdrop {
  display: none;
}

@media (max-width: 860px) {
  .admin-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }
  .admin-mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: #090e17;
    border-bottom: 1px solid #172033;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  .admin-nav {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: -300px !important;
    width: 280px !important;
    z-index: 1001 !important;
    height: 100vh !important;
    overflow-y: auto !important;
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.6) !important;
  }
  .admin-nav.mobile-open {
    left: 0 !important;
  }
  .sidebar-backdrop.active {
    display: block !important;
    position: fixed !important;
    inset: 0 !important;
    background: rgba(15, 23, 42, 0.65) !important;
    z-index: 1000 !important;
    backdrop-filter: blur(3px) !important;
  }
  .admin-main {
    margin-left: 0 !important;
    padding: 16px !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .admin-main header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding-bottom: 16px !important;
  }
  .metric-grid, .two-panels, .grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .panel {
    padding: 16px !important;
  }
  .panel-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
  .modal-box {
    width: 96vw !important;
    max-width: 96vw !important;
    padding: 16px !important;
    margin: 10px auto !important;
  }
  .form-row-2, .form-row-3-1 {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
}

/* Site Mobile Header & Drawer */
.site-mobile-toggle {
  display: none;
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 20px;
  color: #0f172a;
  cursor: pointer;
}
.site-mobile-drawer {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 10px 25px -5px rgba(15,23,42,0.1);
  padding: 20px 24px;
  flex-direction: column;
  gap: 14px;
  z-index: 99;
}
.site-mobile-drawer.open {
  display: flex !important;
}
.site-mobile-drawer a {
  font-size: 15px;
  font-weight: 600;
  color: #334155;
  text-decoration: none;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}
.site-mobile-drawer a:hover {
  color: #059669;
}

@media (max-width: 860px) {
  .site-nav {
    display: none !important;
  }
  .site-header-actions {
    display: none !important;
  }
  .site-mobile-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
  .site-header-inner {
    padding: 12px 18px !important;
  }
}
