/* ==========================================================================
   DCT Audio - Customer Web Portal Design System
   Modern SaaS TTS Dashboard with Dark/Light Support & Flag Icons
   ========================================================================== */

/* ------------------- CSS Variables & Themes ------------------- */
:root {
  /* Default Theme: Dark (Obsidian & Emerald) */
  --bg: #080d1a;
  --bg-gradient: radial-gradient(circle at 15% 10%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
                  radial-gradient(circle at 85% 90%, rgba(14, 165, 233, 0.05) 0%, transparent 40%),
                  #080d1a;
  --panel: #0d1527;
  --panel-2: #131f37;
  --panel-card: #101a2f;
  --panel-card-hover: #162440;
  --glass: rgba(13, 21, 39, 0.88);

  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --line-focus: #10b981;
  --grid-line: rgba(255, 255, 255, 0.03);

  --text: #f8fafc;
  --text-dim: #cbd5e1;
  --muted: #94a3b8;
  --faint: #64748b;

  --accent: #10b981;
  --accent-hover: #34d399;
  --accent-active: #059669;
  --accent-soft: rgba(16, 185, 129, 0.12);
  --accent-border: rgba(16, 185, 129, 0.28);
  --accent-contrast: #022c15;

  --blue: #38bdf8;
  --blue-soft: rgba(56, 189, 248, 0.12);
  --blue-border: rgba(56, 189, 248, 0.28);

  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.12);
  --warn-border: rgba(245, 158, 11, 0.28);

  --bad: #f43f5e;
  --bad-soft: rgba(244, 63, 94, 0.14);
  --bad-border: rgba(244, 63, 94, 0.32);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 2px 6px -1px rgba(0, 0, 0, 0.45), 0 8px 24px -4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 28px -4px rgba(0, 0, 0, 0.65), 0 18px 52px -8px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 16px rgba(16, 185, 129, 0.2);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  /* Soft Memphis pastels: strong tone for shapes/strokes, soft tone for surfaces */
  --mint: #5fd3a8;
  --lav: #a894f5;
  --peach: #ff9f73;
  --butter: #f5c451;
  --sky: #6cb8f5;
  --pink: #f58bb8;
  --mint-soft: rgba(95, 211, 168, 0.12);
  --lav-soft: rgba(168, 148, 245, 0.13);
  --peach-soft: rgba(255, 159, 115, 0.12);
  --sky-soft: rgba(108, 184, 245, 0.12);
  --deco-opacity: 0.38;
  --dot: rgba(255, 255, 255, 0.07);

  /* Dashboard design system: teal leads, blue/orange/violet only tag a stat type */
  --tone-teal: #2dd4bf;
  --tone-teal-soft: rgba(45, 212, 191, 0.12);
  --tone-blue: #60a5fa;
  --tone-blue-soft: rgba(96, 165, 250, 0.12);
  --tone-orange: #fb923c;
  --tone-orange-soft: rgba(251, 146, 60, 0.12);
  --tone-violet: #a78bfa;
  --tone-violet-soft: rgba(167, 139, 250, 0.13);
  --chart-1: #2dd4bf;
  --track: rgba(255, 255, 255, 0.05);

  --dur-fast: 180ms;
  --dur: 240ms;

  color-scheme: dark;
}

[data-theme="light"] {
  /* Light Theme: Modern Minimal SaaS + Soft Memphis geometry. Text/accent pairs are >= 4.5:1 on white. */
  --bg: #f6f8f7;
  --bg-gradient: radial-gradient(ellipse 55% 45% at 0% 0%, rgba(20, 184, 166, 0.07) 0%, transparent 70%),
                  #f6f8f7;
  --panel: #ffffff;
  --panel-2: #f2f5f4;
  --panel-card: #ffffff;
  --panel-card-hover: #fbfcfc;
  --glass: rgba(246, 248, 247, 0.86);

  --line: rgba(16, 24, 40, 0.07);
  --line-2: rgba(16, 24, 40, 0.12);
  --line-focus: #0f766e;
  --grid-line: transparent;

  --text: #101828;
  --text-dim: #344054;
  --muted: #5d6679;
  --faint: #667085;

  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-active: #134e4a;
  --accent-soft: rgba(15, 118, 110, 0.08);
  --accent-border: rgba(15, 118, 110, 0.22);
  --accent-contrast: #ffffff;

  --tone-teal: #0f766e;
  --tone-teal-soft: #e5f4f1;
  --tone-blue: #2563eb;
  --tone-blue-soft: #eaf1fe;
  --tone-orange: #c2410c;
  --tone-orange-soft: #fff0e6;
  --tone-violet: #6d28d9;
  --tone-violet-soft: #f1ecfd;
  --chart-1: #0d9488;
  --track: #eef2f1;

  --blue: #0369a1;
  --blue-soft: rgba(3, 105, 161, 0.08);
  --blue-border: rgba(3, 105, 161, 0.2);

  --warn: #b45309;
  --warn-soft: rgba(245, 158, 11, 0.12);
  --warn-border: rgba(180, 83, 9, 0.22);

  --bad: #be123c;
  --bad-soft: rgba(225, 29, 72, 0.08);
  --bad-border: rgba(190, 18, 60, 0.2);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 16px -4px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, 0.04), 0 16px 32px -12px rgba(16, 24, 40, 0.14);
  --shadow-glow: 0 6px 16px -6px rgba(15, 118, 110, 0.45);

  --mint-soft: #e3f7ef;
  --lav-soft: #efebff;
  --peach-soft: #ffede3;
  --sky-soft: #e5f2fd;
  --deco-opacity: 0.7;
  --dot: rgba(21, 27, 45, 0.09);

  color-scheme: light;
}

/* ------------------- Base Reset & Typography ------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px),
    var(--bg-gradient);
  background-size: 48px 48px, 48px 48px, 100% 100%;
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font-family: 'Plus Jakarta Sans', Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

code, pre {
  font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, "Courier New", monospace;
  font-variant-ligatures: none;
}

code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 14.5px;
  color: var(--text-dim);
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

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

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

/* ------------------- Brand Logo ------------------- */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong {
  display: block;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  color: #022612;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

.logo svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.3;
}

/* ------------------- Theme Switcher Button ------------------- */
.theme-toggle {
  position: relative;
  overflow: hidden;
}

.theme-icon {
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}

[data-theme="dark"] .theme-icon.moon {
  display: block;
  opacity: 1;
}
[data-theme="dark"] .theme-icon.sun {
  display: none;
  opacity: 0;
}

[data-theme="light"] .theme-icon.moon {
  display: none;
  opacity: 0;
}
[data-theme="light"] .theme-icon.sun {
  display: block;
  opacity: 1;
  color: #ea580c;
}

/* ------------------- App Shell Layout ------------------- */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 14px 10px;
  z-index: 20;
}

.sidebar nav {
  flex: 1;
  overflow-y: auto;
  margin-top: 16px;
  padding-right: 2px;
}

.nav-group {
  color: var(--faint);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 16px 8px 6px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.sidebar nav a:hover {
  background: var(--panel-2);
  color: var(--text);
}

.sidebar nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
  font-weight: 600;
}

.sidebar nav a.active svg {
  color: var(--accent);
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 0;
  border-top: 1px solid var(--line);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  flex-shrink: 0;
}

.who {
  flex: 1;
  min-width: 0;
}

.who strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  color: var(--text);
}

.who small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
  font-family: ui-monospace, Consolas, monospace;
}

/* ------------------- Topbar ------------------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 24px;
  min-height: 50px;
  position: sticky;
  top: 0;
  background: var(--glass);
  backdrop-filter: blur(12px);
  z-index: 10;
  border-bottom: 1px solid var(--line);
  transition: border-color var(--transition-fast);
}

.topbar.scrolled {
  border-bottom-color: var(--line-2);
}

.titles {
  flex: 1;
  min-width: 0;
}

.titles h1 {
  margin: 0;
  font-size: 17.5px;
  font-weight: 650;
  letter-spacing: -0.2px;
  color: var(--text);
}

.titles p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

.top-balance {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3.5px 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.top-balance:hover {
  border-color: var(--accent-border);
  background: var(--panel-2);
}

.balance-icon {
  color: var(--accent);
  width: 15px;
  height: 15px;
}

.top-balance strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.menu-btn {
  display: none;
}

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 30;
}

main {
  padding: 14px 24px 40px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ------------------- Panels & Cards ------------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

[data-theme="dark"] .panel {
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 18.5px;
  font-weight: 650;
  letter-spacing: -0.2px;
  color: var(--text);
}

.panel h3 {
  margin: 18px 0 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.panel-title-wrap {
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
}

.panel-head p {
  margin: 2px 0 0;
  font-size: 14.5px;
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.grid-2 > .panel {
  margin-bottom: 0;
}

.section-label {
  color: var(--faint);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 24px 0 12px;
}

.label {
  color: var(--faint);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.label.accent {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 14.5px;
}

.link {
  color: var(--accent);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.link:hover {
  text-decoration: underline;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 16px;
  margin: 0;
  font-size: 15.5px;
}

/* ------------------- Modern SaaS Analytics Dashboard ------------------- */
/* Spacing runs on a 4/8px scale. Colour: teal is the primary; each KPI card picks one
   --tone (teal / blue / orange / violet) that only tints its icon tile and corner ring. */
.dash-toolbar-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.dash-toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.dash-top-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--accent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.dash-top-icon svg {
  width: 20px;
  height: 20px;
}

.dash-main-heading {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
}

.dash-toolbar-left p {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.dash-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Segmented controls: a quiet track, the chosen segment lifts out as a white chip */
.time-pills,
.chart-metric-tabs {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 12px;
  background: var(--track);
  border: 1px solid var(--line);
}

.time-pill,
.chart-metric-tabs .tab-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease-out), color var(--dur-fast) ease,
              box-shadow var(--dur) var(--ease-out);
}

.time-pill:hover,
.chart-metric-tabs .tab-btn:hover {
  color: var(--text);
}

.time-pill.on,
.chart-metric-tabs .tab-btn.on {
  background: var(--panel);
  color: var(--accent);
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 0 0 1px var(--line);
}

.refresh-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}

.refresh-btn svg {
  width: 16px;
  height: 16px;
}

.refresh-btn.spinning svg {
  animation: m-spin 0.8s linear infinite;
}

/* 6 KPI cards */
.dash-metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  --tone: var(--tone-teal);
  --tone-soft: var(--tone-teal-soft);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

/* Memphis touch: one soft ring peeking from the corner */
.metric-card::after,
.billing-card::after {
  content: "";
  position: absolute;
  top: -28px;
  right: -28px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 10px solid var(--tone-soft);
  pointer-events: none;
  transition: transform 0.6s var(--ease-out);
}

.metric-card:hover::after,
.billing-card:hover::after {
  transform: scale(1.08) translate(-2px, 2px);
}

/* content paints above the ring */
.metric-card > *,
.billing-card > * {
  position: relative;
  z-index: 1;
}

.card-header-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-right: 24px;
}

.card-pill-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--tone-soft);
  color: var(--tone);
  transition: transform var(--dur) var(--ease-out);
}

.card-pill-icon svg {
  width: 20px;
  height: 20px;
}

.metric-card:hover .card-pill-icon {
  transform: scale(1.05);
}

.card-pill-label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--muted);
}

.card-stat-wrap {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-bottom: 16px;
}

.card-stat-num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.card-stat-unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.card-foot-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
}

.card-foot-text strong {
  color: var(--text);
}

.card-mini-act {
  color: var(--accent);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}

.card-mini-act:hover {
  text-decoration: underline;
}

/* Tone per card (class names are the markup's; the colours are the design's) */
.card-cyan,
.card-emerald { --tone: var(--tone-teal); --tone-soft: var(--tone-teal-soft); }
.card-blue,
.card-green { --tone: var(--tone-blue); --tone-soft: var(--tone-blue-soft); }
.card-purple { --tone: var(--tone-orange); --tone-soft: var(--tone-orange-soft); }
.card-amber { --tone: var(--tone-violet); --tone-soft: var(--tone-violet-soft); }

/* Balance is the headline figure: teal number */
.card-cyan .card-stat-num { color: var(--accent); }

/* Chart panels */
.dash-main-chart-card {
  margin-bottom: 24px;
}

.chart-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chart-badge-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.chart-badge-icon svg {
  width: 18px;
  height: 18px;
}

.chart-title-group h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text);
}

.chart-title-group p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.chart-canvas-wrap {
  width: 100%;
  overflow-x: auto;
  position: relative;
  margin-top: 8px;
}

.chart-spline,
.chart-bars {
  width: 100%;
  position: relative;
}

.chart-spline { min-height: 240px; }
.chart-bars { min-height: 210px; }

.chart-spline svg,
.chart-bars svg,
.donut-svg-wrap svg {
  width: 100%;
  display: block;
  stroke: none;
}

.chart-spline svg { height: 240px; }
.chart-bars svg { height: 210px; }

.chart-bars rect,
.chart-spline rect {
  stroke: none;
}

.chart-spline .grid,
.chart-bars .grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-spline .axis,
.chart-bars .axis {
  fill: var(--faint);
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
}

/* app.js draws the area with pink stops: CSS paints them teal, very light */
.chart-spline stop { stop-color: var(--chart-1); }
.chart-spline stop:nth-child(1) { stop-opacity: 0.16; }
.chart-spline stop:nth-child(2) { stop-opacity: 0.05; }
.chart-spline stop:nth-child(3) { stop-opacity: 0; }

.chart-spline .spline-line {
  fill: none;
  stroke: var(--chart-1);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-spline .spline-dot {
  fill: var(--panel);
  stroke: var(--chart-1);
  stroke-width: 2.5;
  r: 5;
  cursor: pointer;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--chart-1) 45%, transparent));
  transition: cx var(--dur-fast) var(--ease-out), cy var(--dur-fast) var(--ease-out);
}

.chart-spline .guide-line {
  stroke: var(--line-2);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  pointer-events: none;
}

.chart-bars .bar-p1 {
  fill: var(--chart-1);
  opacity: 0.78;
  rx: 5px;
  transition: opacity var(--dur-fast) ease, fill var(--dur-fast) ease;
}

.chart-bars .bar-p1:has(+ .bar-hit:hover) {
  opacity: 1;
  fill: var(--accent);
}

.tip-p1 {
  color: var(--accent);
}

/* Donut */
.donut-center-info {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  text-align: center;
}

.donut-center-num {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.1;
}

.donut-center-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dash-lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1.3fr);
  gap: 24px;
  margin-bottom: 24px;
}

.dash-sub-chart-card {
  margin-bottom: 0;
  min-width: 0;
}

.donut-content-layout {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 8px 0;
}

.donut-svg-wrap {
  width: 148px;
  height: 148px;
  flex-shrink: 0;
  position: relative;
}

.donut-svg-wrap svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-svg-wrap circle {
  stroke-width: 10;
  transition: stroke-width var(--dur-fast) var(--ease-out);
}

.donut-svg-wrap circle:hover {
  stroke-width: 13;
}

.donut-legend-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13.5px;
  transition: background-color var(--dur-fast) ease;
}

.donut-legend-item:hover {
  background: var(--panel-2);
}

.donut-legend-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.donut-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.donut-legend-name {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.donut-legend-val {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

/* Tables on the dashboard */
.dash-table-card {
  margin-bottom: 24px;
}

.dash-table-card .panel-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.model-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.model-cell-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text);
}

.mini-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-progress-bar {
  width: 72px;
  height: 6px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
  flex-shrink: 0;
}

.mini-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.5s var(--ease-out);
}

.mini-rate-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  width: 44px;
}

/* 6 cards need ~190px each: below ~1480px (1366/1440 laptops) they go 3 x 2 */
@media (max-width: 1480px) {
  .dash-metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .dash-lower-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .dash-metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .metric-card {
    padding: 16px;
  }
  .card-header-pill {
    gap: 8px;
    padding-right: 0;
  }
  .card-pill-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }
  .card-pill-icon svg {
    width: 16px;
    height: 16px;
  }
  .card-stat-num {
    font-size: 22px;
  }
  .dash-main-heading {
    font-size: 18px;
  }
  .donut-content-layout {
    flex-direction: column;
  }
  .donut-legend-list {
    width: 100%;
  }
}

.delta {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.delta:empty {
  display: none;
}

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

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

/* ------------------- Usage Chart ------------------- */
.chart-container {
  width: 100%;
  overflow-x: auto;
}

.chart {
  position: relative;
  min-height: 270px;
  width: 100%;
}

.chart svg {
  width: 100%;
  height: 270px;
  stroke: none;
  display: block;
}

.chart .grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart .axis {
  fill: var(--faint);
  font-size: 13px;
  font-family: inherit;
}

.chart .bar {
  fill: var(--accent);
  opacity: 0.85;
  transition: opacity var(--transition-fast), fill var(--transition-fast);
}

.chart .bar.zero {
  fill: var(--line-2);
  opacity: 0.5;
}

.chart .hit {
  fill: transparent;
  cursor: pointer;
}

.chart .hit:hover + .bar,
.chart .bar.hover {
  opacity: 1;
  fill: var(--accent-hover);
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.4;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
  box-shadow: var(--shadow-lg);
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* app.js moves it by left/top on each hover: glide between points instead of jumping */
  transition: left 0.16s var(--ease-out), top 0.16s var(--ease-out);
}

.tooltip .small {
  font-size: 12px;
}

.tooltip strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ------------------- Segmented Controls ------------------- */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 2.5px;
  border-radius: 7px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.035);
  flex-wrap: wrap;
}

.seg button, .seg label span {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  padding: 4px 12px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.seg button svg, .seg label span svg {
  width: 13px;
  height: 13px;
}

.seg button:hover, .seg label:hover span {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.seg button.on, .seg input:checked + span {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 1px 1px rgba(15, 23, 42, 0.04);
  font-weight: 600;
}

[data-theme="dark"] .seg button.on, 
[data-theme="dark"] .seg input:checked + span {
  background: var(--panel-card);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), inset 0 0 0 1px var(--line-2);
}

.seg label {
  margin: 0;
}

.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg.wide {
  display: flex;
  width: 100%;
}

.seg.wide label {
  flex: 1;
  text-align: center;
}

.seg.wide span {
  width: 100%;
}

/* ------------------- Form Controls ------------------- */
.form-group {
  margin-bottom: 10px;
}

label {
  display: block;
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-dim);
  letter-spacing: -0.1px;
}

.req {
  color: var(--bad);
}

.label-with-output {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
}

.label-with-output label {
  margin: 0;
}

.label-with-output output {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 2px 8px;
  border-radius: 6px;
}

input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  min-height: 33px;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

select {
  appearance: none;
  -webkit-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='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 36px;
  cursor: pointer;
}

[data-theme="light"] input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=file]), 
[data-theme="light"] select, 
[data-theme="light"] textarea {
  background-color: #ffffff;   /* not the shorthand: it wiped the select chevron (background-image) */
  border-color: rgba(15, 23, 42, 0.12);
}

input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=file]):focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 2.5px var(--accent-soft);
}

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

textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.45;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

legend {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text-dim);
  padding: 0;
  margin-bottom: 6px;
}

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

.select-wrap {
  position: relative;
}

/* ------------------- Pasted text / TXT source ------------------- */
.txt-bar, .txt-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.txt-bar {
  margin-bottom: 8px;
}

.txt-foot {
  justify-content: space-between;
  margin-top: 8px;
}

.txt-bar label {
  margin: 0;
}

.txt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
}

.txt-max {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 550;
}

#txt-max {
  width: 72px;
}

/* ------------------- Drag & Drop File Zone ------------------- */
.drop-zone {
  position: relative;
  display: block;
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft), inset 0 1px 2px rgba(16, 185, 129, 0.05);
}

.drop-zone:hover .drop-icon {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.drop-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.drop-content {
  display: flex;
  align-items: center;
  gap: 11px;
  pointer-events: none;
}

.drop-icon {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.drop-icon svg {
  width: 15px;
  height: 15px;
}

.drop-text {
  flex: 1;
  min-width: 0;
}

.drop-text strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.1px;
}

.drop-hint {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 1px;
}

.drop-zone.has-file {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone.has-file .drop-icon {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

/* ------------------- Toggle Switch & Checkbox ------------------- */
.toggle-row {
  margin: 14px 0 6px;
}

.check-switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.check-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-slider {
  width: 40px;
  height: 22px;
  background: var(--line-2);
  border-radius: 999px;
  position: relative;
  transition: background var(--transition-fast);
}

.switch-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform var(--transition-fast);
}

.check-switch input:checked + .switch-slider {
  background: var(--accent);
}

.check-switch input:checked + .switch-slider::before {
  transform: translateX(18px);
}

.switch-label {
  font-size: 15.5px;
  font-weight: 500;
  color: var(--text);
}

.check-box {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.check-box input[type=checkbox] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

/* ------------------- Language Flag Picker ------------------- */
.lang-picker-container {
  position: relative;
}

.lang-trigger {
  width: 100%;
  padding: 5px 9px;
  min-height: 33px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
  transition: all var(--transition-fast);
  text-align: left;
}

.lang-trigger:hover {
  border-color: var(--accent-border);
}

.lang-trigger:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.lang-flag-current {
  display: flex;
  align-items: center;
}

.lang-text-current {
  flex: 1;
  font-weight: 600;
  color: var(--text);
}

.lang-chevron {
  color: var(--muted);
  width: 16px;
  height: 16px;
  transition: transform var(--transition-fast);
}

.lang-trigger[aria-expanded="true"] .lang-chevron {
  transform: rotate(180deg);
}

.lang-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  padding: 8px;
  max-height: 320px;
  display: flex;
  flex-direction: column;
  animation: dropdownFadeIn 0.15s ease-out;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.lang-dropdown-header {
  padding: 6px 8px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.lang-list {
  overflow-y: auto;
  display: grid;
  gap: 2px;
  max-height: 250px;
  padding-right: 2px;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  transition: background var(--transition-fast);
}

.lang-option:hover, .lang-option.focused {
  background: var(--panel-2);
}

.lang-option.selected {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.lang-option-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
  margin-left: auto;
}

.lang-option.selected .lang-option-badge {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* Flag Vector SVGs */
.flag-svg {
  width: 24px;
  height: 18px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.28), 0 1px 3px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  display: inline-block;
  overflow: hidden;
  vertical-align: middle;
}

.flag-auto {
  box-shadow: none;
  color: var(--accent);
  width: 22px;
  height: 18px;
}

/* ------------------- Speed Slider & Presets ------------------- */
input[type=range] {
  width: 100%;
  height: 6px;
  background: var(--line-2);
  border-radius: 999px;
  border: 0;
  padding: 0;
  margin: 10px 0 12px;
  accent-color: var(--accent);
  cursor: pointer;
}

.speed-presets {
  display: flex;
  gap: 5px;
  margin-top: 5px;
}

.preset-btn {
  flex: 1;
  padding: 2px 6px;
  height: 25px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
  transition: all var(--transition-fast);
}

.preset-btn:hover {
  background: var(--panel);
  color: var(--text);
  border-color: var(--line-2);
}

.preset-btn.on {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* ------------------- Buttons ------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  height: 34px;
  padding: 0 14px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 550;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.btn.primary:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-glow);
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-2);
}

.btn.ghost:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.btn.block {
  width: 100%;
}

.btn.small {
  height: 28px;
  padding: 0 10px;
  font-size: 13.5px;
  border-radius: 6px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 7px;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--line-2);
  background: var(--panel-2);
}

.submit-wrap {
  margin-top: 18px;
}

.err {
  color: var(--bad);
  font-size: 14.5px;
  margin: 8px 0 0;
  white-space: pre-line;
  min-height: 1.2em;
}

.okmsg {
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 7px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}

/* ------------------- Tables & Job List ------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

th {
  text-align: left;
  color: var(--faint);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--panel-2);
}

td.file {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text);
}

/* Status Badges */
.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.status.done {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}
.status.done::before {
  background: var(--accent);
}

.status.partial {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: var(--blue-border);
}
.status.partial::before {
  background: var(--blue);
}

.status.running {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-border);
}
.status.running::before {
  background: var(--warn);
  animation: pulseDot 1.5s infinite;
}

.status.queued {
  background: var(--panel-2);
  color: var(--muted);
}
.status.queued::before {
  background: var(--faint);
}

.status.error {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: var(--bad-border);
}
.status.error::before {
  background: var(--bad);
}

.status.cancelled {
  background: var(--panel-2);
  color: var(--muted);
}

@keyframes pulseDot {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.note {
  color: var(--muted);
  font-size: 13.5px;
  margin-left: 6px;
}

/* Progress Bar */
.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 140px;
}

.bar-track {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: var(--line-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--blue) 100%);
  border-radius: 99px;
  transition: width var(--transition-normal);
}

/* Action Buttons in Tables */
.act {
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  margin-right: 6px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.act.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.act.primary:hover {
  background: var(--accent-hover);
}

.act.danger {
  color: var(--bad);
}

.act.danger:hover {
  background: var(--bad-soft);
  border-color: var(--bad-border);
}

.act:hover {
  border-color: var(--accent);
}

.table-foot-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 14px;
  margin-top: 14px;
}

/* ------------------- Voice List ------------------- */
.voice-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.voice-list li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-card);
  transition: border-color var(--transition-fast);
}

.voice-list li:hover {
  border-color: var(--line-2);
}

.voice-list .vicon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.voice-list .vbody {
  flex: 1;
  min-width: 0;
}

.voice-list .vbody strong {
  display: block;
  font-size: 16.5px;
  color: var(--text);
}

.voice-list .vbody p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ------------------- Tips Box & Quick Guide ------------------- */
.tips {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  padding: 14px 16px;
}

[data-theme="dark"] .tips {
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tips::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.5px;
  background: linear-gradient(90deg, var(--accent) 0%, #38bdf8 100%);
  opacity: 0.85;
}

.tips-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}

.tips-header h2 {
  font-size: 15px;
  font-weight: 650;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.15px;
}

.tips-icon {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.tips-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: tip-counter;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.tips-list li {
  counter-increment: tip-counter;
  position: relative;
  padding-left: 26px;
  font-size: 13px;
  line-height: 1.48;
  color: var(--text-dim);
}

.tips-list li::before {
  content: "0" counter(tip-counter);
  position: absolute;
  left: 0;
  top: 1px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 0 3.5px;
  border-radius: 3px;
  line-height: 1.35;
}

.tips-list > li > strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1px;
}

.tips-list code {
  font-size: 12px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  color: var(--accent);
  font-weight: 600;
}

/* ------------------- API Docs (Stripe / Vercel Developer Grade) ------------------- */
.docs-hero {
  margin-bottom: 24px;
}

.docs-hero h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.docs-intro {
  padding: 16px 20px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 28px;
  font-size: 15px;
  line-height: 1.6;
}

.docs-intro code {
  color: var(--accent);
  font-weight: 600;
}

.doc-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.doc-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.doc-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
}

.copy-code-btn {
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  color: var(--text-dim);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.copy-code-btn:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

pre {
  background: #090e1a !important;
  color: #e2e8f0 !important;
  border: 1px solid #1c2b46 !important;
  border-radius: 12px !important;
  padding: 38px 20px 18px !important;
  overflow-x: auto !important;
  font-size: 14.5px !important;
  line-height: 1.65 !important;
  margin: 0 0 14px !important;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28) !important;
  position: relative !important;
}

pre::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 16px 0 0 #f59e0b, 32px 0 0 #10b981;
}

pre code {
  background: none !important;
  border: 0 !important;
  padding: 0 !important;
  font-size: inherit !important;
  color: #f1f5f9 !important;
}

pre code span.origin {
  color: #38bdf8 !important;
  font-weight: 600;
}

/* ------------------- Responsive Breakpoints ------------------- */
@media (max-width: 1200px) {
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .hero {
    grid-template-columns: 1fr;
  }
  .hero-plan {
    justify-content: flex-start;
  }
  .plan-card {
    max-width: none;
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .menu-btn {
    display: grid;
  }
  .topbar {
    padding: 14px 18px;
  }
  main {
    padding: 12px 18px 36px;
  }
  .top-balance .tb-label {
    display: none;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .panel {
    padding: 20px 18px;
  }
  .row {
    grid-template-columns: 1fr;
  }
  
  /* Responsive Mobile Job Cards */
  table.jobs thead {
    display: none;
  }
  table.jobs, table.jobs tbody, table.jobs tr, table.jobs td {
    display: block;
    width: 100%;
  }
  table.jobs tr {
    border-bottom: 1px solid var(--line);
    padding: 14px 0;
  }
  table.jobs td {
    border: 0;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  table.jobs td::before {
    content: attr(data-label);
    color: var(--faint);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
  }
  table.jobs td.file {
    max-width: none;
    font-size: 16.5px;
    padding-bottom: 8px;
  }
  table.jobs td.file::before {
    content: none;
  }
  table.jobs td.job-actions-cell {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    white-space: normal;
  }
  table.jobs td.job-actions-cell::before {
    margin-right: auto;
  }
}

@media (max-width: 480px) {
  .stats {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .stat .value {
    font-size: 26px;
  }
  .big {
    font-size: 34px;
  }
  .hero-actions {
    flex-direction: column;
    width: 100%;
  }
  .hero-actions .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Voices: language filter + flag icon */
.voice-filter {
  border-radius: 14px;
  margin-bottom: 14px;
}

.voice-filter button {
  gap: 6px;
  padding: 6px 12px;
}

.voice-filter .flag-svg {
  width: 18px;
  height: 13px;
}

.voice-list .vflag {
  background: transparent;
}

.voice-list .vflag .flag-svg {
  width: 34px;
  height: 25px;
  border-radius: 4px;
}

.voice-filter .chip-count {
  font-size: 13.5px;
  opacity: 0.7;
}

/* Language picker: search over the 646 supported languages */
.lang-dropdown {
  max-height: 420px;
}

.lang-list {
  max-height: 300px;
  grid-template-columns: minmax(0, 1fr);   /* long subtitles must not widen the column */
}

.lang-option .lang-option-badge {
  flex-shrink: 0;
}

.lang-dropdown-header {
  display: grid;
  gap: 6px;
}

.lang-search {
  width: 100%;
}

.lang-option-name {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.lang-option-sub {
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-empty {
  padding: 10px 12px;
  margin: 0;
}

img.flag-svg {
  object-fit: cover;
}

.flag-none {
  background: var(--panel-2);
}

/* ---- review fixes 27/09 ---- */
/* The hidden radio of a .seg label was absolute against a far ancestor with width:100%
   (1440px on desktop) and stretched the page sideways. Pin it to its own label. */
.seg label {
  position: relative;
}

.seg input {
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
}

/* CSP (default-src 'self') blocks style="" attributes: these replace the ones app.js used to set */
.chart-hit {
  cursor: crosshair;
}

.bar-hit {
  cursor: pointer;
}

.tip-p1 {
  color: #3b82f6;
}

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

.demo-login-wrap {
  margin-top: 10px;
}

.demo-login-wrap .btn {
  margin-top: 0;
}

@media (max-width: 980px) {
  /* 1fr = minmax(auto, 1fr): wide content pushed panels past a 390px screen */
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .titles {
    flex: 1;
    min-width: 0;
  }
  .titles h1 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #page-sub {
    display: none;
  }
}

@media (max-width: 480px) {
  /* give the page title room: the balance keeps only its number */
  .top-balance .balance-icon,
  .top-balance .tb-unit {
    display: none;
  }
  .topbar {
    gap: 10px;
  }
}

.expire-note {
  display: block;
  margin-top: 4px;
}

/* ==========================================================================
   STUDIO VIEW REDESIGN (Tạo giọng đọc & Bảng danh sách file SRT với STT)
   ========================================================================== */
.form-section {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 6px 0 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--text);
}

.studio-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 16px;
  margin-bottom: 16px;
}

.studio-config-panel {
  background: var(--panel);
}

.studio-tips-panel {
  background: var(--panel-card);
  border: 1px solid var(--line);
}

/* Files Table Panel */
.studio-files-panel {
  margin-top: 24px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.studio-files-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.studio-files-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.studio-title-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  flex-shrink: 0;
}

.studio-title-badge svg {
  width: 20px;
  height: 20px;
}

.studio-files-title h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.studio-files-title p {
  margin: 2px 0 0;
}

.studio-files-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.studio-add-more-btn {
  cursor: pointer;
  background: var(--panel-2);
  border-color: var(--line-2);
}

.studio-add-more-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.danger-ghost:hover {
  color: var(--bad) !important;
  border-color: var(--bad-border) !important;
  background: var(--bad-soft) !important;
}

/* Studio Files Table */
.studio-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  margin-bottom: 20px;
}

table.studio-files-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  text-align: left;
}

table.studio-files-table th {
  background: var(--panel-card);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}

table.studio-files-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

/* Column Alignments & Sizing */
.th-check, .st-cell-check {
  width: 36px;
  text-align: center;
}

.th-check input, .st-cell-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.st-cell-check input:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

tr.selected td {
  background: var(--accent-soft);
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 14.5px;
}

.th-stt, .st-cell-stt {
  width: 60px;
  text-align: center;
}

.th-file, .st-cell-file {
  min-width: 220px;
  max-width: 320px;
}

.th-stats, .st-cell-stats {
  min-width: 140px;
}

.th-voice, .st-cell-voice {
  min-width: 180px;
}

.th-speed, .st-cell-speed {
  width: 100px;
}

.th-roles, .st-cell-roles {
  width: 120px;
  text-align: center;
}

.th-state, .st-cell-state {
  width: 130px;
  text-align: center;
}

.th-action, .st-cell-action {
  width: 60px;
  text-align: center;
}

/* STT Number Badge (Sequence number) */
.stt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  color: var(--accent);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .stt-badge {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #059669;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* File Info Cell */
.st-file-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.fr-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  padding: 3px 6px;
}

.st-file-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.st-file-name {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Stats Cell */
.st-stats-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.st-stat-cues {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}

.st-stat-chars {
  font-size: 13.5px;
  color: var(--muted);
}

.st-stat-emo {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-soft);
  padding: 1px 6px;
  border-radius: 4px;
  width: fit-content;
  margin-top: 2px;
}

/* Speed input cell */
.st-speed-wrap input {
  padding: 6px 8px;
  font-size: 14.5px;
  text-align: center;
  border-radius: 8px;
  font-weight: 600;
}

/* State Badge */
.fr-state {
  display: inline-block;
  font-size: 13.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.fr-state.ready {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.fr-state.scanning {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: var(--blue-border);
}

.fr-state.ok {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
  font-weight: 700;
}

.fr-state.err {
  background: var(--bad-soft);
  color: var(--bad);
  border-color: var(--bad-border);
}

/* Remove button */
.fr-remove {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  margin: 0 auto;
  transition: all var(--transition-fast);
}

.fr-remove:hover {
  color: var(--bad);
  border-color: var(--bad-border);
  background: var(--bad-soft);
}

/* Expandable Roles Subrow */
.fr-roles-tr {
  background: rgba(16, 185, 129, 0.025);
}

.fr-roles-container {
  padding: 14px 18px;
  border-radius: 10px;
  background: var(--panel-card);
  border: 1px dashed var(--line-2);
  margin: 4px 0 8px;
}

.fr-roles-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
}

.fr-roles-banner svg {
  width: 16px;
  height: 16px;
}

.fr-roles-table-grid {
  display: grid;
  gap: 8px;
}

.fr-role-item {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(200px, 2fr) 96px;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.fr-role-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.role-pill-badge {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 2px 8px;
  border-radius: 6px;
}

.fr-apply {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  margin-left: 4px;
}

.fr-role-item select,
.fr-role-item input {
  padding: 6px 10px;
  font-size: 14.5px;
  border-radius: 8px;
}

/* Studio Summary & Submit Bar */
.studio-summary-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.studio-summary-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.studio-summary-pill {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-2);
  padding: 6px 14px;
  border-radius: 999px;
}

.studio-summary-pill.warn {
  color: var(--warn);
  border-color: var(--warn-border);
  background: var(--warn-soft);
}

.studio-balance-pill {
  font-size: 14.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
}

.studio-balance-pill.ok {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.studio-balance-pill.short {
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid var(--bad-border);
}

.studio-submit-btn {
  padding: 10px 22px;
  font-size: 15.5px;
  font-weight: 600;
  border-radius: 10px;
}

/* ==========================================================================
   HISTORY VIEW REDESIGN (Stats Ribbon, Instant Search & STT table)
   ========================================================================== */
.history-panel {
  padding: 24px;
}

.history-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.history-title-wrap h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.history-title-wrap p {
  margin: 0;
}

.history-quick-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Stats Ribbon */
.history-stats-ribbon {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.h-stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--panel-card);
  border: 1px solid var(--line);
  transition: all var(--transition-fast);
}

.h-stat-card:hover {
  border-color: var(--line-2);
  background: var(--panel-card-hover);
}

.h-stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.h-stat-icon svg {
  width: 18px;
  height: 18px;
}

.icon-total {
  background: var(--panel-2);
  color: var(--text-dim);
  border: 1px solid var(--line);
}

.icon-running {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

.icon-done {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.icon-chars {
  background: var(--blue-soft);
  color: var(--blue);
  border: 1px solid var(--blue-border);
}

.h-stat-meta {
  display: flex;
  flex-direction: column;
}

.h-stat-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}

.h-stat-val {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.val-warn {
  color: var(--warn);
}

.val-ok {
  color: var(--accent);
}

/* History Toolbar: Filter tabs & Search box */
.history-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chip-count {
  font-size: 12.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  margin-left: 4px;
}

[data-theme="light"] .chip-count {
  background: rgba(0, 0, 0, 0.06);
}

.seg button.on .chip-count {
  background: var(--accent);
  color: var(--accent-contrast);
}

.history-dates {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 14.5px;
  color: var(--muted);
}

#h-from, #h-to {   /* ids: beat the global input:not(...) width: 100% */
  width: 140px;
}

.history-dates label {
  margin: 0;
}

.history-dl-name {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 14.5px;
  color: var(--muted);
}

#dl-name {   /* id: beats the global select width: 100% */
  width: auto;
}

.history-search-wrap {
  position: relative;
  width: 280px;
  max-width: 100%;
}

.history-search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

#history-search {
  padding: 8px 12px 8px 34px;
  font-size: 14.5px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  transition: all var(--transition-fast);
}

#history-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* History Table & Rows */
.history-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-card);
}

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

table.history-jobs-table th {
  background: var(--panel-2);
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}

table.history-jobs-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.history-time-text {
  font-size: 14.5px;
  color: var(--muted);
  white-space: nowrap;
}

.history-chars-cell {
  font-size: 15px;
  white-space: nowrap;
}

.status-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge-retry {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid var(--warn-border);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Table action buttons with icons */
.act-icon {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 14px;
}

.act-icon svg {
  width: 13px;
  height: 13px;
}

.act.act-warn {
  color: var(--warn);
  border-color: var(--warn-border);
}

.act.act-warn:hover {
  background: var(--warn-soft);
}

/* ZIP / WAV / SRT / Chạy lại / Xoá wrap inside the cell instead of scrolling the whole table */
.job-actions-cell {
  min-width: 200px;
}

.job-actions-cell .act {
  margin-block: 2px;
}

/* Responsive Breakpoints */
@media (max-width: 1100px) {
  .history-stats-ribbon {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 980px) {
  .studio-top-grid {
    grid-template-columns: 1fr;
  }
  .history-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .history-search-wrap {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .history-stats-ribbon {
    grid-template-columns: 1fr;
  }
  .fr-role-item {
    grid-template-columns: 1fr;
  }
}


/* History: what each job was set up with + countdown to the result purge */
.job-voice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: normal;
}

.job-voice .jv-main {
  color: var(--text-dim);
  font-weight: 600;
}

.job-voice .jv-meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.job-voice .jv-sep {
  color: var(--faint);
}

.job-voice .flag-svg {
  width: 16px;
  height: 12px;
  border-radius: 2px;
}

.job-roles {
  margin-top: 3px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: normal;
}

.job-roles summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  width: fit-content;
}

.job-roles ul {
  margin: 4px 0 0;
  padding-left: 16px;
}

.job-roles li strong {
  color: var(--text-dim);
}

.countdown {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.countdown.soon {
  color: var(--warn);
  font-weight: 600;
}

.countdown.urgent {
  color: var(--bad);
}

.expire-banner {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--warn-border);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 15px;
  font-weight: 600;
}

/* Voices tab: 4-column cards grid layout matching customer web spec */
.voices-full-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.vl-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}

.vl-title-group h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.vl-title-group p {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.vl-header-actions #btn-open-voice-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 8px;
}

.vl-header-actions #btn-open-voice-add svg {
  width: 16px;
  height: 16px;
}

/* Search bar & count display row */
.vl-toolbar-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vl-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.vl-search {
  position: relative;
  width: 360px;
  max-width: 100%;
}

.vl-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.vl-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  font-size: 15px;
  border-radius: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  outline: none;
  transition: all 0.15s ease;
}

.vl-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--panel);
}

.vl-count-display {
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Horizontal filter chips row */
.voice-filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-card);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.filter-chip:hover {
  border-color: var(--line-2);
  background: var(--panel-2);
}

.filter-chip .flag-svg {
  width: 17px;
  height: 12px;
  border-radius: 2px;
  object-fit: cover;
  flex-shrink: 0;
}

.filter-chip .chip-label {
  white-space: nowrap;
}

.filter-chip .chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--muted);
}

/* Active filter chip: Solid Blue matching target web screenshot */
.filter-chip.on {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.filter-chip.on:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.filter-chip.on .chip-count {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.vl-missing {
  margin: 0;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-left: 4px solid var(--warn);
  background: rgba(245, 158, 11, 0.06);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
}

/* Voice Cards: 4 Columns Responsive Grid */
.voice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  list-style: none;
  padding: 0;
  margin: 0;
}

@media (max-width: 1380px) {
  .voice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .voice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

/* Single Voice Card */
.voice-card {
  background: var(--panel-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 145px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
}

.voice-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-2);
  box-shadow: 0 4px 14px -2px rgba(15, 23, 42, 0.07);
}

[data-theme="dark"] .voice-card {
  background: #111a2e;
  border-color: rgba(255, 255, 255, 0.07);
}

[data-theme="dark"] .voice-card:hover {
  border-color: rgba(96, 165, 250, 0.35);
  box-shadow: 0 6px 20px -2px rgba(0, 0, 0, 0.4), 0 0 12px rgba(96, 165, 250, 0.08);
}

/* Card Header */
.vc-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.vc-flag {
  width: 36px;
  height: 25px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.vc-flag .flag-svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}

button.vc-flag-none {
  width: 36px;
  height: 25px;
  border: 1.5px dashed var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  border-radius: 4px;
  display: grid;
  place-items: center;
  padding: 0;
  transition: all 0.15s ease;
}

button.vc-flag-none::before {
  content: "";
  display: block;
  width: 14px;
  height: 14px;
  background-color: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='2' y1='12' x2='22' y2='12'/%3E%3Cpath d='M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='2' y1='12' x2='22' y2='12'/%3E%3Cpath d='M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z'/%3E%3C/svg%3E") no-repeat center / contain;
}

.vc-info-box {
  flex: 1;
  min-width: 0;
}

.vc-name {
  display: block;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
  letter-spacing: -0.15px;
}

.vc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.vc-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 550;
  padding: 1.5px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Country Tag: Amber / Orange Tint matching competitor */
.tag-country {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fef3c7;
}

[data-theme="dark"] .tag-country {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.25);
}

.tag-mini-flag {
  display: inline-flex;
  width: 14px;
  height: 10px;
  border-radius: 1px;
  overflow: hidden;
  flex-shrink: 0;
}

.tag-mini-flag .flag-svg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.vc-tag-dot.tag-dot-orange {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d97706;
  flex-shrink: 0;
}

/* Language Tag: Sky Blue Tint matching competitor */
.tag-lang {
  background: #f0f9ff;
  color: #0284c7;
  border: 1px solid #e0f2fe;
}

[data-theme="dark"] .tag-lang {
  background: rgba(14, 165, 233, 0.12);
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.25);
}

.tag-mini-icon {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  flex-shrink: 0;
}

/* Card Body: Italic quote clamped to 2 lines */
.vc-card-body {
  margin: 10px 0 12px;
  flex: 1;
}

.vc-ref {
  font-size: 13.5px;
  line-height: 1.5;
  font-style: italic;
  color: #64748b;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

[data-theme="dark"] .vc-ref {
  color: #94a3b8;
}

/* Card Footer: Play Button on left, Actions on right */
.vc-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.vc-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: 0;
  padding: 4px 6px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.vc-play-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.vc-play-btn.on {
  color: var(--accent);
  background: var(--accent-soft);
}

.vc-play-btn .play-icon {
  width: 12px;
  height: 12px;
  fill: currentColor;
  stroke: none;
}

.vc-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vc-actions .act {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 0;
  padding: 4px 6px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.vc-actions .act .act-icon {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.vc-actions .act-edit:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.vc-actions .act-delete:hover {
  color: var(--bad);
  background: var(--bad-soft);
}

/* Audio Player and Preview Controls */
.vc-player,
.vc-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  padding: 7px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin-top: 10px;
}

.vc-seek {
  flex: 1;
  min-width: 80px;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
  border-radius: 999px;
  outline: none;
}

.vc-seek:disabled {
  opacity: 0.35;
  cursor: default;
}

.vc-time {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  font-family: ui-monospace, Consolas, monospace;
  white-space: nowrap;
}

.vc-play-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.vc-play-sm:hover {
  transform: scale(1.06);
}

.vc-play-sm svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

#v-preview .vc-play-label {
  display: none;
}

.vc-check {
  font-size: 14px;
  font-weight: 600;
}

.vc-check.ok {
  color: var(--accent);
}

.vc-check.bad {
  color: var(--bad);
}

/* Modal Dialogs */
.ve-dialog {
  width: min(540px, calc(100vw - 32px));
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: 22px 24px;
  box-shadow: var(--shadow-lg);
  overflow: visible;
}

.ve-dialog::backdrop {
  background: rgba(2, 6, 23, 0.6);
  backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h3 {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

.dialog-header p {
  margin: 0;
}

.dialog-close-btn {
  background: transparent;
  border: 0;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  transition: color 0.15s ease;
}

.dialog-close-btn:hover {
  color: var(--text);
}

.ve-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

/* ==========================================================================
   BILLING VIEW & SUMMARY CARDS
   ========================================================================== */
.billing-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.billing-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition-fast);
}

.billing-card:hover {
  border-color: var(--line-2);
  transform: translateY(-1px);
}

.billing-card-body strong {
  display: block;
  font-size: 15.5px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 3px;
}

.billing-card-body p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

#tx td.link {
  color: var(--accent);
  font-weight: 650;
  font-family: ui-monospace, Consolas, monospace;
}

#tx td.nowrap {
  color: var(--faint);
  font-size: 14px;
  font-family: ui-monospace, Consolas, monospace;
}

/* ==========================================================================
   HIGH-END CUSTOM RANGE SLIDER (Slender Seekbars & Speed Controls)
   ========================================================================== */
/* High-End Clear Range Slider (Speed Slider & Custom Seekbars) */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  min-height: 0 !important;
  padding: 0 !important;
  margin: 4px 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  cursor: pointer;
  display: block;
  outline: none;
}

/* WebKit Track: Clean 6px track with dynamic accent progress fill */
input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--range-pct, 33.3%),
    rgba(15, 23, 42, 0.14) var(--range-pct, 33.3%),
    rgba(15, 23, 42, 0.14) 100%
  );
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: background 0.08s ease;
}

[data-theme="dark"] input[type=range]::-webkit-slider-runnable-track {
  background: linear-gradient(
    to right,
    #10b981 0%,
    #10b981 var(--range-pct, 33.3%),
    #25344d var(--range-pct, 33.3%),
    #25344d 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* WebKit Thumb: Tactile 16px knob with distinct emerald ring */
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.08);
  cursor: grab;
  margin-top: -5px;
  transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.12s ease;
}

input[type=range]:hover::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 2px 6px rgba(0, 0, 0, 0.25);
}

input[type=range]:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.25);
  box-shadow: 0 0 0 6px var(--accent-soft), 0 3px 8px rgba(16, 185, 129, 0.4);
}

/* Firefox Track */
input[type=range]::-moz-range-track {
  width: 100%;
  height: 6px;
  cursor: pointer;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.14);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] input[type=range]::-moz-range-track {
  background: #25344d;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

input[type=range]::-moz-range-progress {
  height: 6px;
  background: var(--accent);
  border-radius: 999px;
}

/* Firefox Thumb */
input[type=range]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: grab;
}

input[type=range]:hover::-webkit-slider-thumb {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

input[type=range]:focus-visible {
  outline: none;
}

input[type=range]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px var(--accent-border);
}

@media (max-width: 900px) {
  .billing-cards-grid {
    grid-template-columns: 1fr;
  }
}


/* ==========================================================================
   SOFT MEMPHIS REDESIGN (last on purpose: wins ties with the rules above)
   Modern Minimal SaaS surfaces + pastel geometry. All motion is slow and small;
   the prefers-reduced-motion rule above stops the CSS loops and app.js skips
   the waveform / parallax loops in that case.
   ========================================================================== */
html, body {
  background: var(--bg-gradient);
  background-attachment: fixed;
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(18px); }
}

@keyframes m-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-14px) rotate(8deg); }
}

@keyframes m-drift {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(10px, -8px); }
  66% { transform: translate(-8px, 6px); }
}

@keyframes m-spin {
  to { transform: rotate(360deg); }
}

@keyframes m-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14); opacity: 0.55; }
}

/* ------------------- Background geometry ------------------- */
/* --px/--py: pointer -1..1, --sy: scrollY (set by app.js). --z = depth: bigger moves more. */
.memphis {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: var(--deco-opacity);
  transition: opacity 0.6s ease;
}

body:has(#app-view:not([hidden])) .memphis {
  opacity: calc(var(--deco-opacity) * 0.6);
}

.memphis::before,
.memphis::after {
  content: "";
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  background: radial-gradient(var(--dot) 1.4px, transparent 1.9px) 0 0 / 22px 22px;
  -webkit-mask-image: radial-gradient(closest-side, #000, transparent);
  mask-image: radial-gradient(closest-side, #000, transparent);
  translate: calc(var(--px, 0) * 6px) calc(var(--py, 0) * 6px - min(var(--sy, 0), 1500) * 0.03px);
}

.memphis::before { top: -14vmax; left: -12vmax; }
.memphis::after { bottom: -18vmax; right: -14vmax; }

.m {
  --z: 1;
  position: absolute;
  translate: calc(var(--px, 0) * var(--z) * 14px) calc(var(--py, 0) * var(--z) * 14px - min(var(--sy, 0), 1500) * var(--z) * 0.06px);
}

svg.m {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
}

.m1 { --z: 0.7; top: 11%; left: 5%; width: 30px; height: 30px; color: var(--mint); animation: m-float 15s ease-in-out infinite; }
.m2 { --z: 1.1; top: 7%; left: 38%; width: 54px; height: 54px; color: var(--lav); animation: m-breathe 10s ease-in-out infinite; }
.m3 { --z: 1.4; top: 17%; right: 8%; width: 16px; height: 16px; border-radius: 50%; background: var(--peach); animation: m-float 12s -4s ease-in-out infinite; }
.m4 { --z: 0.9; bottom: 13%; left: 8%; width: 44px; height: 44px; color: var(--peach); animation: m-float 18s -6s ease-in-out infinite; }
.m5 { --z: 0.6; bottom: 8%; left: 36%; width: 96px; height: 24px; color: var(--sky); animation: m-drift 18s ease-in-out infinite; }
.m6 { --z: 0.45; top: 66%; left: 52%; width: 76px; height: 76px; color: var(--lav); background: radial-gradient(currentColor 2.2px, transparent 2.8px) 0 0 / 15px 15px; animation: m-drift 20s -6s ease-in-out infinite; }
.m7 { --z: 1.2; bottom: 20%; right: 11%; width: 24px; height: 24px; color: var(--lav); animation: m-spin 20s linear infinite reverse; }
.m8 { --z: 0.8; top: 58%; left: 2%; width: 70px; height: 70px; color: var(--mint); stroke-dasharray: 3 8; animation: m-spin 20s linear infinite; }
.m9 { --z: 0.5; top: 3%; right: 26%; width: 130px; height: 64px; color: var(--peach); animation: m-drift 22s ease-in-out infinite; }
.m10 { --z: 1.5; top: 45%; left: 47%; width: 16px; height: 16px; color: var(--sky); animation: m-float 11s -3s ease-in-out infinite; }
.m11 { --z: 0.6; bottom: 3%; right: 30%; width: 64px; height: 32px; border-radius: 64px 64px 0 0; background: var(--lav); opacity: 0.35; animation: m-breathe 12s -5s ease-in-out infinite; }
.m12 { --z: 1.3; top: 74%; right: 31%; width: 10px; height: 10px; border-radius: 50%; background: var(--mint); animation: m-breathe 7s ease-in-out infinite; }
.m13 { --z: 0.4; bottom: 2%; left: 3%; width: 90px; height: 90px; border-radius: 50%; color: var(--mint); animation: m-breathe 16s -4s ease-in-out infinite; }

/* faint diagonal hatching, faded at the edges */
.m9, .m13 {
  background: repeating-linear-gradient(-45deg, currentColor 0 2px, transparent 2px 11px);
  -webkit-mask-image: radial-gradient(closest-side, #000 40%, transparent);
  mask-image: radial-gradient(closest-side, #000 40%, transparent);
}

.login-page-wrap,
.shell {
  position: relative;
  z-index: 1;
}

/* ------------------- Login page ------------------- */
.login-page-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 32px;
}

.login-grid-container {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  max-width: 1120px;
  width: 100%;
  gap: 72px;
  align-items: center;
  margin: auto;
}

.login-showcase {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* staggered fade-up; replays whenever the view is shown again (display none -> block) */
.login-showcase > *,
.showcase-metrics > *,
.login-card-wrap {
  animation: fade-up 0.9s var(--ease-out) backwards;
}
.login-showcase > :nth-child(2) { animation-delay: 0.08s; }
.login-showcase > :nth-child(3) { animation-delay: 0.16s; }
.login-showcase > :nth-child(4) { animation-delay: 0.24s; }
.showcase-metrics > :nth-child(1) { animation-delay: 0.34s; }
.showcase-metrics > :nth-child(2) { animation-delay: 0.42s; }
.showcase-metrics > :nth-child(3) { animation-delay: 0.5s; }
.login-card-wrap { animation-delay: 0.18s; }

.showcase-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 6px 18px 6px 6px;
  margin-bottom: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.showcase-brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}

.showcase-brand .logo svg {
  width: 19px;
  height: 19px;
}

.showcase-brand strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.25;
}

.showcase-brand small {
  display: block;
  font-size: 13.5px;
  color: var(--muted);
}

.showcase-title {
  font-size: clamp(30px, 3.2vw, 42px);
  line-height: 1.16;
  font-weight: 750;
  letter-spacing: -0.035em;
  margin: 0 0 18px;
  color: var(--text);
  text-wrap: balance;
}

/* own block so balanced wrapping splits this line evenly instead of orphaning the last words */
.showcase-title .gradient-text {
  display: block;
  width: fit-content;
}

.gradient-text {
  background: linear-gradient(100deg, var(--accent) 0%, #0369a1 55%, #6d4fd0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .gradient-text {
  background-image: linear-gradient(100deg, #6ee7b7 0%, #7dd3fc 55%, #c4b5fd 100%);
}

.showcase-desc {
  font-size: 17px;
  line-height: 1.7;
  color: var(--muted);
  margin: 0 0 28px;
  max-width: 520px;
}

/* Live speech waveform: bars scroll right-to-left like a recording (app.js initSoundwave) */
.wave-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 520px;
  margin-bottom: 22px;
}

.wave-mic {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--mint-soft);
  color: var(--accent);
}

.wave-mic::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--mint);
  opacity: 0;
  animation: mic-ring 2.8s var(--ease-out) infinite;
}

@keyframes mic-ring {
  0% { transform: scale(0.9); opacity: 0.75; }
  100% { transform: scale(1.4); opacity: 0; }
}

.soundwave-container {
  flex: 1;
  min-width: 0;
  height: 56px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 86%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 86%, transparent);
}

.soundwave-strip {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 100%;
  will-change: transform;
}

.soundwave-bar {
  flex: 0 0 3px;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--sky) 0%, var(--mint) 50%, var(--lav) 100%);
  transform: scaleY(0.1);
}

.showcase-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 520px;
}

.metric-item {
  padding: 14px 16px 15px;
  border-radius: 16px;
  background: var(--tone-bg);
  border: 1px solid var(--line);
  transition: transform 0.5s var(--ease-out), box-shadow 0.5s var(--ease-out);
}

.metric-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.metric-item::before {
  content: "";
  display: block;
  width: 18px;
  height: 4px;
  border-radius: 4px;
  background: var(--tone);
  margin-bottom: 10px;
}

.tone-mint { --tone: var(--mint); --tone-bg: var(--mint-soft); }
.tone-lav { --tone: var(--lav); --tone-bg: var(--lav-soft); }
.tone-peach { --tone: var(--peach); --tone-bg: var(--peach-soft); }

.metric-item .metric-val {
  font-size: 24px;
  font-weight: 750;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.metric-item .metric-lbl {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-top: 5px;
}

/* Login card */
.login-card-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin-left: auto;
}

.card-deco {
  position: absolute;
  pointer-events: none;
  translate: calc(var(--px, 0) * -10px) calc(var(--py, 0) * -10px);
}

.card-deco-dots {
  top: -30px;
  right: -32px;
  width: 104px;
  height: 104px;
  color: var(--lav);
  opacity: 0.6;
  background: radial-gradient(currentColor 2px, transparent 2.6px) 0 0 / 16px 16px;
}

.card-deco-ring {
  bottom: -30px;
  left: -34px;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 2.5px solid var(--peach);
  opacity: 0.6;
  animation: m-breathe 9s ease-in-out infinite;
}

.login-card {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 34px 32px 28px;
  box-shadow: var(--shadow-lg);
}

/* Memphis colour stripe along the top edge */
.login-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 32px;
  right: 32px;
  height: 4px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, var(--mint) 0 25%, var(--sky) 25% 50%, var(--lav) 50% 75%, var(--peach) 75% 100%);
}

.login-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 26px;
}

.login-heading {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
}

.login-card-top p.muted {
  font-size: 15.5px;
  margin: 0;
  line-height: 1.5;
}

.login-card label {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .field-icon {
  position: absolute;
  left: 15px;
  z-index: 1;
  width: 18px;
  height: 18px;
  color: var(--faint);
  pointer-events: none;
  transition: color 0.2s ease;
}

.input-with-icon:focus-within .field-icon {
  color: var(--accent);
}

/* #login-form outranks the generic input:not(...) rule, which used to reset padding-left under the key icon */
#login-form .input-with-icon input {
  height: 48px;
  padding: 0 14px 0 44px;
  font-size: 16px;
  border-radius: 12px;
}

#login-form .input-with-icon input:focus {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.btn.login-submit-btn {
  margin-top: 16px;
  height: 48px;
  font-size: 16px;
  font-weight: 650;
  border-radius: 12px;
  gap: 8px;
}

.btn.login-submit-btn:not(:disabled):hover svg {
  transform: translateX(4px);
}

.login-footer {
  margin-top: 12px;
  padding-top: 18px;
  border-top: 1px dashed var(--line-2);
}

.support-badge {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--sky-soft);
  border-radius: 12px;
  font-size: 14.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

.support-badge svg {
  color: var(--blue);
  width: 17px;
  height: 17px;
  margin-top: 1px;
  flex-shrink: 0;
}

@media (max-width: 980px) {
  .login-page-wrap {
    align-items: flex-start;
    padding: 28px 20px 48px;
  }
  /* one column: brand + title, then the form, then the pitch */
  .login-grid-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 520px;
  }
  .login-showcase { display: contents; }
  .showcase-brand { order: 1; align-self: flex-start; margin-bottom: 22px; }
  .showcase-title { order: 2; }
  .login-card-wrap { order: 3; max-width: none; margin: 8px 0 36px; }
  .showcase-desc { order: 4; }
  .wave-card { order: 5; }
  .showcase-metrics { order: 6; }
  .card-deco-dots { right: -12px; }
  .card-deco-ring { left: -14px; }
}

@media (max-width: 480px) {
  .showcase-title { font-size: 30px; }
  .login-card { padding: 28px 20px 22px; border-radius: 20px; }
  .login-card::before { left: 20px; right: 20px; }
  #login-form .input-with-icon input { font-size: 18px; }   /* < 16px makes iOS zoom in */
  .showcase-metrics { gap: 8px; }
  .metric-item { padding: 12px; }
  .metric-item .metric-val { font-size: 20px; }
  .metric-item .metric-lbl { font-size: 12px; }
}

@media (max-width: 640px) {
  /* the page scrolls past fixed shapes on a phone: keep only the ones that stay clear of the text */
  .m1, .m4, .m5, .m6, .m7, .m9, .m10, .m11, .m13 { display: none; }
}

/* ------------------- App shell polish ------------------- */
/* Light, airy sidebar on the panel colour; the active page gets a soft teal fill plus a
   short indicator bar. Position/transform stay with the 860px drawer rules above. */
.sidebar {
  width: 248px;
  padding: 20px 16px 16px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.sidebar .brand {
  padding: 0 8px;
}

.sidebar .brand strong {
  font-size: 17px;
  letter-spacing: -0.01em;
}

.sidebar .brand small {
  font-size: 12.5px;
}

.sidebar nav {
  margin-top: 16px;
}

.nav-group {
  margin: 20px 12px 8px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  color: var(--faint);
}

.sidebar nav a {
  position: relative;
  gap: 12px;
  min-height: 40px;
  padding: 8px 12px;
  margin-bottom: 4px;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 550;
  color: var(--muted);
  transition: background-color var(--dur) var(--ease-out), color var(--dur-fast) ease;
}

.sidebar nav a svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.7;
  transition: transform var(--dur) var(--ease-out), color var(--dur-fast) ease;
}

.sidebar nav a:hover {
  background: var(--panel-2);
  color: var(--text);
}

.sidebar nav a:hover svg {
  transform: scale(1.05);
}

.sidebar nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.sidebar nav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform var(--dur) var(--ease-out);
}

.sidebar nav a.active::before {
  transform: scaleY(1);
}

.sidebar-foot {
  gap: 8px;
  padding: 12px 8px 0;
}

.brand .logo,
.avatar {
  border-radius: 12px;
}

.avatar {
  width: 36px;
  height: 36px;
  border: 0;
}

/* the hamburger only opens the mobile drawer: .icon-btn (later above) had re-shown it on desktop */
.icon-btn.menu-btn { display: none; }
@media (max-width: 860px) {
  .icon-btn.menu-btn { display: grid; }
}

/* Header: one compact row, balance reads as a live status pill */
.topbar {
  min-height: 64px;
  padding: 12px 32px;
  gap: 16px;
  backdrop-filter: blur(8px);
}

.titles h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.titles p {
  margin-top: 2px;
  font-size: 13px;
}

.topbar-actions {
  gap: 8px;
}

.top-balance {
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  box-shadow: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 550;
  transition: background-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}

.top-balance::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: m-breathe 4s ease-in-out infinite;
}

.top-balance:hover {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: var(--accent-border);
  transform: scale(1.03);
}

.top-balance .balance-icon {
  display: none;
}

.top-balance strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

main {
  padding: 32px 32px 48px;
}

@media (max-width: 860px) {
  .topbar { padding: 12px 16px; }
  main { padding: 16px 16px 40px; }
  .panel { padding: 20px 16px; }
}

/* Cards & panels: 16px corners, hairline border, barely-there shadow */
.panel {
  padding: 24px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease-out), border-color var(--dur) ease;
}

[data-theme="dark"] .panel {
  box-shadow: var(--shadow-sm);
}

.dash-main-chart-card:hover,
.dash-sub-chart-card:hover,
.dash-table-card:hover {
  box-shadow: var(--shadow-md);
}

.metric-card,
.billing-card,
.h-stat-card,
.voice-card {
  border-radius: 16px;
  transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), border-color var(--dur) ease;
}

.metric-card:hover,
.billing-card:hover,
.h-stat-card:hover,
.voice-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-2);
}

/* page switch: blocks fade up one after another (sections toggle display, so this replays per page) */
main > section > * {
  animation: fade-up 0.5s var(--ease-out) backwards;
}
main > section > :nth-child(2) { animation-delay: 0.05s; }
main > section > :nth-child(3) { animation-delay: 0.1s; }
main > section > :nth-child(4) { animation-delay: 0.15s; }
main > section > :nth-child(n+5) { animation-delay: 0.2s; }

.dash-metrics-grid > * {
  animation: fade-up 0.5s var(--ease-out) backwards;
}
.dash-metrics-grid > :nth-child(1) { animation-delay: 0.06s; }
.dash-metrics-grid > :nth-child(2) { animation-delay: 0.1s; }
.dash-metrics-grid > :nth-child(3) { animation-delay: 0.14s; }
.dash-metrics-grid > :nth-child(4) { animation-delay: 0.18s; }
.dash-metrics-grid > :nth-child(5) { animation-delay: 0.22s; }
.dash-metrics-grid > :nth-child(6) { animation-delay: 0.26s; }

/* ------------------- Controls: soft scale ------------------- */
.btn {
  border-radius: 10px;
  transition: transform var(--dur) var(--ease-out), background-color var(--dur-fast) ease, border-color var(--dur-fast) ease,
              color var(--dur-fast) ease, box-shadow var(--dur) var(--ease-out);
}

.btn.small {
  border-radius: 8px;
}

.btn svg,
.icon-btn svg {
  transition: transform 0.35s var(--ease-out);
}

.btn:not(:disabled):hover {
  transform: scale(1.03);
}

.btn:not(:disabled):active {
  transform: scale(0.97);
  transition-duration: 0.08s;
}

.btn.primary:not(:disabled):hover {
  box-shadow: var(--shadow-glow);
}

.icon-btn {
  border-radius: 10px;
  transition: transform var(--dur) var(--ease-out), background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.icon-btn:hover {
  transform: scale(1.04);
}

.icon-btn:active {
  transform: scale(0.94);
  transition-duration: 0.08s;
}

input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  border-radius: 10px;
}

input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=file]):focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* Reduced motion (also on when Windows "Show animations" is off) means less motion, not none:
   entrances become plain fades and hover feedback stays soft, while the background shapes hold
   still (the global rule above) and app.js skips the parallax. The waveform keeps running. */
@keyframes fade-in {
  from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .login-showcase > *,
  .showcase-metrics > *,
  .login-card-wrap,
  main > section > *,
  .dash-metrics-grid > * {
    animation-name: fade-in !important;
    animation-duration: 0.6s !important;
  }
  .wave-mic::after {
    animation-duration: 2.8s !important;
    animation-iteration-count: infinite !important;
  }
  .btn, .icon-btn, .metric-item, .metric-card, .billing-card, .h-stat-card, .voice-card {
    transition-duration: 0.25s !important;
  }
}

/* ==========================================================================
   PAGES: Studio, History, Voices, Billing, Docs and Login on the dashboard's
   design system (tokens, 4/8px spacing, 16px cards, teal-led colour).
   Last in the file on purpose: it restyles the older per-page layers above.
   ========================================================================== */

/* ---- Shared controls ---- */
input:not([type=range]):not([type=checkbox]):not([type=radio]):not([type=file]),
select,
.lang-trigger {
  min-height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
  border-radius: 10px;
  border-color: var(--line-2);
}

textarea {
  border-radius: 12px;
  padding: 12px;
  border-color: var(--line-2);
}

input[type=checkbox] {
  accent-color: var(--accent);
}

.btn {
  height: 40px;
  padding: 0 16px;
  font-size: 14px;
}

.btn.small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.icon-btn {
  width: 36px;
  height: 36px;
}

.icon-btn.refresh-btn {   /* matches the 42px segmented control beside it */
  width: 42px;
  height: 42px;
}

.act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border-color: var(--line-2);
  background: var(--panel);
  font-size: 13px;
  transition: transform var(--dur) var(--ease-out), background-color var(--dur-fast) ease,
              border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.act:not(:disabled):hover {
  transform: scale(1.03);
}

/* segmented radios/buttons (.seg): same quiet track + white chip as the dashboard filters */
.seg {
  padding: 4px;
  gap: 4px;
  border-radius: 12px;
  background: var(--track);
  box-shadow: none;
}

.seg button,
.seg label span {
  min-height: 32px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  transition: background-color var(--dur) var(--ease-out), color var(--dur-fast) ease, box-shadow var(--dur) var(--ease-out);
}

:root .seg button.on,
:root .seg input:checked + span {
  background: var(--panel);
  color: var(--accent);
  font-weight: 650;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 0 0 1px var(--line);
}

.preset-btn {
  height: 32px;
  border-radius: 8px;
  transition: transform var(--dur) var(--ease-out), background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.preset-btn:hover {
  transform: scale(1.03);
}

.preset-btn.on {
  color: var(--accent-contrast);
  box-shadow: var(--shadow-glow);
}

.label-with-output output {
  border-radius: 8px;
  font-size: 14px;
}

.drop-zone {
  padding: 16px;
  border-radius: 12px;
  border-color: var(--line-2);
  box-shadow: none;
}

.drop-content {
  gap: 16px;
}

.drop-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 0;
  background: var(--accent-soft);
  box-shadow: none;
}

.drop-icon svg {
  width: 18px;
  height: 18px;
}

.okmsg:empty {
  display: none;
}

/* ---- Headings: one scale for every page ---- */
.panel h2,
.history-title-wrap h2,
.vl-title-group h2,
.docs-hero h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.panel-title-wrap,
.docs-hero {
  margin-bottom: 24px;
}

.panel-title-wrap p,
.history-title-wrap p,
.vl-title-group p,
.docs-hero p {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}

/* ---- Tables: bordered 12px frame, soft header row ---- */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
}

th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--faint);
  background: var(--panel-2);
}

td {
  padding: 14px 16px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

table.history-jobs-table th,
table.studio-files-table th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-2);
  border-bottom-color: var(--line);
}

table.history-jobs-table td,
table.studio-files-table td {
  padding: 14px 16px;
}

.stt-badge {
  min-width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 0;
  background: var(--accent-soft);
  font-family: inherit;
  font-size: 13px;
  box-shadow: none;
}

/* ---- Studio ---- */
.studio-top-grid {
  gap: 24px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 16px;
}

.tips {
  padding: 24px;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

:root .tips {
  box-shadow: var(--shadow-sm);
}

.tips::before {
  display: none;
}

.tips-header {
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 16px;
}

.tips-header h2 {
  font-size: 16px;
  font-weight: 650;
}

.tips-icon {
  width: 20px;
  height: 20px;
}

.tips-list {
  gap: 16px;
}

.tips-list li {
  padding-left: 40px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.tips-list li::before {
  content: counter(tip-counter);
  top: 0;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.tips-list > li > strong {
  font-size: 14px;
  margin-bottom: 2px;
}

.studio-files-panel {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
}

.studio-files-head {
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.studio-title-badge {
  border: 0;
  border-radius: 12px;
}

.studio-files-title h3 {
  font-size: 16px;
  font-weight: 650;
}

.studio-table-wrap {
  background: var(--panel);
  margin-bottom: 16px;
}

.fr-toggle {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease, border-color var(--dur-fast) ease;
}

.fr-toggle:hover,
.fr-toggle.on {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}

.studio-summary-bar {
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--track);
}

.studio-summary-pill,
.studio-balance-pill {
  font-size: 13.5px;
  padding: 6px 14px;
}

.studio-submit-btn {
  height: 44px;
  padding: 0 24px;
  font-size: 15px;
}

/* ---- History ---- */
.history-top-bar {
  margin-bottom: 24px;
}

.history-stats-ribbon {
  gap: 16px;
  margin-bottom: 24px;
}

.h-stat-card {
  gap: 16px;
  padding: 16px 20px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}

.h-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 0;
}

.h-stat-icon svg {
  width: 20px;
  height: 20px;
}

.icon-total { background: var(--tone-blue-soft); color: var(--tone-blue); border: 0; }
.icon-running { background: var(--tone-orange-soft); color: var(--tone-orange); border: 0; }
.icon-done { background: var(--tone-teal-soft); color: var(--tone-teal); border: 0; }
.icon-chars { background: var(--tone-violet-soft); color: var(--tone-violet); border: 0; }

.h-stat-label {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 600;
}

.h-stat-val {
  font-size: 24px;
  letter-spacing: -0.02em;
}

.val-warn { color: var(--tone-orange); }

.history-toolbar {
  gap: 12px 16px;
}

.history-dates,
.history-dl-name {
  font-size: 13.5px;
  gap: 8px;
}

.history-search-wrap {
  width: 300px;
}

#history-search {
  border-radius: 10px;
  font-size: 14px;
}

.bulk-bar {
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.expire-banner {
  border-radius: 12px;
  font-size: 14px;
}

/* ---- Voices ---- */
.voices-full-panel {
  gap: 16px;
}

#btn-open-voice-add {
  height: 40px;
  padding: 0 16px;
  font-size: 14px;
  border-radius: 10px;
}

#voice-search {
  padding-left: 36px;   /* id: the global input rule above out-ranks .vl-search input and hid the icon's room */
  border-radius: 10px;
  font-size: 14px;
}

.filter-chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border-color: var(--line-2);
  background: var(--panel);
  font-size: 13.5px;
  box-shadow: none;
  transition: background-color var(--dur-fast) ease, border-color var(--dur-fast) ease, color var(--dur-fast) ease,
              transform var(--dur) var(--ease-out);
}

.filter-chip:hover {
  transform: scale(1.03);
}

.filter-chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}

.filter-chip.on:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.vl-missing {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  border-left: 3px solid var(--tone-orange);
  background: var(--tone-orange-soft);
  font-size: 14px;
}

.voice-grid {
  gap: 16px;
}

:root .voice-card {
  padding: 20px;
  min-height: 168px;
  background: var(--panel);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}

:root .voice-card:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-md);
}

.vc-flag,
button.vc-flag-none {
  width: 40px;
  height: 28px;
  border-radius: 6px;
}

.vc-name {
  font-size: 15px;
  margin-bottom: 8px;
}

.vc-tag {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

:root .tag-country { background: var(--tone-orange-soft); color: var(--tone-orange); border-color: transparent; }
:root .tag-lang { background: var(--tone-blue-soft); color: var(--tone-blue); border-color: transparent; }
.vc-tag-dot.tag-dot-orange { background: currentColor; }

:root .vc-ref {
  color: var(--muted);
}

.vc-card-body {
  margin: 12px 0 16px;
}

.vc-card-foot {
  padding-top: 12px;
}

.vc-play-btn {
  height: 32px;
  padding: 0 14px;
  gap: 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13.5px;
  transition: background-color var(--dur-fast) ease, transform var(--dur) var(--ease-out);
}

.vc-play-btn:hover {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  transform: scale(1.04);
}

.vc-actions .act {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
}

/* ---- Billing ---- */
.billing-cards-grid {
  gap: 16px;
  margin-bottom: 24px;
}

.billing-card {
  --tone: var(--tone-teal);
  --tone-soft: var(--tone-teal-soft);
  position: relative;
  overflow: hidden;
  gap: 16px;
  padding: 20px;
  border-radius: 16px;
}

.billing-card .card-header-pill {
  margin-bottom: 0;
}

.billing-card-body strong {
  font-size: 16px;
  margin-bottom: 4px;
}

.billing-card-body p {
  font-size: 13.5px;
  line-height: 1.55;
}

/* app.js puts class "link" on the credits cell: .link is inline-flex, which broke the row borders */
#tx td.link {
  display: table-cell;
  font-family: inherit;
  font-weight: 700;
}

#tx td.nowrap {
  font-family: inherit;
  color: var(--muted);
}

/* ---- API Docs ---- */
.docs-intro {
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 14.5px;
  margin-bottom: 32px;
}

.docs-intro p,
.doc-section > p {
  max-width: 88ch;   /* ~75-90 chars per line reads far easier than the full 1100px */
}

.doc-section {
  margin-bottom: 32px;
  padding-bottom: 32px;
}

.doc-header {
  margin-bottom: 12px;
}

.doc-header h3 {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.copy-code-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--panel);
  font-size: 13px;
  box-shadow: none;
  transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease, border-color var(--dur-fast) ease,
              transform var(--dur) var(--ease-out);
}

.copy-code-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
  transform: scale(1.03);
  box-shadow: none;
}

/* ---- Login ---- */
.login-card {
  border-radius: 20px;
}

.login-card::before {
  background: var(--accent);   /* one teal accent line instead of four pastel bands */
}

@media (max-width: 1100px) {
  .history-stats-ribbon {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  /* 1fr = minmax(auto, 1fr): the config panel's content pushed the page past a phone screen */
  .studio-top-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .history-search-wrap,
  .vl-search {
    width: 100%;
  }
  /* job rows become cards here: one divider per card, not per field */
  table.jobs tr {
    padding: 12px 16px;
  }
  table.jobs td,
  table.history-jobs-table td {
    padding: 6px 0;
    border-bottom: 0;
  }
}

@media (max-width: 640px) {
  .h-stat-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }
  .h-stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .h-stat-val {
    font-size: 20px;
  }
}
