/* ==========================================================================
   CF Manager Pro — design system
   Hand-written so the app has no CDN dependency and no build step.
   Light theme is the default; [data-theme="dark"] on <html> flips the tokens.
   ========================================================================== */

/* ---------------------------------------------------------------- 1. tokens */

:root {
  /* Brand */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-300: #93c5fd;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-800: #1e40af;

  /* Surfaces */
  --bg:          #f7f9fc;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --surface-3:   #f1f5f9;
  --border:      #e6ebf2;
  --border-soft: #eef2f7;

  /* Text */
  --text:        #0f172a;
  --text-muted:  #64748b;
  --text-subtle: #94a3b8;

  /* Status */
  --success:     #10b981;
  --success-bg:  #ecfdf5;
  --success-text:#047857;
  --warning:     #f59e0b;
  --warning-bg:  #fffbeb;
  --warning-text:#b45309;
  --danger:      #ef4444;
  --danger-bg:   #fef2f2;
  --danger-text: #b91c1c;
  --info:        #0ea5e9;
  --info-bg:     #f0f9ff;
  --info-text:   #0369a1;

  /* Shape + depth */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow:    0 4px 14px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, .11), 0 4px 10px rgba(15, 23, 42, .05);
  --shadow-xl: 0 28px 60px rgba(15, 23, 42, .16);

  /* Rhythm */
  --gap:      16px;
  --sidebar-w: 264px;
  --header-h:  68px;
  --maxw:      1200px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg:          #0b1220;
  --surface:     #111a2b;
  --surface-2:   #162033;
  --surface-3:   #1c2740;
  --border:      #243049;
  --border-soft: #1b2438;

  --text:        #e8edf7;
  --text-muted:  #93a3bd;
  --text-subtle: #6b7c99;

  --success-bg:  rgba(16, 185, 129, .12);
  --success-text:#34d399;
  --warning-bg:  rgba(245, 158, 11, .12);
  --warning-text:#fbbf24;
  --danger-bg:   rgba(239, 68, 68, .12);
  --danger-text: #f87171;
  --info-bg:     rgba(14, 165, 233, .12);
  --info-text:   #38bdf8;
  --brand-50:    rgba(37, 99, 235, .14);
  --brand-100:   rgba(37, 99, 235, .2);
  --brand-200:   rgba(37, 99, 235, .3);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
  --shadow:    0 4px 14px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .45);
  --shadow-xl: 0 28px 60px rgba(0, 0, 0, .55);
}

/* ----------------------------------------------------------------- 2. base */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { margin: 0 0 .5em; line-height: 1.25; font-weight: 800; letter-spacing: -.02em; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.75rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.9rem); }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

code, .mono { font-family: var(--mono); font-size: .875em; }

:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------- 3. icons */

.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }
.icon--xl { width: 32px; height: 32px; }

/* ------------------------------------------------------------------ 4. layout */

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.container--narrow { max-width: 780px; }
.container--tight { max-width: 480px; }

.section { padding: 72px 0; }
.section--tight { padding: 44px 0; }
.section--alt { background: var(--surface); }

.grid { display: grid; gap: var(--gap); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: 2fr 1fr; }

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack--sm { gap: 10px; }
.stack--lg { gap: 24px; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--top { align-items: flex-start; }

.spacer { flex: 1 1 auto; }

/* --------------------------------------------------------------- 5. utilities */

.muted  { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small  { font-size: .8125rem; }
.tiny   { font-size: .75rem; }
.bold   { font-weight: 700; }
.center { text-align: center; }
.right  { text-align: right; }
.nowrap { white-space: nowrap; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break { word-break: break-all; }
.mono { font-family: var(--mono); font-size: .8125rem; letter-spacing: -.01em; }
.mono-sm { font-family: var(--mono); font-size: .75rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 36px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 36px; }

.hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------- 6. cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.card__title { margin: 0; font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.card__title .icon { color: var(--brand-600); }
.card__body { padding: 22px; }
.card__body--flush { padding: 0; }
.card__foot {
  padding: 16px 22px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.card--accent { border-color: var(--brand-200); box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- 7. buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text);
  font-family: inherit; font-size: .875rem; font-weight: 650; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .1s ease;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--brand-600); color: #fff; box-shadow: 0 2px 8px rgba(37, 99, 235, .28); }
.btn--primary:hover { background: var(--brand-700); }

.btn--secondary { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { background: var(--surface-2); border-color: var(--brand-300); color: var(--brand-700); }

.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.94); }

.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { filter: brightness(.94); }

.btn--soft-danger { background: var(--danger-bg); color: var(--danger-text); }
.btn--soft-danger:hover { background: var(--danger); color: #fff; }

.btn--sm { padding: 7px 12px; font-size: .8125rem; border-radius: var(--radius-sm); }
.btn--lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn--block { width: 100%; }

.btn--icon { padding: 8px; border-radius: var(--radius-sm); width: 36px; height: 36px; }
.btn--icon.btn--sm { width: 30px; height: 30px; padding: 6px; }

/* ------------------------------------------------------------------ 8. forms */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.field__label { font-size: .8125rem; font-weight: 700; color: var(--text); }
.field__label .req { color: var(--danger); }
.field__help { font-size: .75rem; color: var(--text-subtle); }
.field__error { font-size: .75rem; color: var(--danger-text); font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit; font-size: .9375rem; line-height: 1.4;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px var(--brand-50);
}

.input--error, .select--error { border-color: var(--danger); }
.input--error:focus { box-shadow: 0 0 0 4px var(--danger-bg); }

.input--mono { font-family: var(--mono); font-size: .875rem; }
.textarea { min-height: 120px; resize: vertical; }
.textarea--tall { min-height: 260px; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }

.checkline { display: flex; align-items: flex-start; gap: 10px; font-size: .875rem; }
.checkline input[type="checkbox"] { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--brand-600); flex: 0 0 auto; }

/* A switch-style toggle used across the settings pages. */
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: relative; width: 44px; height: 25px; flex: 0 0 auto;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 999px; transition: background .18s ease, border-color .18s ease;
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform .18s ease;
}
.switch input:checked + .switch__track { background: var(--brand-600); border-color: var(--brand-600); }
.switch input:checked + .switch__track::after { transform: translateX(19px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.switch__text { display: flex; flex-direction: column; }
.switch__text strong { font-size: .875rem; font-weight: 650; }
.switch__text span { font-size: .75rem; color: var(--text-subtle); }

/* ------------------------------------------------------------------ 9. badges */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .6875rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase;
  background: var(--surface-3); color: var(--text-muted);
  white-space: nowrap;
}
.badge--success { background: var(--success-bg); color: var(--success-text); }
.badge--warning { background: var(--warning-bg); color: var(--warning-text); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger-text); }
.badge--info    { background: var(--info-bg);    color: var(--info-text); }
.badge--brand   { background: var(--brand-50);   color: var(--brand-700); }
.badge--neutral { background: var(--surface-3);  color: var(--text-muted); }

.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------------ 10. alerts */

.alert {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .875rem;
  margin-bottom: 16px;
}
.alert:last-child { margin-bottom: 0; }
.alert .icon { margin-top: 1px; }
.alert--success { background: var(--success-bg); color: var(--success-text); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert--error   { background: var(--danger-bg);  color: var(--danger-text);  border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert--warning { background: var(--warning-bg); color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert--info    { background: var(--info-bg);    color: var(--info-text);    border-color: color-mix(in srgb, var(--info) 25%, transparent); }

.alert__body { flex: 1 1 auto; }
.alert__body strong { display: block; font-weight: 700; }

/* ------------------------------------------------------------------ 11. stats */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.stat__top { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }

.stat__icon {
  width: 44px; height: 44px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: var(--radius);
  background: var(--brand-50); color: var(--brand-600);
}
.stat__icon--success { background: var(--success-bg); color: var(--success-text); }
.stat__icon--warning { background: var(--warning-bg); color: var(--warning-text); }
.stat__icon--danger  { background: var(--danger-bg);  color: var(--danger-text); }
.stat__icon--info    { background: var(--info-bg);    color: var(--info-text); }

.stat__label { font-size: .6875rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--text-subtle); }
.stat__value { font-size: 1.75rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat__foot  { font-size: .75rem; color: var(--text-subtle); }

/* ------------------------------------------------------------------ 12. tables */

.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }

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

.table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: .6875rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-subtle);
  white-space: nowrap;
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .right { text-align: right; }
.table__actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ----------------------------------------------------------------- 13. app shell */

.shell { display: flex; min-height: 100vh; }

.shell__sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 40;
}

.shell__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.shell__content { padding: 24px; flex: 1 1 auto; }
.shell__content > *:last-child { margin-bottom: 0; }

/* Sidebar */

.sidebar__brand {
  display: flex; align-items: center; gap: 11px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
  min-height: var(--header-h);
}

.sidebar__brand img { width: 34px; height: 34px; border-radius: 9px; object-fit: contain; }

.sidebar__mark {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .3);
}

.sidebar__name { font-weight: 800; font-size: .9375rem; letter-spacing: -.01em; line-height: 1.2; }
.sidebar__role { font-size: .6875rem; color: var(--text-subtle); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }

.sidebar__nav { flex: 1 1 auto; overflow-y: auto; padding: 14px 12px; }

.sidebar__group {
  font-size: .625rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-subtle);
  padding: 14px 10px 6px;
}

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .875rem; font-weight: 600;
  text-decoration: none;
  margin-bottom: 2px;
  transition: background .14s ease, color .14s ease;
}
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link--active { background: var(--brand-50); color: var(--brand-700); font-weight: 700; }
[data-theme="dark"] .nav-link--active { color: var(--brand-300); }
.nav-link .icon { color: inherit; opacity: .85; }
.nav-link__count {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: .625rem; font-weight: 800;
  padding: 2px 7px; border-radius: 999px;
}

.sidebar__foot { padding: 14px 12px; border-top: 1px solid var(--border-soft); }

/* Topbar */

.topbar {
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}

.topbar__title { font-size: 1.0625rem; font-weight: 750; margin: 0; letter-spacing: -.01em; }
.topbar__sub { font-size: .75rem; color: var(--text-subtle); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.topbar__burger { display: none; }

/* Impersonation banner */

.impersonate-bar {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 9px 18px;
  background: linear-gradient(90deg, #f59e0b, #ea580c);
  color: #fff;
  font-size: .8125rem; font-weight: 650;
  text-align: center;
  flex-wrap: wrap;
}
.impersonate-bar form { margin: 0; }
.impersonate-bar .btn {
  background: rgba(255, 255, 255, .22); color: #fff;
  border: 1px solid rgba(255, 255, 255, .4);
  padding: 5px 12px; font-size: .75rem;
}
.impersonate-bar .btn:hover { background: rgba(255, 255, 255, .34); }

/* ------------------------------------------------------------------ 14. public site */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner { display: flex; align-items: center; gap: 20px; height: var(--header-h); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; }
.brand__mark {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 8px; background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
}

.site-nav { display: flex; align-items: center; gap: 4px; margin-left: 12px; }
.site-nav a {
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: .875rem; font-weight: 600;
}
.site-nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }

.site-header__actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 40px 0 28px;
  color: var(--text-muted);
  font-size: .875rem;
}
.site-footer__grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 32px; margin-bottom: 28px; }
.site-footer h4 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-subtle); margin-bottom: 12px; }
.site-footer a { color: var(--text-muted); display: block; padding: 3px 0; }
.site-footer a:hover { color: var(--brand-600); }
.site-footer__bar {
  border-top: 1px solid var(--border-soft); padding-top: 20px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: .8125rem; color: var(--text-subtle);
}

/* Hero */

.hero {
  position: relative;
  padding: 84px 0 72px;
  overflow: hidden;
  background:
    radial-gradient(900px 420px at 12% -8%, var(--brand-50), transparent 62%),
    radial-gradient(700px 380px at 96% 6%, rgba(14, 165, 233, .1), transparent 60%);
}

.hero__grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; }

.hero__eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: .75rem; font-weight: 700; color: var(--brand-700);
  box-shadow: var(--shadow-xs);
  margin-bottom: 20px;
}

.hero h1 { margin-bottom: 18px; }
.hero__lead { font-size: 1.0625rem; color: var(--text-muted); max-width: 52ch; margin-bottom: 28px; }
.hero__cta { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; }
.hero__points { display: flex; flex-wrap: wrap; gap: 18px; font-size: .8125rem; color: var(--text-muted); }
.hero__points span { display: inline-flex; align-items: center; gap: 7px; }
.hero__points .icon { color: var(--success); }

/* A mock browser/dashboard card used as hero art. */
.mock {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.mock__bar {
  display: flex; align-items: center; gap: 7px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.mock__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.mock__dot--r { background: #fca5a5; } .mock__dot--y { background: #fcd34d; } .mock__dot--g { background: #86efac; }
.mock__body { padding: 20px; }
.mock__row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  margin-bottom: 8px;
  font-size: .8125rem;
}
.mock__row:last-child { margin-bottom: 0; }
.mock__pill { margin-left: auto; font-size: .625rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; }

/* Feature cards */

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--brand-200); }
.feature__icon {
  width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: var(--radius); background: var(--brand-50); color: var(--brand-600);
  margin-bottom: 16px;
}
.feature h3 { font-size: 1.0625rem; margin-bottom: 8px; }
.feature p { color: var(--text-muted); font-size: .875rem; margin: 0; }

.section__head { max-width: 60ch; margin: 0 auto 44px; text-align: center; }
.section__head h2 { margin-bottom: 12px; }
.section__head p { color: var(--text-muted); font-size: 1rem; }

/* ------------------------------------------------------------------ 15. auth pages */

.auth {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(800px 420px at 50% -10%, var(--brand-50), transparent 60%),
    var(--bg);
}

.auth__card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 34px;
}

.auth__head { text-align: center; margin-bottom: 26px; }
.auth__mark {
  width: 54px; height: 54px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, .3);
}
.auth__head h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth__head p { color: var(--text-muted); font-size: .875rem; margin: 0; }
.auth__foot { text-align: center; margin-top: 22px; font-size: .875rem; color: var(--text-muted); }

.auth__aside {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 20px; padding: 12px;
  background: var(--surface-2); border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: .8125rem; color: var(--text-muted);
}

/* ------------------------------------------------------------------ 16. modal */

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(3px);
}
.modal.is-open { display: flex; }

.modal__panel {
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  animation: modal-in .18s ease;
}
.modal__panel--wide { max-width: 720px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

.modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border-soft);
}
.modal__head h3 { margin: 0; font-size: 1.0625rem; }
.modal__body { padding: 22px; }
.modal__foot {
  padding: 16px 22px; border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
  display: flex; gap: 10px; justify-content: flex-end;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.modal__close {
  background: none; border: 0; cursor: pointer; padding: 4px;
  color: var(--text-subtle); display: grid; place-items: center;
}
.modal__close:hover { color: var(--text); }

/* ------------------------------------------------------------------ 17. dropdown */

.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 60;
}
.dropdown.is-open .dropdown__menu { display: block; }
.dropdown__menu a, .dropdown__menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: 0; background: none; cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-size: .875rem; text-align: left;
}
.dropdown__menu a:hover, .dropdown__menu button:hover { background: var(--surface-3); text-decoration: none; }
.dropdown__menu .danger { color: var(--danger-text); }
.dropdown__divider { height: 1px; background: var(--border-soft); margin: 6px 4px; }

/* ------------------------------------------------------------------ 18. tabs */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tab {
  padding: 11px 16px;
  border: 0; background: none; cursor: pointer;
  color: var(--text-muted); font: inherit; font-size: .875rem; font-weight: 650;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab--active { color: var(--brand-600); border-bottom-color: var(--brand-600); }

/* ------------------------------------------------------------------ 19. pagination */

.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 16px; }
.pagination__link {
  min-width: 36px; height: 36px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .875rem; font-weight: 650;
}
.pagination__link:hover { background: var(--surface-2); text-decoration: none; }
.pagination__link--active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.pagination__gap { padding: 0 4px; color: var(--text-subtle); }

/* ------------------------------------------------------------------ 20. empty state */

.empty { padding: 56px 24px; text-align: center; }
.empty__icon {
  width: 62px; height: 62px; margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-3); color: var(--text-subtle);
}
.empty h3 { margin-bottom: 8px; }
.empty p { color: var(--text-muted); font-size: .875rem; max-width: 46ch; margin: 0 auto 20px; }

/* ------------------------------------------------------------------ 21. misc */

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); font-size: .875rem; }
.kv:last-child { border-bottom: 0; }
.kv__k { color: var(--text-muted); font-weight: 600; }
.kv__v { font-weight: 650; text-align: right; word-break: break-word; }

.code-block {
  font-family: var(--mono);
  font-size: .8125rem;
  line-height: 1.7;
  padding: 14px 16px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  overflow-x: auto;
}

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  font-family: var(--mono); font-size: .75rem;
  color: var(--text-muted);
}
.chip--button { cursor: pointer; }
.chip--button:hover { background: var(--brand-50); border-color: var(--brand-400); color: var(--brand-700, var(--brand-600)); }

.copy-field { display: flex; align-items: center; gap: 8px; }
.copy-field code {
  flex: 1 1 auto; padding: 9px 12px;
  background: var(--surface-3); border-radius: var(--radius-sm);
  overflow-x: auto; white-space: nowrap;
}

.search-box { position: relative; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); pointer-events: none; }
.search-box .input { padding-left: 40px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.progress { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; background: var(--brand-600); border-radius: 999px; transition: width .3s ease; }
.progress__bar--warning { background: var(--warning); }
.progress__bar--danger  { background: var(--danger); }

/* Landing pricing */

.plan {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 28px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
}
.plan--featured { border-color: var(--brand-500); box-shadow: var(--shadow-lg); position: relative; }
.plan--featured::before {
  content: "Most popular";
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--brand-600); color: #fff;
  font-size: .625rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 14px; border-radius: 999px;
}
.plan__price { font-size: 2.25rem; font-weight: 800; letter-spacing: -.03em; margin: 10px 0 4px; }
.plan ul { list-style: none; padding: 0; margin: 20px 0 24px; display: flex; flex-direction: column; gap: 10px; font-size: .875rem; }
.plan li { display: flex; gap: 10px; align-items: flex-start; color: var(--text-muted); }
.plan li .icon { color: var(--success); margin-top: 2px; }

/* Installer */

.install-steps { display: flex; gap: 8px; margin-bottom: 28px; flex-wrap: wrap; }
.install-step {
  flex: 1 1 0; min-width: 120px;
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .8125rem; font-weight: 650; color: var(--text-muted);
}
.install-step--active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.install-step--done { background: var(--success-bg); border-color: var(--success); color: var(--success-text); }

.req-list { list-style: none; padding: 0; margin: 0; }
.req-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border-soft);
  font-size: .875rem;
}
.req-list li:last-child { border-bottom: 0; }
.req-list .icon { flex: 0 0 auto; }
.req-list .ok { color: var(--success); }
.req-list .bad { color: var(--danger); }
.req-list .req-list__hint { margin-left: auto; font-size: .75rem; color: var(--text-subtle); text-align: right; }

/* Email preview frame */

.mail-preview {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: #fff;
}
.mail-preview iframe { width: 100%; height: 520px; border: 0; display: block; background: #fff; }

/* ------------------------------------------------------------------ 23. toasts */

.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(390px, calc(100vw - 32px));
  pointer-events: none;
}

/* Anything inside a layout with a fixed header sits slightly lower. */
.toast-stack--offset { top: 74px; }

.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 16px 15px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-600);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  pointer-events: auto;
  overflow: hidden;
  animation: toast-in .32s cubic-bezier(.21, 1.02, .73, 1);
}

.toast.is-leaving {
  animation: toast-out .22s ease forwards;
}

.toast__icon {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-top: 1px;
}

.toast__icon .icon { width: 17px; height: 17px; }

.toast__body { flex: 1 1 auto; min-width: 0; }

.toast__title {
  display: block;
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
  line-height: 1.35;
}

.toast__message {
  display: block;
  margin-top: 3px;
  font-size: .8125rem;
  line-height: 1.55;
  color: var(--text-muted);
  word-break: break-word;
}

.toast__close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  margin: -2px -4px 0 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.toast__close:hover { background: var(--surface-3); color: var(--text); }
.toast__close .icon { width: 15px; height: 15px; }

/* The countdown strip along the bottom edge. */
.toast__timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  transform-origin: left center;
  background: currentColor;
  opacity: .28;
}

.toast--success { border-left-color: var(--success); color: var(--success); }
.toast--error,
.toast--danger  { border-left-color: var(--danger);  color: var(--danger); }
.toast--warning { border-left-color: var(--warning); color: var(--warning); }
.toast--info    { border-left-color: var(--info);    color: var(--info); }
.toast--brand   { border-left-color: var(--brand-600); color: var(--brand-600); }

.toast--success .toast__icon { background: var(--success-bg); color: var(--success-text); }
.toast--error   .toast__icon,
.toast--danger  .toast__icon { background: var(--danger-bg);  color: var(--danger-text); }
.toast--warning .toast__icon { background: var(--warning-bg); color: var(--warning-text); }
.toast--info    .toast__icon { background: var(--info-bg);    color: var(--info-text); }
.toast--brand   .toast__icon { background: var(--brand-50);   color: var(--brand-700); }

.toast.is-paused .toast__timer { animation-play-state: paused; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(calc(100% + 24px)) scale(.97); }
  to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
  from { opacity: 1; transform: none; max-height: 220px; }
  to   { opacity: 0; transform: translateX(calc(100% + 24px)) scale(.97); max-height: 0; }
}

@keyframes toast-timer {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

@media (max-width: 640px) {
  .toast-stack { top: auto; bottom: 14px; right: 14px; left: 14px; width: auto; }
  .toast-stack--offset { top: auto; }
  .toast { animation-name: toast-in-mobile; }
  @keyframes toast-in-mobile {
    from { opacity: 0; transform: translateY(calc(100% + 20px)) scale(.97); }
    to   { opacity: 1; transform: none; }
  }
}

/* ------------------------------------------------------------------ 22. responsive */

@media (max-width: 1024px) {
  .grid--4, .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--sidebar { grid-template-columns: 1fr; }
  .hero__grid { grid-template-columns: 1fr; gap: 40px; }
  .site-footer__grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .shell__sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-xl);
  }
  .shell--nav-open .shell__sidebar { transform: none; }
  .shell--nav-open::after {
    content: ""; position: fixed; inset: 0; z-index: 35;
    background: rgba(15, 23, 42, .45);
  }
  .topbar__burger { display: inline-flex; }
  .sidebar__close { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .shell__content { padding: 18px 16px; }
  .site-nav { display: none; }
}

@media (max-width: 640px) {
  .grid--2, .grid--3, .grid--4, .stats { grid-template-columns: 1fr; }
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid .span-3 { grid-column: span 1; }
  .section { padding: 48px 0; }
  .hero { padding: 52px 0 44px; }
  .auth__card { padding: 26px 20px; }
  .site-footer__grid { grid-template-columns: 1fr; gap: 22px; }
  .card__body, .card__head, .card__foot { padding-left: 16px; padding-right: 16px; }
  .modal__panel { border-radius: var(--radius-lg); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar form { flex-direction: column; align-items: stretch; }
}

@media (min-width: 861px) {
  .sidebar__close { display: none; }
}

@media print {
  .shell__sidebar, .topbar, .impersonate-bar, .btn { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------- 23. public mobile menu */

/*
 * .site-nav is hidden below 860px, so the same links are rendered a second
 * time inside a panel that [data-site-nav-toggle] opens. The panel is hidden
 * by the `hidden` attribute, which the toggle removes.
 */
.site-nav-toggle { display: none; }

.site-nav-mobile {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.site-nav-mobile__inner { display: flex; flex-direction: column; padding: 4px 0 12px; }

.site-nav-mobile a {
  display: flex; align-items: center; gap: 9px;
  padding: 13px 2px;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border-soft);
}

.site-nav-mobile a:last-child { border-bottom: 0; }
.site-nav-mobile a:hover { color: var(--brand-600); }

/* --------------------------------------------- 24. zone assignment controls */

.zone-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.zone-actions__form { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; margin: 0; }

.select--sm { padding: 6px 10px; font-size: .8125rem; }

.card__sub { margin: 5px 0 0; font-size: .8125rem; font-weight: 400; color: var(--text-muted); }

/* --------------------------------------------------- 25. small screens */

@media (max-width: 860px) {
  .site-nav-toggle { display: inline-flex; }

  /* "Get started" carries the same intent as "Sign in" for a first-time
     visitor, so the header keeps one call to action and the burger. */
  .site-header__signin { display: none; }
}

@media (max-width: 640px) {
  /* Tabs scroll sideways instead of stacking into a tall column. */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; }

  /* A dropdown must never hang off the edge of a phone. */
  .dropdown__menu { max-width: calc(100vw - 32px); }

  /* Stacked controls read better than a squeezed row in a table cell. */
  .zone-actions { align-items: stretch; }
  .zone-actions__form { flex-wrap: wrap; }
  .zone-actions__form .select { flex: 1 1 100%; min-width: 0; }
  .zone-actions__form .btn { flex: 1 1 auto; justify-content: center; }

  .table__actions { flex-wrap: wrap; justify-content: flex-start; }

  /* Long tokens (zone ids, API keys) should wrap rather than widen the page. */
  .mono-sm.break { overflow-wrap: anywhere; }

  .site-header__inner { gap: 10px; }
  .brand span { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 380px) {
  .site-header__actions .btn--primary { padding-left: 12px; padding-right: 12px; }
}

/* ------------------------------------------------------ 26. traffic chart */

/* A pure-CSS column chart. Each bar is a flex child whose height is a
   percentage of the busiest day, so there is nothing to load and nothing to
   lay out in JavaScript. */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 140px;
}

.chart__col {
  flex: 1 1 0;
  min-width: 2px;
  height: 100%;
  display: flex;
  align-items: flex-end;
}

.chart__bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg, var(--brand-400), var(--brand-600));
  transition: filter .15s ease;
}

.chart__col:hover .chart__bar { filter: brightness(1.1); }

.chart__axis {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-subtle);
}

@media (max-width: 640px) {
  .chart { height: 100px; gap: 2px; }
  .chart__axis { font-size: 11px; }
}

