/* ============================================================
   VoxGuard API - design system
   Deep charcoal / dark navy, purple + electric blue accents.
   ============================================================ */

:root {
  --bg: #0b0f18;
  --bg-2: #0e131f;
  --surface: #131a2a;
  --surface-2: #182033;
  --surface-3: #1e2740;
  --border: #232d45;
  --border-soft: #1c2439;
  --text: #e7ebf4;
  --text-2: #aab3c7;
  --muted: #7d879e;
  --primary: #7c5cff;
  --primary-2: #9a83ff;
  --primary-soft: rgba(124, 92, 255, .14);
  --accent: #35b9ff;
  --accent-soft: rgba(53, 185, 255, .12);
  --success: #2ecc8f;
  --success-soft: rgba(46, 204, 143, .12);
  --danger: #ff5c7a;
  --danger-soft: rgba(255, 92, 122, .12);
  --warning: #ffb020;
  --warning-soft: rgba(255, 176, 32, .12);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --shadow: 0 8px 28px rgba(0, 0, 0, .34);
  --shadow-soft: 0 2px 10px rgba(0, 0, 0, .22);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", Consolas, "Liberation Mono", Menlo, monospace;
  --sidebar-w: 250px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 650; letter-spacing: -.01em; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15.5px; }
p { margin: 0 0 1em; color: var(--text-2); }
small, .muted { color: var(--muted); font-size: 12.5px; }

::selection { background: rgba(124, 92, 255, .35); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: #2a3450; border-radius: 6px; border: 2px solid var(--bg-2); }
::-webkit-scrollbar-thumb:hover { background: #364266; }

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

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 22px; }

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface-3); color: var(--text);
  font: inherit; font-size: 13.5px; font-weight: 550; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease, opacity .15s ease;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: linear-gradient(180deg, #8a6bff, #6f4dff);
  border-color: #7c5cff; color: #fff;
  box-shadow: 0 4px 14px rgba(124, 92, 255, .28);
}
.btn-primary:hover { background: linear-gradient(180deg, #9779ff, #7b5bff); }

.btn-accent { background: #1f8fd6; border-color: #2ba4ec; color: #fff; }
.btn-accent:hover { background: #249ce6; }

.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: #2e3a5a; }

.btn-danger { background: var(--danger-soft); border-color: rgba(255, 92, 122, .4); color: var(--danger); }
.btn-danger:hover { background: rgba(255, 92, 122, .2); }

.btn-success { background: var(--success-soft); border-color: rgba(46, 204, 143, .4); color: var(--success); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent; color: var(--muted);
  cursor: pointer; transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; letter-spacing: .02em; }
.label .req { color: var(--danger); }

.input, .select, .textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 14px;
  color: var(--text); background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input::placeholder, .textarea::placeholder { color: #5c6683; }
.input:hover, .select:hover, .textarea:hover { border-color: #2e3a5a; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, .18);
  background: #0c111c;
}
.textarea { min-height: 132px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237d879e' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; cursor: pointer; }
.input-error { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 5px; display: block; }
.field-hint { color: var(--muted); font-size: 12px; margin-top: 5px; display: block; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-2); }
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--primary); }

/* ------------------------------------------------------------
   Cards / panels
   ------------------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-soft);
  padding: 20px; margin-bottom: 18px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 14.5px; font-weight: 650; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 16px; height: 16px; color: var(--primary-2); }
.card-sub { color: var(--muted); font-size: 12.5px; margin: 3px 0 0; }
.card-body { color: var(--text-2); }
.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-header { padding: 16px 20px 0; margin-bottom: 12px; }

/* ------------------------------------------------------------
   Alerts
   ------------------------------------------------------------ */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 13.5px; color: var(--text-2); margin-bottom: 14px;
  animation: fade-in .18s ease;
}
.alert-icon { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.alert-success { background: var(--success-soft); border-color: rgba(46, 204, 143, .35); color: #9ff0d1; }
.alert-success .alert-icon { color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: rgba(255, 92, 122, .35); color: #ffc2ce; }
.alert-error .alert-icon { color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: rgba(255, 176, 32, .35); color: #ffe0a8; }
.alert-warning .alert-icon { color: var(--warning); }
.alert-info { background: var(--accent-soft); border-color: rgba(53, 185, 255, .32); color: #b7e5ff; }
.alert-info .alert-icon { color: var(--accent); }
.alert-close { margin-left: auto; background: none; border: 0; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; opacity: .65; padding: 0 2px; }
.alert-close:hover { opacity: 1; }

/* ------------------------------------------------------------
   Badges
   ------------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
  letter-spacing: .03em; border: 1px solid transparent; white-space: nowrap;
}
.badge-neutral { background: var(--surface-3); border-color: var(--border); color: var(--text-2); }
.badge-success { background: var(--success-soft); border-color: rgba(46, 204, 143, .35); color: var(--success); }
.badge-danger { background: var(--danger-soft); border-color: rgba(255, 92, 122, .35); color: var(--danger); }
.badge-warning { background: var(--warning-soft); border-color: rgba(255, 176, 32, .35); color: var(--warning); }
.badge-purple { background: var(--primary-soft); border-color: rgba(124, 92, 255, .4); color: var(--primary-2); }
.badge-blue { background: var(--accent-soft); border-color: rgba(53, 185, 255, .35); color: var(--accent); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------
   Tables
   ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.2px; }
.table th {
  text-align: left; padding: 10px 14px; font-size: 11.5px; font-weight: 650;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: rgba(255, 255, 255, .022); }
.table td strong, .table td .td-main { color: var(--text); font-weight: 550; }
.table .td-sub { display: block; color: var(--muted); font-size: 11.5px; margin-top: 1px; }
.table-actions { display: flex; gap: 7px; justify-content: flex-end; }

/* ------------------------------------------------------------
   Stats / dashboard
   ------------------------------------------------------------ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 17px; position: relative; overflow: hidden; box-shadow: var(--shadow-soft);
  transition: border-color .15s ease, transform .15s ease;
}
.stat-card:hover { border-color: #2c3756; transform: translateY(-1px); }
.stat-card::after {
  content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent)); opacity: 0; transition: opacity .2s ease;
}
.stat-card:hover::after { opacity: .8; }
.stat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; }
.stat-icon { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary-2); }
.stat-icon svg { width: 15px; height: 15px; }
.stat-icon.is-blue { background: var(--accent-soft); color: var(--accent); }
.stat-icon.is-green { background: var(--success-soft); color: var(--success); }
.stat-icon.is-red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.is-amber { background: var(--warning-soft); color: var(--warning); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--text); line-height: 1.15; }
.stat-foot { font-size: 12px; color: var(--muted); margin-top: 5px; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.chart-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } .chart-grid .span-2 { grid-column: auto; } }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-soft); margin-bottom: 0; }
.chart-box { position: relative; height: 260px; }
.chart-box canvas { max-height: 100%; }

/* ------------------------------------------------------------
   Empty state
   ------------------------------------------------------------ */
.empty-state { text-align: center; padding: 46px 22px; }
.empty-state .empty-icon {
  width: 58px; height: 58px; margin: 0 auto 16px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary-2); border: 1px solid rgba(124, 92, 255, .3);
}
.empty-state .empty-icon svg { width: 26px; height: 26px; }
.empty-state h3 { margin-bottom: 6px; color: var(--text); }
.empty-state p { max-width: 460px; margin: 0 auto 18px; color: var(--muted); }

/* ------------------------------------------------------------
   Modal
   ------------------------------------------------------------ */
.modal { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.is-open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 8, 14, .74); backdrop-filter: blur(3px); animation: fade-in .15s ease; }
.modal-card {
  position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); animation: pop-in .16s ease;
}
.modal-card.modal-lg { max-width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--border-soft); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 15px 20px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }

/* ------------------------------------------------------------
   Misc components
   ------------------------------------------------------------ */
.kbd {
  display: inline-block; padding: 1px 7px; border-radius: 5px; font-family: var(--mono);
  font-size: 12px; background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2);
}

.code-block { position: relative; background: #0a0e17; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; overflow-x: auto; margin: 0 0 14px; }
.code-block pre { margin: 0; white-space: pre; color: #cbd3e6; font-size: 12.6px; line-height: 1.65; }
.code-block .copy-btn { position: absolute; top: 8px; right: 8px; }
.code-tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.code-tab { padding: 5px 12px; font-size: 12.5px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); cursor: pointer; }
.code-tab.is-active { background: var(--primary-soft); border-color: rgba(124, 92, 255, .45); color: var(--primary-2); }
.code-pane { display: none; }
.code-pane.is-active { display: block; }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .25); border-top-color: #fff;
  animation: spin .7s linear infinite; display: inline-block;
}
.spinner-lg { width: 30px; height: 30px; border-width: 3px; border-color: var(--border); border-top-color: var(--primary); }

.progress { height: 7px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; transition: width .4s ease; }

.divider-text { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 18px 0; text-transform: uppercase; letter-spacing: .08em; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filter-bar .field { margin-bottom: 0; flex: 0 1 auto; min-width: 150px; }
.filter-bar .grow { flex: 1 1 220px; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--border-soft); flex-wrap: wrap; }
.pagination-info { color: var(--muted); font-size: 12.5px; }
.pagination-links { display: flex; gap: 7px; }

.definition-list { display: grid; gap: 0; }
.definition-list > div { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--border-soft); font-size: 13.3px; }
.definition-list > div:last-child { border-bottom: 0; }
.definition-list dt { color: var(--muted); }
.definition-list dd { margin: 0; color: var(--text); text-align: right; word-break: break-all; }

/* ------------------------------------------------------------
   App shell (authenticated)
   ------------------------------------------------------------ */
.app-body { background: var(--bg); }
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--bg-2);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 60;
}
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 17px 18px 15px; border-bottom: 1px solid var(--border-soft); }
.sidebar-close { display: none; background: none; border: 0; color: var(--muted); cursor: pointer; }
.sidebar-close svg { width: 19px; height: 19px; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #7c5cff, #35b9ff); color: #fff; box-shadow: 0 4px 12px rgba(124, 92, 255, .35);
}
.brand-mark svg { width: 17px; height: 17px; }
.brand-sub { color: var(--primary-2); font-weight: 600; margin-left: 5px; font-size: 12.5px; vertical-align: 1px; letter-spacing: .1em; }

.nav { flex: 1; padding: 14px 11px; overflow-y: auto; }
.nav-divider { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #5a6478; padding: 16px 10px 7px; font-weight: 700; }
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; margin-bottom: 2px;
  border-radius: var(--radius-sm); color: var(--text-2); font-size: 13.5px; font-weight: 520;
  transition: background .13s ease, color .13s ease;
}
.nav-link svg { width: 16.5px; height: 16.5px; color: var(--muted); transition: color .13s ease; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link:hover svg { color: var(--text-2); }
.nav-link.is-active { background: var(--primary-soft); color: #cfc4ff; box-shadow: inset 2px 0 0 var(--primary); }
.nav-link.is-active svg { color: var(--primary-2); }

.sidebar-footer { border-top: 1px solid var(--border-soft); padding: 12px; }
.sidebar-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 7px 9px; border-radius: var(--radius-sm); }
.sidebar-status:hover { background: var(--surface-2); color: var(--text-2); text-decoration: none; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(125, 135, 158, .16); }
.status-ok { background: var(--success); box-shadow: 0 0 0 3px rgba(46, 204, 143, .18); }
.status-bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 92, 122, .18); }
.status-warn { background: var(--warning); box-shadow: 0 0 0 3px rgba(255, 176, 32, .18); }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: var(--radius-sm); background: var(--surface); margin-top: 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, #7c5cff, #4a9dff); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.sidebar-user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.sidebar-user-meta strong { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-meta small { font-size: 11px; color: var(--muted); }
.logout-form { margin: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 14px;
  padding: 0 24px; border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 15, 24, .86); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 40;
}
.topbar-menu { display: none; }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 1px 0 0; font-size: 12.3px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }

.content { flex: 1; padding: 24px; max-width: 1360px; width: 100%; margin: 0 auto; animation: fade-in .2s ease; }

.app-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 15px 24px; border-top: 1px solid var(--border-soft);
  color: var(--muted); font-size: 12.3px; flex-wrap: wrap;
}
.app-footer code { color: var(--text-2); }
.app-footer-links { display: flex; gap: 15px; }
.app-footer-links a { color: var(--muted); }
.app-footer-links a:hover { color: var(--text-2); }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(4, 7, 12, .6); z-index: 55; }

@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-close, .topbar-menu { display: inline-flex; }
  .sidebar-backdrop.is-visible { display: block; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ------------------------------------------------------------
   Public pages
   ------------------------------------------------------------ */
.public-body { display: flex; flex-direction: column; min-height: 100vh; background:
  radial-gradient(1100px 500px at 80% -10%, rgba(124, 92, 255, .12), transparent 60%),
  radial-gradient(900px 460px at 8% 0%, rgba(53, 185, 255, .08), transparent 55%),
  var(--bg);
}
.public-nav { position: sticky; top: 0; z-index: 50; border-bottom: 1px solid var(--border-soft); background: rgba(11, 15, 24, .82); backdrop-filter: blur(10px); }
.public-nav-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 16px; }
.public-links { display: flex; align-items: center; gap: 20px; font-size: 13.7px; }
.public-links a { color: var(--text-2); }
.public-links a:hover, .public-links a.is-active { color: var(--text); text-decoration: none; }
.public-links .btn { color: #fff; }
.public-menu-btn { display: none; }
.public-main { flex: 1; }
.public-flash-wrap { margin-top: 18px; }

.hero { padding: 76px 0 54px; text-align: center; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px; border-radius: 999px;
  background: var(--primary-soft); border: 1px solid rgba(124, 92, 255, .4);
  color: var(--primary-2); font-size: 12.5px; font-weight: 600; margin-bottom: 22px;
}
.hero h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.14; letter-spacing: -.03em; margin-bottom: 16px; }
.hero h1 .grad { background: linear-gradient(90deg, #9a83ff, #35b9ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { max-width: 680px; margin: 0 auto 30px; font-size: 16.5px; color: var(--text-2); line-height: 1.65; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.hero-demo { max-width: 720px; margin: 46px auto 0; text-align: left; }
.hero-demo .demo-head { display: flex; align-items: center; gap: 7px; padding: 11px 15px; border-bottom: 1px solid var(--border-soft); }
.demo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-3); }
.demo-dot:nth-child(1) { background: #ff5f57; } .demo-dot:nth-child(2) { background: #febc2e; } .demo-dot:nth-child(3) { background: #28c840; }
.demo-title { margin-left: 8px; font-size: 12px; color: var(--muted); font-family: var(--mono); }

.section { padding: 52px 0; }
.section-title { text-align: center; margin-bottom: 36px; }
.section-title h2 { font-size: 27px; letter-spacing: -.02em; }
.section-title p { max-width: 620px; margin: 8px auto 0; color: var(--muted); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (max-width: 980px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; } }

.feature-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; transition: border-color .18s ease, transform .18s ease; }
.feature-card:hover { border-color: #2f3b60; transform: translateY(-2px); }
.feature-icon {
  width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary-2); margin-bottom: 14px; border: 1px solid rgba(124, 92, 255, .25);
}
.feature-icon.is-blue { background: var(--accent-soft); color: var(--accent); border-color: rgba(53, 185, 255, .25); }
.feature-icon.is-green { background: var(--success-soft); color: var(--success); border-color: rgba(46, 204, 143, .25); }
.feature-icon.is-amber { background: var(--warning-soft); color: var(--warning); border-color: rgba(255, 176, 32, .25); }
.feature-icon svg { width: 19px; height: 19px; }
.feature-card h3 { font-size: 15.5px; margin-bottom: 7px; }
.feature-card p { font-size: 13.6px; color: var(--muted); margin: 0; line-height: 1.6; }

.steps { counter-reset: step; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 980px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 19px; position: relative; }
.step::before {
  counter-increment: step; content: counter(step);
  width: 27px; height: 27px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #7c5cff, #4a9dff); color: #fff; font-size: 13px; font-weight: 700; margin-bottom: 11px;
}
.step h3 { font-size: 14.3px; margin-bottom: 5px; }
.step p { font-size: 13px; color: var(--muted); margin: 0; }

.lang-cloud { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.lang-chip { padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.lang-chip strong { color: var(--text); font-weight: 600; }

.public-footer { border-top: 1px solid var(--border-soft); background: var(--bg-2); margin-top: 40px; }
.public-footer-inner { display: flex; justify-content: space-between; gap: 26px; padding: 34px 22px 24px; flex-wrap: wrap; }
.public-footer-inner p { font-size: 13px; color: var(--muted); max-width: 380px; margin: 7px 0 0; }
.public-footer-links { display: flex; flex-direction: column; gap: 9px; font-size: 13.4px; }
.public-footer-links a { color: var(--text-2); }
.public-footer-base { display: flex; justify-content: space-between; gap: 14px; padding: 15px 22px; border-top: 1px solid var(--border-soft); font-size: 12.3px; color: var(--muted); flex-wrap: wrap; }

/* Auth pages */
.auth-wrap { min-height: calc(100vh - 62px); display: flex; align-items: center; justify-content: center; padding: 46px 20px; }
.auth-card { width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px; box-shadow: var(--shadow); }
.auth-card.auth-wide { max-width: 640px; }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .brand-mark { margin: 0 auto 13px; width: 42px; height: 42px; border-radius: 12px; }
.auth-head .brand-mark svg { width: 21px; height: 21px; }
.auth-head h1 { font-size: 20px; margin-bottom: 5px; }
.auth-head p { font-size: 13.5px; color: var(--muted); margin: 0; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13.3px; color: var(--muted); }
.auth-alt { text-align: center; margin-top: 14px; font-size: 13.3px; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; font-size: 13.3px; }

/* Legal / docs layout */
.page-narrow { max-width: 860px; margin: 0 auto; }
.prose h2 { margin-top: 30px; font-size: 19px; }
.prose h3 { margin-top: 22px; font-size: 15.5px; }
.prose p, .prose li { color: var(--text-2); font-size: 14.2px; line-height: 1.7; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 1em; }
.prose li { margin-bottom: 6px; }
.prose code { background: var(--surface-3); padding: 1.5px 6px; border-radius: 5px; color: #d7cdfc; }
.prose blockquote { border-left: 3px solid var(--primary); margin: 0 0 1em; padding: 4px 16px; color: var(--muted); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.2em; font-size: 13.5px; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.prose th { background: var(--surface-2); color: var(--text); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }

.docs-toc { position: sticky; top: 84px; }
.docs-layout { display: grid; grid-template-columns: 218px 1fr; gap: 30px; align-items: start; }
@media (max-width: 900px) { .docs-layout { grid-template-columns: 1fr; } .docs-toc { position: static; } }
.docs-toc nav { display: flex; flex-direction: column; gap: 2px; }
.docs-toc a { font-size: 13px; color: var(--muted); padding: 6px 11px; border-radius: 6px; border-left: 2px solid transparent; }
.docs-toc a:hover { color: var(--text-2); background: var(--surface-2); text-decoration: none; }
.docs-toc a.is-active { color: var(--primary-2); border-left-color: var(--primary); background: var(--primary-soft); }
.docs-toc .toc-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #5a6478; font-weight: 700; padding: 12px 11px 6px; }

/* Playground */
.pg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .pg-grid { grid-template-columns: 1fr; } }
.json-view {
  background: #0a0e17; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; min-height: 240px; max-height: 460px; overflow: auto;
  font-family: var(--mono); font-size: 12.6px; line-height: 1.65; color: #cbd3e6;
  white-space: pre-wrap; word-break: break-word; margin: 0;
}
.json-view .j-key { color: #9a83ff; }
.json-view .j-str { color: #7ee0b8; }
.json-view .j-num { color: #35b9ff; }
.json-view .j-bool { color: #ffb020; }
.json-view .j-null { color: #ff5c7a; }
.result-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 15px; border-radius: 999px; font-size: 13px; font-weight: 650; }
.result-clean { background: var(--success-soft); border: 1px solid rgba(46, 204, 143, .4); color: var(--success); }
.result-flagged { background: var(--danger-soft); border: 1px solid rgba(255, 92, 122, .4); color: var(--danger); }
.result-idle { background: var(--surface-3); border: 1px solid var(--border); color: var(--muted); }

/* Reveal key box */
.secret-box {
  display: flex; align-items: center; gap: 10px; background: #0a0e17;
  border: 1px dashed rgba(124, 92, 255, .55); border-radius: var(--radius-sm);
  padding: 13px 15px; font-family: var(--mono); font-size: 13px; color: #d7cdfc;
  word-break: break-all; margin-bottom: 14px;
}
.secret-box .grow { flex: 1; }

/* Install page */
.install-body { background: var(--bg); min-height: 100vh; padding: 40px 20px; }
.install-wrap { max-width: 760px; margin: 0 auto; }
.install-step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; }
.install-step h3 { display: flex; align-items: center; gap: 10px; font-size: 14.5px; margin-bottom: 10px; }
.install-num { width: 24px; height: 24px; border-radius: 7px; background: var(--primary-soft); color: var(--primary-2); display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; flex: none; }
.check-line { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 13.4px; color: var(--text-2); border-bottom: 1px dashed var(--border-soft); }
.check-line:last-child { border-bottom: 0; }
.check-line svg { width: 16px; height: 16px; flex: none; }
.check-ok { color: var(--success); } .check-fail { color: var(--danger); } .check-warn { color: var(--warning); }
.install-log { background: #0a0e17; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; font-family: var(--mono); font-size: 12.6px; line-height: 1.8; color: #b9c2d8; max-height: 340px; overflow: auto; }
.install-log .ok { color: var(--success); } .install-log .bad { color: var(--danger); } .install-log .warn { color: var(--warning); }

/* Health checks */
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.health-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 17px; }
.health-item h4 { font-size: 13.4px; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.health-item p { font-size: 12.7px; margin: 0; color: var(--muted); }

/* ------------------------------------------------------------
   Animations
   ------------------------------------------------------------ */
@keyframes fade-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

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

@media print {
  .sidebar, .topbar, .public-nav, .app-footer, .public-footer, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}
