/* ==========================================================================
   Healthcare Evolutions · Voice Portal
   ========================================================================== */

:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;

  --primary: #0d9488;
  --primary-hover: #0f766e;
  --primary-soft: #ccfbf1;
  --primary-softer: #f0fdfa;
  --primary-text: #115e59;
  --focus-ring: 0 0 0 3px rgba(13, 148, 136, 0.25);

  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --info-text: #1e40af;
  --purple: #7c3aed;
  --purple-bg: #ede9fe;
  --purple-text: #5b21b6;
  --neutral: #64748b;
  --neutral-bg: #f1f5f9;
  --neutral-text: #475569;

  --sidebar-bg: linear-gradient(180deg, #0f3b3d 0%, #0a2a2c 100%);
  --sidebar-text: #d5ecea;
  --sidebar-muted: #8fb5b2;
  --hero-bg: radial-gradient(1200px 600px at -10% -10%, #14b8a6 0%, transparent 55%),
    radial-gradient(900px 500px at 110% 110%, #0ea5e9 0%, transparent 50%),
    linear-gradient(135deg, #0f3b3d 0%, #0b2f3a 100%);

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.18);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #111a2b;
    --surface-2: #0e1626;
    --surface-hover: #172338;
    --border: #1f2c42;
    --border-strong: #2c3c57;
    --text: #e5edf7;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;

    --primary: #14b8a6;
    --primary-hover: #2dd4bf;
    --primary-soft: rgba(20, 184, 166, 0.18);
    --primary-softer: rgba(20, 184, 166, 0.08);
    --primary-text: #5eead4;
    --focus-ring: 0 0 0 3px rgba(45, 212, 191, 0.3);

    --success-bg: rgba(34, 197, 94, 0.15);
    --success-text: #86efac;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --warning-text: #fcd34d;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --danger-text: #fca5a5;
    --info-bg: rgba(59, 130, 246, 0.15);
    --info-text: #93c5fd;
    --purple-bg: rgba(139, 92, 246, 0.18);
    --purple-text: #c4b5fd;
    --neutral-bg: rgba(148, 163, 184, 0.14);
    --neutral-text: #cbd5e1;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */

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

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

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

[hidden] {
  display: none !important;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 600;
}

h3 {
  font-size: 15px;
  font-weight: 600;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
}

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

.small {
  font-size: 12px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  display: inline-block;
  vertical-align: middle;
}

.icon-sm {
  width: 14px;
  height: 14px;
}

.icon-lg {
  width: 28px;
  height: 28px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(13, 148, 136, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-danger-outline {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-bg);
}

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

.btn-block {
  width: 100%;
}

.btn .spinner {
  display: none;
}

.btn.is-loading .spinner {
  display: inline-block;
}

.btn.is-loading .icon {
  display: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---------- Forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.field em {
  color: var(--danger);
  font-style: normal;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
}

input[type='text'],
input[type='password'],
input[type='tel'],
input[type='date'],
select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

input.is-invalid {
  border-color: var(--danger);
}

input:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
}

.input-group {
  position: relative;
}

.input-group input {
  padding-right: 44px;
}

.input-group .icon-btn {
  position: absolute;
  right: 3px;
  top: 3px;
}

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

.field-full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

/* ---------- Alerts ---------- */

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
}

.alert .icon {
  margin-top: 1px;
}

.alert > div {
  flex: 1;
  min-width: 0;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info-text);
}

/* ---------- Badges & chips ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-transform: capitalize;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-lg {
  padding: 6px 14px;
  font-size: 14px;
}

.tone-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.tone-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.tone-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.tone-info {
  background: var(--info-bg);
  color: var(--info-text);
}

.tone-purple {
  background: var(--purple-bg);
  color: var(--purple-text);
}

.tone-neutral {
  background: var(--neutral-bg);
  color: var(--neutral-text);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.chip.is-ok {
  border-color: transparent;
  background: var(--success-bg);
  color: var(--success-text);
}

.chip.is-missing {
  border-color: transparent;
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* Toggle chips (checkbox pills) */
.chip-toggle {
  position: relative;
  cursor: pointer;
  user-select: none;
}

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

.chip-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}

.chip-toggle span .icon {
  display: none;
}

.chip-toggle input:checked + span {
  border-color: var(--primary);
  background: var(--primary-softer);
  color: var(--primary-text);
}

.chip-toggle input:checked + span .icon {
  display: inline-block;
}

.chip-toggle input:focus-visible + span {
  box-shadow: var(--focus-ring);
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}

.card + .card {
  margin-top: 20px;
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 18px;
}

.card-header.row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-header p {
  font-size: 13px;
}

.stack > * + * {
  margin-top: 16px;
}

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

.grid-2 > .card + .card {
  margin-top: 0;
}

/* ---------- Login ---------- */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}

.auth-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  color: #e6fffb;
  background: var(--hero-bg);
  overflow: hidden;
}

.auth-hero::after {
  content: '';
  position: absolute;
  inset: auto -120px -160px auto;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 60px rgba(255, 255, 255, 0.03), 0 0 0 120px rgba(255, 255, 255, 0.02);
}

.auth-hero-copy {
  position: relative;
  z-index: 1;
  max-width: 460px;
}

.auth-hero h1 {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.auth-hero-copy > p {
  margin-top: 14px;
  font-size: 16px;
  color: rgba(230, 255, 251, 0.85);
}

.feature-list {
  list-style: none;
  margin: 32px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 500;
}

.feature-list .feature-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.auth-hero-foot {
  position: relative;
  z-index: 1;
  font-size: 12px;
  color: rgba(230, 255, 251, 0.6);
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-card h2 {
  font-size: 24px;
  font-weight: 700;
}

.auth-card .mobile-brand {
  display: none;
}

/* ---------- Brand ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, #14b8a6, #0ea5e9);
  box-shadow: 0 6px 16px rgba(20, 184, 166, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text small {
  font-weight: 500;
  font-size: 12px;
  opacity: 0.7;
}

/* ---------- App shell ---------- */

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 16px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.sidebar .brand {
  padding: 0 8px;
  color: #fff;
}

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

.nav-label {
  padding: 0 12px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

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

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-link.is-active {
  background: rgba(45, 212, 191, 0.16);
  color: #fff;
  box-shadow: inset 3px 0 0 #2dd4bf;
}

.nav-link:focus-visible {
  outline: 2px solid #2dd4bf;
  outline-offset: 2px;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.user-card strong {
  display: block;
  color: #fff;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card > div {
  min-width: 0;
}

.avatar {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  font-weight: 700;
  color: #0f3b3d;
  background: linear-gradient(135deg, #5eead4, #7dd3fc);
  text-transform: uppercase;
}

.role-badge {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  color: #0f3b3d;
  background: #99f6e4;
}

.role-badge.is-viewer {
  background: #fde68a;
}

.btn-sidebar {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--sidebar-text);
}

.btn-sidebar:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 32px 40px 48px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.page-header p {
  margin-top: 6px;
}

.view > * + * {
  margin-top: 20px;
}

/* ---------- Segmented control ---------- */

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.segmented-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

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

.segmented-btn.is-active {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.segmented-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---------- Live call status ---------- */

.call-status {
  min-height: 100%;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 260px;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--primary-softer);
  color: var(--primary);
}

.empty-state strong {
  color: var(--text);
  font-size: 15px;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--primary-text);
}

.pulse {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

.pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.5s ease-out infinite;
}

@keyframes pulse {
  from {
    transform: scale(1);
    opacity: 0.6;
  }
  to {
    transform: scale(2.8);
    opacity: 0;
  }
}

.steps {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 0;
}

.step {
  position: relative;
  display: flex;
  gap: 12px;
  padding-bottom: 18px;
  color: var(--text-subtle);
}

.step:last-child {
  padding-bottom: 0;
}

.step::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 24px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.step:last-child::before {
  display: none;
}

.step-dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
}

.step-dot .icon {
  width: 12px;
  height: 12px;
  display: none;
}

.step-body strong {
  display: block;
  font-weight: 600;
}

.step-body small {
  font-size: 12px;
}

.step.is-done {
  color: var(--text-muted);
}

.step.is-done::before {
  background: var(--primary);
}

.step.is-done .step-dot {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.step.is-done .step-dot .icon {
  display: block;
}

.step.is-active {
  color: var(--text);
}

.step.is-active .step-dot {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.step.is-active .step-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

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

.result-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.result-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 14px;
}

.result-icon .icon {
  width: 24px;
  height: 24px;
}

.result-head p {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
}

.detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
}

.detail-list dt {
  color: var(--text-muted);
}

.detail-list dd {
  margin: 0;
  font-weight: 500;
  word-break: break-word;
}

/* ---------- Transcript ---------- */

.transcript {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble small {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

.bubble-agent {
  align-self: flex-start;
  background: var(--surface-hover);
  border-bottom-left-radius: 4px;
}

.bubble-user {
  align-self: flex-end;
  background: var(--primary-soft);
  color: var(--primary-text);
  border-bottom-right-radius: 4px;
}

.transcript-plain {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 13px;
}

details.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

details.disclosure summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

details.disclosure summary::-webkit-details-marker {
  display: none;
}

details.disclosure summary .icon {
  transition: transform 0.15s;
}

details.disclosure[open] summary .icon {
  transform: rotate(180deg);
}

details.disclosure .disclosure-body {
  padding: 4px 14px 14px;
  max-height: 360px;
  overflow: auto;
}

/* ---------- Dropzone ---------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 20px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-softer);
}

.dropzone:focus-within {
  box-shadow: var(--focus-ring);
}

.dropzone .dropzone-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--primary);
}

.dropzone strong {
  color: var(--primary);
}

.dropzone.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.required-cols {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.file-info .file-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--success-bg);
  color: var(--success-text);
}

.file-info > div {
  flex: 1;
  min-width: 0;
}

.file-info strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Progress ---------- */

.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-hover);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #14b8a6, #0ea5e9);
  transition: width 0.4s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.progress-sm {
  height: 6px;
  margin-top: 4px;
}

/* ---------- Running batch banner ---------- */

.batch-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
  padding: 12px 16px;
  border: 1px solid var(--primary-soft);
  border-radius: var(--radius);
  background: var(--primary-softer);
  box-shadow: var(--shadow-sm);
}

.batch-banner-body {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.batch-banner-body strong {
  color: var(--primary-text);
}

.batch-banner-body .small {
  color: var(--text-muted);
}

/* The batch tab already shows the full progress card with its own Stop button. */
body[data-view='calls'][data-call-mode='batch'] .batch-banner {
  display: none;
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

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

.table th,
.table td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

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

.table tbody tr:hover td {
  background: var(--surface-2);
}

.table td.nowrap {
  white-space: nowrap;
}

.table td.truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table td.cell-wrap {
  min-width: 110px;
  max-width: 160px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.table td.cell-strong {
  font-weight: 600;
}

.table .empty-row td {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
}

.table-logs-wrap {
  max-height: 620px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination select {
  width: auto;
  height: 32px;
  padding: 0 8px;
}

/* ---------- Stats ---------- */

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

.stat {
  position: relative;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--stat-color, var(--primary));
}

.stat span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat small {
  font-size: 12px;
  color: var(--text-subtle);
}

/* ---------- Filters ---------- */

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

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

.multiselect {
  position: relative;
}

.multiselect-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.multiselect-toggle:focus-visible,
.multiselect.is-open .multiselect-toggle {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.multiselect-toggle span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multiselect-toggle .is-partial {
  color: var(--primary-text);
  font-weight: 600;
}

.multiselect-toggle .is-none {
  color: var(--danger);
  font-weight: 600;
}

.multiselect-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 320px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.multiselect-options {
  max-height: 240px;
  overflow: auto;
}

.multiselect-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.multiselect-option:hover {
  background: var(--surface-hover);
}

.multiselect-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multiselect-option.is-all {
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  margin-bottom: 4px;
}

.multiselect-empty {
  padding: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  flex: none;
}

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  animation: fade-in 0.15s ease;
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.18s ease;
}

.modal-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-dialog header p {
  margin-top: 2px;
  font-size: 12px;
}

.modal-body {
  padding: 20px;
  overflow: auto;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

/* ---------- Toasts ---------- */

.toasts {
  position: fixed;
  z-index: 60;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 40px));
}

.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--toast-color, var(--primary));
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: pop-in 0.18s ease;
}

.toast .icon {
  color: var(--toast-color, var(--primary));
}

.toast > div {
  flex: 1;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(-6px);
  transition: all 0.2s ease;
}

/* ---------- Responsive ---------- */

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

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

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

  .call-status {
    min-height: 0;
  }
}

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

  .sidebar {
    position: sticky;
    z-index: 30;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
  }

  .sidebar .brand-text small,
  .nav-label,
  .user-card > div {
    display: none;
  }

  .sidebar .brand {
    padding: 0;
  }

  .nav {
    flex-direction: row;
    flex: 1;
    justify-content: center;
  }

  .nav-link {
    padding: 8px 12px;
  }

  .nav-link.is-active {
    box-shadow: inset 0 -2px 0 #2dd4bf;
  }

  .sidebar-footer {
    margin-top: 0;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .user-card {
    padding: 0;
    background: none;
    border: 0;
  }

  .btn-sidebar .btn-label {
    display: none;
  }

  .btn-sidebar {
    width: 40px;
    padding: 0;
  }

  .main {
    padding: 24px 16px 40px;
  }

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

  .auth-hero {
    display: none;
  }

  .auth-card .mobile-brand {
    display: flex;
  }
}

@media (max-width: 640px) {
  .sidebar .brand-text,
  .nav-link span {
    display: none;
  }

  .nav-link .icon {
    width: 20px;
    height: 20px;
  }

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

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

  h1 {
    font-size: 20px;
  }

  .card {
    padding: 16px;
  }

  .segmented {
    display: flex;
  }

  .segmented-btn {
    flex: 1;
    justify-content: center;
  }

  .form-actions .btn {
    flex: 1;
  }
}

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