/* ============================================================
   GreenUp.lt valdymo sąsaja - design system
   Light theme, brand-matched.
   ============================================================ */

/* ─── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
button { font: inherit; cursor: pointer; background: none; border: none; padding: 0; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
ul, ol { margin: 0; padding: 0; }

/* ─── Tokens ──────────────────────────────────────────────── */
:root {
  --primary: #5951EC;
  --primary-hover: #4338ca;
  --primary-soft: rgba(89, 81, 236, 0.08);
  --primary-soft-strong: rgba(89, 81, 236, 0.14);

  --bg-page: #f8f9fb;
  --bg-card: #ffffff;
  --bg-subtle: #f1f3f8;
  --bg-hover: #f5f7fb;

  --text: #0f172a;
  --text-strong: #020617;
  --text-muted: #64748b;
  --text-soft: #94a3b8;

  --border: #e6e8ef;
  --border-strong: #cbd5e1;

  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --success: #059669;
  --success-soft: #d1fae5;

  --slate-pill-bg: #f1f5f9;
  --slate-pill-text: #475569;

  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-card-hover: 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-pop: 0 12px 32px rgba(15, 23, 42, 0.12);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --nav-h: 64px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* ─── Base ────────────────────────────────────────────────── */
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* ─── Top nav ─────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topnav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.topnav-logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0;
  box-shadow: 0 4px 10px rgba(89, 81, 236, 0.25);
}
.topnav-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.topnav-brand-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.topnav-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.topnav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}
.topnav-links a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.topnav-links a:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.topnav-links a.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.topnav-spacer { flex: 1; }

.topnav-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--bg-subtle);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Container ───────────────────────────────────────────── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px;
}

/* ─── Page header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title {
  margin: 0 0 4px 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
}
.page-greeting {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 4px 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}
.back-link:hover { color: var(--primary); }

/* ─── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}
.card-flush { padding: 0; overflow: hidden; }

.card-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 14px 0;
}

/* ─── KPI / Stat grid ─────────────────────────────────────── */
/* Minutes balance banner (above stats) */
.minutes-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 20px 24px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(89,81,236,0.05), rgba(89,81,236,0.02));
  border: 1px solid rgba(89,81,236,0.18);
  margin-bottom: 24px;
}
.minutes-banner.warn {
  background: linear-gradient(135deg, rgba(217,119,6,0.06), rgba(217,119,6,0.02));
  border-color: rgba(217,119,6,0.25);
}
.minutes-banner.danger {
  background: linear-gradient(135deg, rgba(220,38,38,0.07), rgba(220,38,38,0.02));
  border-color: rgba(220,38,38,0.3);
}
.minutes-banner-left { display: flex; flex-direction: column; gap: 4px; min-width: 240px; }
.minutes-banner-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 1; max-width: 360px; }
.minutes-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--text-muted);
}
.minutes-icon svg { vertical-align: middle; }
.minutes-headline {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.minutes-remaining { font-size: 32px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; }
.minutes-of, .minutes-unit { font-size: 14px; color: var(--text-muted); font-weight: 500; }
.minutes-total { font-size: 18px; color: var(--text-primary); font-weight: 600; }
.minutes-sub { font-size: 13px; color: var(--text-muted); }
.minutes-bar {
  width: 100%;
  height: 8px;
  background: rgba(89,81,236,0.12);
  border-radius: 999px;
  overflow: hidden;
}
.minutes-banner.warn .minutes-bar { background: rgba(217,119,6,0.15); }
.minutes-banner.danger .minutes-bar { background: rgba(220,38,38,0.15); }
.minutes-bar-fill {
  height: 100%;
  background: var(--primary, #5951EC);
  transition: width 400ms ease;
}
.minutes-banner.warn .minutes-bar-fill { background: #d97706; }
.minutes-banner.danger .minutes-bar-fill { background: #dc2626; }
.minutes-pct {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
}
.minutes-banner.warn .minutes-pct { color: #92400e; }
.minutes-banner.danger .minutes-pct { color: #991b1b; }
@media (max-width: 720px) {
  .minutes-banner { flex-direction: column; align-items: stretch; gap: 16px; }
  .minutes-banner-right { max-width: 100%; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-grid-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
@media (max-width: 1180px) {
  .stat-grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  position: relative;
  transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow-card-hover); }
.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}
.stat-value.accent { color: var(--primary); }
.stat-value.danger { color: var(--danger); }
.stat-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat-icon.emerald { background: var(--success-soft); color: var(--success); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  transition: background 0.15s, border 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  cursor: pointer;
  line-height: 1.2;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { flex-shrink: 0; }

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

.btn-secondary {
  background: #fff;
  border-color: var(--border-strong);
  color: #334155;
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: #94a3b8;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-danger-outline {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}
.btn-danger-outline:hover:not(:disabled) {
  background: #fef2f2;
  border-color: #fca5a5;
}

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

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 6px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.btn-icon:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-icon-danger:hover:not(:disabled) {
  background: #fef2f2;
  color: var(--danger);
}
.btn-icon-primary:hover:not(:disabled) {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Pills ───────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill-slate {
  background: var(--slate-pill-bg);
  color: var(--slate-pill-text);
  border-color: #e2e8f0;
}
.pill-red {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}
.pill-amber {
  background: var(--warning-soft);
  color: #b45309;
  border-color: #fde68a;
}
.pill-emerald {
  background: var(--success-soft);
  color: var(--success);
  border-color: #a7f3d0;
}
.pill-purple {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(89, 81, 236, 0.2);
}

/* ─── Filter / toolbar ────────────────────────────────────── */
.toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.toolbar-spacer { flex: 1; }

/* ─── Inputs ──────────────────────────────────────────────── */
.input, .select, .textarea {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  color: var(--text);
  transition: border 0.15s, box-shadow 0.15s;
  width: 100%;
  max-width: 100%;
}
.textarea {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input::placeholder { color: var(--text-soft); }

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.input-with-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}
.input-with-icon svg {
  position: absolute;
  left: 11px;
  color: var(--text-soft);
  pointer-events: none;
}
.input-with-icon input {
  padding-left: 34px;
}

.label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-row { margin-bottom: 14px; }
.form-row:last-of-type { margin-bottom: 0; }
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.helper {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Segmented control ───────────────────────────────────── */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-subtle);
  border-radius: 9px;
  border: 1px solid var(--border);
}
.segmented button {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
  background: #fff;
  color: var(--text-strong);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

/* ─── Toggle switch ───────────────────────────────────────── */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text);
}
.toggle input { display: none; }
.toggle-slider {
  position: relative;
  width: 34px;
  height: 20px;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.18s;
  flex-shrink: 0;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(14px); }

/* ─── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
}
.table thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 12px 16px;
  background: #fafbfd;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr {
  transition: background 0.12s;
}
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--bg-hover); }

.table .cell-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.table .cell-stack .top {
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table .cell-stack .sub {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.table .actions {
  text-align: right;
  white-space: nowrap;
}
.table .actions > * + * { margin-left: 4px; }

.recording-row td {
  background: var(--bg-subtle);
  padding: 12px 16px;
}
.recording-row audio {
  width: 100%;
  max-width: 480px;
  height: 36px;
}

/* ─── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty-state .icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  margin: 0 auto 16px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state h3 {
  margin: 0 0 6px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}
.empty-state p {
  margin: 0 auto 18px auto;
  color: var(--text-muted);
  max-width: 420px;
  font-size: 13.5px;
}

/* ─── Loader ──────────────────────────────────────────────── */
.loader {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-pop);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.18s ease-out;
}
.modal-card.modal-sm { max-width: 400px; }
@keyframes popIn {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 8px 22px;
}
.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}
.modal-body {
  padding: 4px 22px 16px 22px;
  font-size: 13.5px;
  color: var(--text);
  overflow-y: auto;
}
.modal-body p { margin: 0 0 10px 0; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px 18px 22px;
  border-top: 1px solid var(--border);
  background: #fafbfd;
}

/* ─── Toast ───────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-pop);
  min-width: 220px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.18s ease-out;
}
@keyframes slideIn {
  from { transform: translateX(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.toast .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-soft);
  flex-shrink: 0;
}
.toast.success .dot { background: var(--success); }
.toast.error .dot { background: var(--danger); }
.toast.info .dot { background: var(--primary); }

/* ─── Tooltip / help ──────────────────────────────────────── */
.help {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  cursor: help;
}
.help:hover { color: var(--text); border-color: #94a3b8; }
.help-body {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 300px;
  background: var(--text-strong);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
  z-index: 30;
  text-align: left;
}
.help-body code {
  background: rgba(255, 255, 255, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: var(--font-mono);
}
.help:hover .help-body,
.help:focus .help-body {
  opacity: 1;
  visibility: visible;
  transform: none;
}

/* ─── Login page ──────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-page);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.06);
  padding: 40px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.login-logo .mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 6px 16px rgba(89, 81, 236, 0.3);
}
.login-logo .text {
  display: flex; flex-direction: column;
  line-height: 1.15;
}
.login-logo .name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}
.login-logo .sub {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.login-title {
  font-size: 20px;
  font-weight: 600;
  margin: 4px 0 8px 0;
  letter-spacing: -0.015em;
  color: var(--text-strong);
}
.login-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0 0 22px 0;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 44px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: #334155;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, border 0.15s;
}
.btn-google:hover {
  background: var(--bg-hover);
  border-color: #94a3b8;
}

.login-footer {
  margin-top: 22px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.55;
}
.login-footer code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ─── Call detail page ────────────────────────────────────── */
.call-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .call-grid { grid-template-columns: 1fr; }
}

.kv-list {
  display: flex;
  flex-direction: column;
}
.kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k {
  color: var(--text-muted);
  font-weight: 500;
}
.kv-row .v {
  color: var(--text);
  text-align: right;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kv-row .v.mono { font-family: var(--font-mono); font-size: 12.5px; }

.contact-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.contact-head .name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}
.contact-head .company {
  font-size: 13px;
  color: var(--text-muted);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  color: var(--text-soft);
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.copy-btn:hover { background: var(--bg-hover); color: var(--primary); }

/* recording player card */
.player-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #fafbfd, #f1f5fb);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}
.player-card .icon {
  width: 40px; height: 40px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.player-card .meta {
  flex: 1;
  min-width: 0;
}
.player-card .title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 4px;
}
.player-card audio {
  height: 36px;
  width: 100%;
  max-width: 100%;
}

/* audio player with speed controls */
.audio-player {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.audio-player audio {
  width: 100%;
  height: 38px;
}
.audio-speed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.audio-speed .speed-label {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  margin-right: 4px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 600;
}
.speed-btn {
  appearance: none;
  background: #fff;
  border: 1px solid var(--border, #e6e8ef);
  color: var(--text-primary, #0f172a);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  transition: all 120ms;
}
.speed-btn:hover {
  background: #f8f9fb;
  border-color: var(--primary, #5951EC);
  color: var(--primary, #5951EC);
}
.speed-btn.is-active {
  background: var(--primary, #5951EC);
  color: #fff;
  border-color: var(--primary, #5951EC);
}

/* transcript */
.transcript {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 4px 2px;
}
.transcript-turn {
  display: flex;
  flex-direction: column;
  max-width: 75%;
}
.transcript-turn.user { align-self: flex-start; }
.transcript-turn.assistant { align-self: flex-end; align-items: flex-end; }

.transcript-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.transcript-meta .who { color: var(--text); font-weight: 600; }
.transcript-meta .time { font-family: var(--font-mono); color: var(--text-soft); }

.transcript-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.transcript-turn.user .transcript-bubble {
  background: #f1f5f9;
  border-bottom-left-radius: 6px;
}
.transcript-turn.assistant .transcript-bubble {
  background: var(--primary-soft);
  border-bottom-right-radius: 6px;
}

/* function calls */
.fn-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fn-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.fn-item .icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.fn-item .icon.red { background: var(--danger-soft); color: var(--danger); }
.fn-item .icon.amber { background: var(--warning-soft); color: var(--warning); }
.fn-item .icon.emerald { background: var(--success-soft); color: var(--success); }
.fn-item .icon.slate { background: #fff; color: var(--text-muted); border: 1px solid var(--border); }

.fn-item .body { flex: 1; min-width: 0; }
.fn-item .name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-strong);
  margin-bottom: 2px;
}
.fn-item .detail {
  font-size: 12.5px;
  color: var(--text-muted);
}
.fn-item .time {
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-soft);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Hot leads grid ──────────────────────────────────────── */
.hot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 760px) {
  .hot-grid { grid-template-columns: 1fr; }
}
.hot-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px 20px;
  position: relative;
  transition: box-shadow 0.15s, transform 0.15s;
}
.hot-card:hover {
  box-shadow: var(--shadow-card-hover);
}
.hot-card .flame {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  display: flex; align-items: center; justify-content: center;
}
.hot-card .name {
  font-size: 15.5px;
  font-weight: 600;
  margin: 0 50px 2px 0;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}
.hot-card .company {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.hot-card .contact-line {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 12px;
}
.hot-card .contact-line .row {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.hot-card .summary {
  font-size: 13px;
  color: var(--text);
  margin: 10px 0 14px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.hot-card .timestamp {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.hot-card .actions {
  display: flex;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* count badge */
.count-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  margin-left: 10px;
  vertical-align: middle;
}

/* drawer */
.drawer-row {
  background: var(--bg-subtle);
}
.drawer-row td {
  padding: 18px 20px;
  border-top: 1px solid var(--border);
}
.drawer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 14px;
}
@media (max-width: 720px) {
  .drawer-grid { grid-template-columns: 1fr; }
}
.drawer-kv .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.drawer-kv .val {
  font-size: 13.5px;
  color: var(--text);
  word-break: break-word;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 760px) {
  .topnav { padding: 0 16px; gap: 14px; }
  .topnav-links { display: none; }
  .user-name { display: none; }
  .container { padding: 20px 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-grid-5 { grid-template-columns: repeat(2, 1fr); }
  .page-header { align-items: flex-start; }
}
