/* Voxy AI Admin — light SaaS console (sidebar + KPI + tables) */
:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-elevated: #ffffff;
  --sidebar: #0f172a;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-text: #94a3b8;
  --sidebar-text-strong: #f8fafc;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.12);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --accent-hover: #4338ca;
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.04);
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

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

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

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

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

a:hover {
  text-decoration: underline;
}

/* ——— App shell ——— */
.app-body {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 18px;
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 22px;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.45);
}

.sidebar-product {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--sidebar-text-strong);
  letter-spacing: -0.02em;
}

.sidebar-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-text-strong);
  text-decoration: none;
}

.nav-link.is-active {
  background: rgba(99, 102, 241, 0.22);
  color: #e0e7ff;
}

.nav-ico {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-logout {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--sidebar-text);
  font-family: inherit;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-logout:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text-strong);
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 28px 18px;
  background: rgba(244, 246, 251, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.topbar-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 640px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pill--live {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.92);
  }
}

.pill--muted {
  background: var(--bg-elevated);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
}

.main-canvas {
  flex: 1;
  padding: 8px 28px 40px;
  max-width: 1600px;
  width: 100%;
}

.analyst-note {
  margin-bottom: 24px;
  padding: 16px 18px;
  background: linear-gradient(120deg, rgba(79, 70, 229, 0.07), rgba(14, 165, 233, 0.05));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.55;
}

.analyst-note > strong:first-child {
  display: block;
  margin-bottom: 10px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.analyst-note__body strong {
  color: var(--text);
  font-weight: 600;
}

.section--tight {
  margin-bottom: 28px;
}

.exec-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.exec-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.exec-card--lead {
  grid-column: span 2;
  border-color: rgba(79, 70, 229, 0.35);
  background: linear-gradient(145deg, rgba(79, 70, 229, 0.07), var(--bg-elevated));
}

.exec-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.exec-value {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.exec-foot {
  font-size: 0.78rem;
  margin-top: auto;
}

.exec-chip {
  font-size: 0.72rem;
  font-weight: 600;
  align-self: flex-start;
}

.funnel-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.funnel-header {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  margin-bottom: 18px;
  font-size: 0.9rem;
}

.funnel-bars {
  display: grid;
  gap: 12px;
}

.funnel-row {
  display: grid;
  grid-template-columns: minmax(88px, 120px) 1fr;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
}

.funnel-key {
  color: var(--muted);
  font-weight: 600;
}

.funnel-track {
  height: 14px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 7px;
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  border-radius: 7px;
  min-width: 2px;
  transition: width 0.4s ease;
}

.funnel-fill--base {
  background: #cbd5e1;
}

.funnel-fill--mid {
  background: linear-gradient(90deg, #6366f1, #818cf8);
}

.funnel-fill--paid {
  background: linear-gradient(90deg, #059669, #34d399);
}

@media (max-width: 900px) {
  .exec-card--lead {
    grid-column: span 1;
  }
}

/* ——— Dashboard sections ——— */
.section {
  margin-bottom: 36px;
}

.section-title {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.section-hint {
  margin: 0 0 16px;
  font-size: 0.875rem;
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  gap: 14px;
}

.kpi-grid--5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.kpi-grid--6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 1400px) {
  .kpi-grid--6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .kpi-grid--5 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .kpi-grid--6,
  .kpi-grid--5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .kpi-grid--6,
  .kpi-grid--5 {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.kpi-foot {
  margin-top: 8px;
  font-size: 0.8rem;
}

.delta {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}

.delta--up {
  background: var(--success-soft);
  color: var(--success);
}

.delta--down {
  background: var(--danger-soft);
  color: var(--danger);
}

.chart-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .chart-grid--2,
  .chart-grid--3 {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel--grow {
  flex: 1;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}

.panel-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.chart-panel .panel-head {
  padding-bottom: 4px;
}

.chart-panel--compact .chart-canvas {
  height: 240px;
}

.chart-canvas {
  position: relative;
  height: 280px;
  padding: 8px 14px 18px;
}

.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  margin: 0;
}

.layout-split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.layout-split--top {
  grid-template-columns: 1fr 1fr;
}

.layout-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (max-width: 1100px) {
  .layout-split,
  .layout-split--top {
    grid-template-columns: 1fr;
  }
}

.table-scroll {
  overflow-x: auto;
}

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

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(248, 250, 252, 0.9);
}

.data-table tbody tr:hover td {
  background: rgba(79, 70, 229, 0.03);
}

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

canvas {
  max-height: 100%;
}

/* ——— Legacy page patterns (users, comms, forms) ——— */
.eyebrow {
  display: block;
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.65rem, 3vw, 2.1rem);
  font-weight: 600;
  letter-spacing: -0.03em;
}

.subtitle {
  margin: 0;
  max-width: 560px;
  color: var(--muted);
  font-size: 0.95rem;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.card,
.meta-card,
.login-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.table-card {
  padding: 0;
}

.table-wrap {
  overflow-x: auto;
}

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

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

table th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: rgba(248, 250, 252, 0.95);
}

table tbody tr:hover td {
  background: rgba(79, 70, 229, 0.03);
}

.card-header,
.action-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.metric-card span,
.metric-card small,
.meta-card span,
.card-header span {
  color: var(--muted);
}

.metrics {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.65rem;
  font-weight: 600;
}

.button,
button[type="submit"]:not(.sidebar-logout),
.login-card button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
  transition: background 0.15s, transform 0.1s;
}

.button:hover,
button[type="submit"]:not(.sidebar-logout):hover {
  background: var(--accent-hover);
  text-decoration: none;
}

.button:active,
button[type="submit"]:not(.sidebar-logout):active {
  transform: translateY(1px);
}

.button--secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

.button--secondary:hover {
  background: #f8fafc;
}

.link-button {
  display: block;
  width: 100%;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--text);
  background: transparent;
}

.search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-form input {
  flex: 1;
  min-width: 200px;
}

.form-stack,
.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
}

input,
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg-elevated);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  resize: vertical;
}

.flash-stack {
  padding: 0 28px;
  display: grid;
  gap: 10px;
}

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: #3730a3;
  font-size: 0.875rem;
}

.flash--error {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.25);
  color: #991b1b;
}

.danger-zone {
  border-color: rgba(220, 38, 38, 0.35);
  background: var(--danger-soft);
}

.charts,
.tables,
.two-cols {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .charts,
  .tables,
  .two-cols,
  .metrics {
    grid-template-columns: 1fr;
  }

  .hero,
  .action-row {
    flex-direction: column;
    align-items: stretch;
  }
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-direction: row;
}

.checkbox-label input {
  width: auto;
}

.table-hint {
  margin: 0 0 12px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.table-edit-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 220px;
}

.table-edit-form--stack {
  flex-direction: column;
  align-items: stretch;
}

.table-edit-input {
  min-width: 10rem;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 0.875rem;
}

.table-edit-input--narrow {
  min-width: 5rem;
  max-width: 7rem;
}

.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;
}

/* Login */
.login-body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  font-family: var(--font-sans);
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(79, 70, 229, 0.18), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(14, 165, 233, 0.12), transparent),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  padding: 36px;
}

.login-card h1 {
  margin: 0 0 20px;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.login-card .eyebrow {
  margin-bottom: 8px;
}

.login-lead {
  margin-bottom: 22px;
}

/* Responsive shell */
@media (max-width: 900px) {
  .app-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
  }

  .sidebar-brand {
    padding: 0;
    flex: 1;
    min-width: 180px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1 1 100%;
    order: 3;
    padding-top: 8px;
    border-top: 1px solid var(--sidebar-border);
  }

  .nav-link {
    flex: 1;
    justify-content: center;
    min-width: 120px;
  }

  .sidebar-footer {
    padding-top: 0;
    border-top: none;
    width: auto;
  }

  .sidebar-logout {
    width: auto;
    min-width: 100px;
  }

  .topbar {
    padding: 16px 18px;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .main-canvas {
    padding: 8px 18px 32px;
  }

  .flash-stack {
    padding: 0 18px;
  }
}
