/* Copied from the CRM (crm/crm static/css/base.css sidebar-v2, racunoid app.css, skills/recipes).
   Graphite theme, Carbon for dark. Entity hues are the CRM's own (home/brand_colors.py). */
:root {
  --app-rail-width: 74px;
  --app-panel-width: 248px;
  --sidebar-width: calc(var(--app-rail-width) + var(--app-panel-width));

  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;

  --rail: #ffffff;
  --rail-hair: rgba(11, 31, 51, 0.10);
  --rail-ink: #0b1f33;
  --rail-ink-2: #33475b;
  --rail-muted: #5e7082;
  --rail-hover: rgba(11, 31, 51, 0.05);
  --rail-hover-strong: rgba(11, 31, 51, 0.09);
  --rail-active: color-mix(in srgb, var(--primary-color) 12%, var(--rail));
  --sidebar-bg: var(--rail);
  --sidebar-bg-hover: var(--rail-hover);
  --sidebar-bg-active: var(--rail-active);
  --sidebar-text: var(--rail-ink-2);
  --sidebar-text-strong: var(--rail-ink);
  --sidebar-text-muted: var(--rail-muted);
  --sidebar-border: var(--rail-hair);
  --sidebar-accent-bar: var(--primary-color);

  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --success-color: #10b981;
  --notice-color: #3b82f6;
  --danger-color: #ef4444;
  --btn-primary-bg: #4f46e5;
  --btn-primary-hover: #4338ca;
  --btn-primary-text: #ffffff;
  --shadow-ink: #0f172a;

  /* apps and nav items */
  --ent-transcribe: #0284C7;
  --ent-compare: #059669;
  --ent-audio: #2563EB;
  --ent-youtube: #E11D48;
  --ent-history: #8B5CF6;

  --err: #c42b1c;
  --err-bg: #fde4e0;
  --ground-alpha: 0.04;
}

/* -- THEME: Carbon Dark -- */
:root[data-theme="carbon"] {
  color-scheme: dark;
  --primary-color: #14b8a6;
  --primary-hover: #0d9488;
  --primary-light: #0a2e2a;
  --rail: #0a0a0c;
  --rail-hair: rgba(255, 255, 255, 0.08);
  --rail-ink: rgba(255, 255, 255, 0.96);
  --rail-ink-2: rgba(255, 255, 255, 0.82);
  --rail-muted: rgba(255, 255, 255, 0.45);
  --rail-hover: rgba(20, 184, 166, 0.10);
  --rail-hover-strong: rgba(255, 255, 255, 0.10);
  --rail-active: rgba(20, 184, 166, 0.18);
  --bg-primary: #0e0e10;
  --bg-secondary: #18181b;
  --bg-tertiary: #232327;
  --text-primary: #f4f4f5;
  --text-secondary: #b6b6bd;
  --text-muted: #8b8b93;
  --border-color: #2c2c31;
  --success-color: #34d399;
  --notice-color: #60a5fa;
  --danger-color: #f87171;
  --btn-primary-bg: #14b8a6;
  --btn-primary-hover: #0d9488;
  --btn-primary-text: #04201c;
  --shadow-ink: #000000;
  --err: #ff6b5b;
  --err-bg: #4a1d18;
  --ground-alpha: 0.06;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--text-primary);
  font: 14px/1.5 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
a { color: var(--primary-color); }

/* App ground: the CRM's tiled field behind the shell (base.css html.app-ground). A mask, so it
   takes each theme's ink. */
html { background-color: var(--bg-secondary); }
body { background-color: transparent; }
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  --ground-ink: var(--text-primary);
  background-image:
    radial-gradient(75% 75% at 100% 0%, var(--ground-ink) 0%, transparent 70%),
    radial-gradient(75% 75% at 0% 100%, var(--ground-ink) 0%, transparent 70%),
    radial-gradient(60% 60% at 0% 0%, color-mix(in srgb, var(--ground-ink) 80%, transparent) 0%, transparent 70%),
    radial-gradient(60% 60% at 100% 100%, color-mix(in srgb, var(--ground-ink) 80%, transparent) 0%, transparent 70%),
    linear-gradient(color-mix(in srgb, var(--ground-ink) 35%, transparent), color-mix(in srgb, var(--ground-ink) 35%, transparent));
  -webkit-mask-image: url("img/ground-tile.8e05198476c9.svg");
  mask-image: url("img/ground-tile.8e05198476c9.svg");
  -webkit-mask-size: 100px;
  mask-size: 100px;
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
  -webkit-mask-position: 100% 0;
  mask-position: 100% 0;
  opacity: var(--ground-alpha, 0.04);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }

/* ── Sidebar v2: app rail + contextual panel ────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: row;
}
.app-rail {
  flex-shrink: 0;
  width: var(--app-rail-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px 12px;
  border-right: 1px solid var(--sidebar-border);
}
.app-rail-brand { display: flex; margin-bottom: 8px; text-decoration: none; }
.brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.app-rail-brand:hover .brand-logo { transform: scale(1.05); }
.app-tile {
  position: relative;
  width: 100%;
  padding: 7px 2px 6px;
  border: 0;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: transparent;
  color: var(--sidebar-text-muted);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: color 0.14s ease, background-color 0.14s ease;
}
.app-tile i { font-size: 20px; line-height: 1; color: var(--app-color, currentColor); }
.app-tile:hover { color: var(--sidebar-text-strong); background: var(--sidebar-bg-hover); }
.app-tile:focus-visible { outline: 2px solid var(--primary-color); outline-offset: -2px; }
.app-tile.active { color: var(--sidebar-text-strong); background: var(--sidebar-bg-active); }
.app-tile.current { color: var(--sidebar-text-strong); background: color-mix(in srgb, var(--app-color) 14%, transparent); }
.app-tile.current::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--app-color);
}
.app-tile .sidebar-action-badge { position: absolute; top: 2px; right: 8px; }
.rail-foot {
  width: 100%;
  margin: auto 0 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.rail-foot form { width: 100%; display: grid; margin: 0; }
.rail-foot > .sidebar-quick-action { width: 100%; }
/* the toggle shows the theme it switches to */
[data-theme="carbon"] [data-icon-dark], :root:not([data-theme="carbon"]) [data-icon-light] { display: none; }
.sidebar-quick-action {
  position: relative;
  height: 34px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text-muted);
  background: color-mix(in srgb, var(--sidebar-text) 4%, transparent);
  font-size: 17px;
  cursor: pointer;
}
.sidebar-quick-action:hover { color: var(--sidebar-text-strong); background: var(--sidebar-bg-active); }

.app-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.sidebar-header {
  flex-shrink: 0;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  min-height: 70px;
}
.app-panel-title {
  flex: 1;
  min-width: 0;
  padding-left: 8px;
  color: var(--sidebar-text-strong);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0; }

/* only the open app's items */
.sidebar-v2 [data-app-owner], .sidebar-v2 [data-panel-title] { display: none; }
.sidebar-v2[data-app="transcribe"] [data-app-owner="transcribe"],
.sidebar-v2[data-app="compare"] [data-app-owner="compare"] { display: flex; }
.sidebar-v2[data-app="transcribe"] [data-panel-title="transcribe"],
.sidebar-v2[data-app="compare"] [data-panel-title="compare"] { display: block; }

.sidebar .nav-link {
  position: relative;
  color: var(--sidebar-text);
  font-weight: 500;
  padding: 0.6rem 1rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  margin: 2px 0.5rem;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  white-space: nowrap;
}
.sidebar .nav-link:hover { color: var(--sidebar-text-strong); background-color: var(--sidebar-bg-hover); }
.sidebar .nav-link.active { color: var(--sidebar-text-strong); background-color: var(--sidebar-bg-active); }
.sidebar .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background-color: var(--sidebar-accent-bar);
  border-radius: 0 2px 2px 0;
}
.sidebar .nav-link i { font-size: 1.1rem; width: 20px; flex-shrink: 0; }
.sidebar .nav-link:focus-visible { outline: 2px solid var(--primary-color); outline-offset: -2px; }

/* per-item hue, as with the CRM's item colours on */
.sidebar.item-colors-on .nav-link[data-model="audio"] { --nav-accent: var(--ent-audio); }
.sidebar.item-colors-on .nav-link[data-model="youtube"] { --nav-accent: var(--ent-youtube); }
.sidebar.item-colors-on .nav-link[data-model="history"] { --nav-accent: var(--ent-history); }
.sidebar.item-colors-on .nav-link[data-model="compare"] { --nav-accent: var(--ent-compare); }
.sidebar.item-colors-on .nav-link[data-model] i { color: var(--nav-accent); }
.sidebar.item-colors-on .nav-link[data-model]:hover { background-color: color-mix(in srgb, var(--nav-accent) 16%, transparent); }
.sidebar.item-colors-on .nav-link[data-model].active { background-color: color-mix(in srgb, var(--nav-accent) 20%, transparent); }
.sidebar.item-colors-on .nav-link[data-model].active::before { background-color: var(--nav-accent); }

.sidebar-action-badge {
  min-width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger-color) 78%, var(--shadow-ink));
  color: var(--btn-primary-text, #ffffff);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}
.sidebar-action-badge[hidden] { display: none; }

.sidebar-footer { flex-shrink: 0; padding: 0.4rem 0.5rem; border-top: 1px solid var(--sidebar-border); }
.sidebar-account-button {
  width: 100%;
  min-height: 42px;
  padding: 6px 7px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: color-mix(in srgb, var(--sidebar-text) 4%, transparent);
}
.u-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary-color);
  color: var(--btn-primary-text, #ffffff);
  font-size: 12px;
  font-weight: 700;
}
.sidebar-account-copy { min-width: 0; display: flex; flex: 1; flex-direction: column; line-height: 1.15; }
.sidebar-account-copy strong {
  overflow: hidden;
  color: var(--sidebar-text-strong);
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-topbar, .sidebar-overlay { display: none; }

/* Folded (the CRM default): only the rail is on screen. Hovering a tile peeks the panel
   as a card beside it, laid over the page so nothing reflows. */
.sidebar-v2.collapsed { width: var(--app-rail-width); overflow: visible; }
.sidebar-v2.collapsed .app-panel { display: none; }
.sidebar-v2.collapsed.is-peek .app-panel {
  display: flex;
  position: fixed;
  top: var(--peek-top, 8px);
  left: calc(var(--app-rail-width) + 6px);
  z-index: 1001;
  flex: none;
  width: 236px;
  max-height: calc(100vh - 16px);
  border: 1px solid var(--sidebar-border);
  border-radius: 12px;
  background: var(--sidebar-bg);
  box-shadow: 0 12px 36px color-mix(in srgb, var(--shadow-ink) 32%, transparent);
  overflow: visible;
  animation: peekSlide 130ms cubic-bezier(0.2, 0.75, 0.3, 1);
}
@keyframes peekSlide { from { transform: translateX(-12px); opacity: 0.35; } to { transform: none; opacity: 1; } }
/* rail and the gap to the card stay one hover target */
.sidebar-v2.collapsed.is-peek .app-panel::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -8px;
  width: 8px;
}
.sidebar-v2.collapsed.is-peek .sidebar-header { min-height: 0; padding: 10px 12px 4px; border-bottom: 0; }
.sidebar-v2.collapsed.is-peek .app-panel-title {
  padding-left: 0;
  color: var(--sidebar-text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.sidebar-v2.collapsed.is-peek .sidebar-nav { flex: 0 1 auto; padding: 2px 0 8px; }
.sidebar-v2.collapsed.is-peek .nav-link { padding: 7px 9px 7px 12px; gap: 9px; }

/* ── Main ────────────────────────────────────────────────── */
.main-content { margin-left: var(--app-rail-width); min-height: 100vh; }
.sidebar-v2:not(.collapsed) ~ .main-content { margin-left: var(--sidebar-width); }
.page { max-width: 1100px; margin: 0 auto; padding: 24px; }

.panel {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn i { font-size: 1.05rem; }
.btn-primary { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-primary:disabled { opacity: 0.7; cursor: progress; }
.btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }

.lv-cmd-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}
.lv-cmd-btn i { font-size: 15px; }
.lv-cmd-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.lv-cmd-btn.danger:hover { color: var(--danger-color); background: color-mix(in srgb, var(--danger-color) 10%, transparent); }

/* forms */
.form { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field-label--split { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.field-label label { cursor: pointer; }
input[type=url], input[type=text], input[type=password], textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
}
textarea { resize: vertical; min-height: 160px; font-size: 15px; line-height: 1.6; }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color) 18%, transparent);
}
.inline-field { position: relative; }
.inline-field i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--ent-youtube);
}
.inline-field input { padding-left: 38px; height: 40px; }

.drop {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 16px;
  border: 1.5px dashed var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop i { font-size: 22px; color: var(--ent-audio); }
.drop-main { font-weight: 600; color: var(--text-secondary); word-break: break-all; }
.drop:hover, .drop.over { border-color: var(--ent-audio); background: color-mix(in srgb, var(--ent-audio) 6%, var(--bg-primary)); }
.drop:focus-within { border-color: var(--primary-color); }
.drop.has-file { border-style: solid; border-color: var(--ent-audio); }
.drop.has-file .drop-main { color: var(--text-primary); }

.txt-pick {
  position: relative;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  color: var(--primary-color);
  cursor: pointer;
}
.txt-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.txt-pick:hover > span { text-decoration: underline; }
.form-foot { display: flex; align-items: center; gap: 16px; }

.alert {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  padding: 10px 14px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--danger-color) 10%, var(--bg-primary));
  border: 1px solid color-mix(in srgb, var(--danger-color) 35%, var(--border-color));
  overflow-wrap: anywhere;
}
.alert i { color: var(--danger-color); font-size: 1.15rem; margin-top: 1px; }

/* status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.status-pill--running {
  background: color-mix(in srgb, var(--notice-color) 14%, transparent);
  color: var(--notice-color);
}
.status-pill--done {
  background: color-mix(in srgb, var(--success-color) 14%, transparent);
  color: color-mix(in srgb, var(--success-color) 70%, var(--text-primary));
}
.status-pill--failed {
  background: color-mix(in srgb, var(--danger-color) 14%, transparent);
  color: var(--danger-color);
}

/* history table (rep-table) */
.rep-table-wrap {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}
.rep-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rep-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.rep-table td { padding: 8px 14px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.rep-table tr:last-child td { border-bottom: none; }
.rep-table tbody tr { position: relative; }
.rep-table tbody tr:hover { background: var(--bg-secondary); }
.rep-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rep-table .strong { font-weight: 700; }
.rep-table .empty-row td { text-align: center; color: var(--text-muted); padding: 32px; }
.rep-table tr.unseen { background: color-mix(in srgb, var(--primary-color) 6%, transparent); }
.rep-table tr.unseen .row-link { font-weight: 700; }
.name-wrap { display: flex; align-items: center; gap: 8px; }
.src-file { color: var(--ent-audio); font-size: 1.1rem; flex-shrink: 0; }
.src-yt { color: var(--ent-youtube); font-size: 1.15rem; flex-shrink: 0; }
.row-link { color: var(--text-primary); font-weight: 500; text-decoration: none; overflow-wrap: anywhere; }
.row-link::after { content: ''; position: absolute; inset: 0; }
.row-link:hover { color: var(--primary-color); }
.row-link:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.actions { width: 1%; }
.actions form { position: relative; z-index: 1; margin: 0; }
.row-action {
  border: 0;
  background: transparent;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
}
.row-action.danger:hover { color: var(--danger-color); background: color-mix(in srgb, var(--danger-color) 10%, transparent); }

/* job page */
.job-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.job-title { min-width: 0; flex: 1 1 320px; }
.job-head h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  gap: 8px;
}
.meta { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; color: var(--text-muted); font-size: 13px; }
.meta a { color: var(--text-muted); font-size: 15px; }
.meta a:hover { color: var(--primary-color); }
.cmd-bar { display: flex; gap: 2px; align-items: center; }
.cmd-bar form { margin: 0; }

.pending { padding: 20px 24px; }
.progress { height: 4px; border-radius: 999px; background: var(--bg-tertiary); overflow: hidden; }
.progress span {
  display: block;
  width: 30%;
  height: 100%;
  border-radius: inherit;
  background: var(--ent-transcribe);
  animation: indeterminate 1.4s ease-in-out infinite;
}
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(340%); } }

.metrics-strip { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.metric-card {
  flex: 1;
  min-width: 160px;
  max-width: 240px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px 20px;
}
.metric-value { font-size: 28px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.metric-value small { font-size: 15px; font-weight: 600; color: var(--text-muted); }
.metric-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-top: 6px; }
.metric-card.success .metric-value { color: var(--success-color); }
.metric-card.danger .metric-value { color: var(--danger-color); }

.transcript { padding: 20px 24px; font-size: 16px; line-height: 1.75; }
.transcript p { margin: 0 0 1em; }
.transcript p:last-child { margin-bottom: 0; }
:root { --spk-0: #0284C7; --spk-1: #E11D48; --spk-2: #059669; --spk-3: #8B5CF6; --spk-4: #DB2777; --spk-5: #0D9488; }
.turns { display: grid; gap: 14px; }
.turn { display: grid; grid-template-columns: 112px 1fr; gap: 16px; align-items: baseline; }
.turn p { margin: 0; }
.turn-who { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700;
  letter-spacing: .02em; color: var(--spk); white-space: nowrap; }
.turn-who::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--spk); flex: none; }

.diff { padding: 20px 24px; font: 19px/2.6 Georgia, "Times New Roman", serif; margin-bottom: 16px; }
.diff p { margin: 0 0 1.1em; }
.diff p:last-child { margin-bottom: 0; }
.diff mark {
  position: relative;
  color: var(--err);
  background: var(--err-bg);
  border-radius: 3px;
  padding: 0 2px;
}
.diff mark.ins { background: none; font-weight: 700; }
.diff .heard {
  position: absolute;
  left: 0;
  bottom: 100%;
  margin-bottom: 1px;
  white-space: nowrap;
  color: var(--err);
  font: 600 12px/1.2 ui-monospace, "DejaVu Sans Mono", monospace;
}
.transcript-raw summary { padding: 12px 20px; cursor: pointer; font-weight: 600; color: var(--text-secondary); }
.transcript-raw[open] summary { border-bottom: 1px solid var(--border-color); }
.transcript-raw .transcript { font-size: 15px; }

/* toasts */
.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}
.app-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--text-primary);
  color: var(--bg-primary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--shadow-ink) 22%, transparent);
  animation: toastIn 0.25s ease-out;
  overflow-wrap: anywhere;
}
.app-toast i { font-size: 18px; flex-shrink: 0; }
.app-toast--success i { color: var(--success-color); }
.app-toast--error i { color: var(--danger-color); }
a.app-toast:hover { background: color-mix(in srgb, var(--text-primary) 88%, var(--bg-primary)); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 340px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.login-brand { display: flex; justify-content: center; }
.login-logo { width: 96px; height: 96px; object-fit: contain; }
.btn-block { width: 100%; justify-content: center; }

/* ── Phone: sidebar slides in, as in the CRM ───────────── */
@media (max-width: 768px) {
  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 12px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--sidebar-border);
  }
  .mobile-title { font-weight: 700; font-size: 15px; }
  .icon-btn {
    border: 0;
    background: transparent;
    color: var(--sidebar-text);
    width: 36px;
    height: 36px;
    border-radius: 6px;
    font-size: 22px;
    display: grid;
    place-items: center;
    cursor: pointer;
  }
  .sidebar, .sidebar-v2.collapsed { width: var(--sidebar-width); overflow: hidden; transform: translateX(-100%); transition: transform 0.25s ease; z-index: 1200; max-width: 100vw; }
  .sidebar-v2.collapsed .app-panel { display: flex; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1150;
    background: color-mix(in srgb, var(--shadow-ink) 50%, transparent);
  }
  .main-content { margin-left: 0; }
  .page { padding: 16px; }
  .form, .transcript, .diff, .pending { padding: 16px; }
  .turn { grid-template-columns: 1fr; gap: 4px; }
  .diff { font-size: 17px; }
  /* history rows become blocks: name on top, facts underneath */
  .rep-table thead { display: none; }
  .rep-table, .rep-table tbody { display: block; }
  .rep-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 10px 12px; border-bottom: 1px solid var(--border-color); }
  .rep-table tbody tr:last-child { border-bottom: 0; }
  .rep-table td { display: block; padding: 0; border: 0; }
  .rep-table td.name-cell { flex: 1 1 calc(100% - 44px); min-width: 0; }
  .rep-table td.actions { order: 1; width: auto; }
  .rep-table td:not(.name-cell):not(.actions) { order: 2; font-size: 13px; }
  .rep-table td[data-label]::after { content: ' ' attr(data-label); color: var(--text-muted); font-weight: 400; }
  .rep-table .empty-row td { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .progress span, .bx-spin, .app-toast, .sidebar { animation: none !important; transition: none !important; }
}
