:root {
  --navy-900: #0B2545;
  --navy-800: #14315C;
  --navy-700: #1C3D70;
  --gold-500: #D4A24C;
  --gold-400: #E3B668;
  --gold-300: #EECB8F;
  --forest:   #2F7D5B;
  --forest-soft: #E4EFE8;
  --amber:    #C4861C;
  --amber-soft: #FAEFD7;
  --surface:  #FAFAF7;
  --paper:    #FFFFFF;
  --ink:      #1F2937;
  --mute:     #6B7280;
  --line:     rgba(11, 37, 69, 0.08);
  --line-strong: rgba(11, 37, 69, 0.16);
}

html, body {
  background: var(--surface);
  color: var(--ink);
  font-family: 'Geist', 'Manrope', system-ui, -apple-system, sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.font-display {
  font-family: 'Fraunces', 'Source Serif 4', Georgia, serif;
  font-feature-settings: "ss01";
}

.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Grain texture on navy panels ---------- */
.grain {
  position: relative;
  isolation: isolate;
}
.grain::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.85'/></svg>");
  z-index: 0;
}
.grain > * { position: relative; z-index: 1; }

/* ---------- Decorative hairline wave ---------- */
.hairline-wave {
  width: 100%;
  max-width: 340px;
  opacity: 0.35;
}

/* ---------- Inputs ---------- */
.field-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 500;
}
.field-input {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  padding: 10px 0;
  font-size: 16px;
  color: var(--ink);
  transition: border-color 0.2s ease;
}
.field-input:focus {
  outline: none;
  border-color: var(--navy-900);
}
.field-input::placeholder {
  color: #B7BEC7;
}

/* ---------- Primary button ---------- */
.btn-primary {
  background: var(--navy-900);
  color: #F9F6EE;
  padding: 14px 22px;
  border-radius: 2px;
  font-weight: 500;
  letter-spacing: 0.02em;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.2s ease, transform 0.15s ease;
  border: 1px solid var(--navy-900);
}
.btn-primary:hover { background: var(--navy-800); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 3px;
}

.btn-ghost {
  background: transparent;
  color: #F9F6EE;
  padding: 8px 16px;
  border: 1px solid rgba(249, 246, 238, 0.22);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.btn-ghost:hover { background: rgba(249, 246, 238, 0.08); border-color: rgba(249, 246, 238, 0.4); }
.btn-ghost:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 2px; }

/* ---------- Shake animation on bad login ---------- */
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97); }

/* ---------- Staggered reveal ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rise { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 340px;
  min-width: 340px;
  border-right: 1px solid var(--line);
  background: var(--paper);
  height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 22px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.search-wrap {
  position: relative;
}
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 10px 12px 10px 36px;
  border-radius: 2px;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.search-input:focus {
  outline: none;
  border-color: var(--navy-900);
  background: var(--paper);
}
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--mute);
}

.segmented {
  display: flex;
  gap: 4px;
  margin-top: 14px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.seg-btn {
  flex: 1;
  padding: 7px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--mute);
  border-radius: 1px;
  transition: background 0.2s ease, color 0.2s ease;
  letter-spacing: 0.02em;
}
.seg-btn[aria-pressed="true"] {
  background: var(--navy-900);
  color: #F9F6EE;
}
.seg-btn:hover:not([aria-pressed="true"]) { color: var(--ink); }

.call-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}
.call-row {
  display: grid;
  grid-template-columns: 3px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 22px 14px 19px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}
.call-row:hover { background: #FCFBF7; }
.call-row[aria-selected="true"] {
  background: #FCFAF2;
}
.call-row[aria-selected="true"]::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gold-500);
}
.call-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 0;
}
.call-row .name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.call-row .meta {
  font-size: 11px;
  color: var(--mute);
  margin-top: 2px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.call-row .score {
  font-size: 13px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.call-row .score small {
  color: var(--mute);
  font-weight: 400;
}

/* ---------- Main workspace ---------- */
.workspace {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px 72px;
  background:
    radial-gradient(ellipse 70% 40% at 100% 0%, rgba(212, 162, 76, 0.05), transparent 60%),
    var(--surface);
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow:
    0 1px 2px rgba(11, 37, 69, 0.03),
    0 8px 24px -12px rgba(11, 37, 69, 0.08);
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 500;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--line);
}
.category-badge.good { background: var(--forest-soft); color: #1E5A3F; border-color: transparent; }
.category-badge.bad  { background: #F4ECE0; color: #6B4A1A; border-color: transparent; }

/* ---------- Audio styling ---------- */
.audio-shell {
  padding: 26px 28px;
}
audio {
  width: 100%;
  height: 44px;
  filter: grayscale(0.05) contrast(1.02);
}
audio::-webkit-media-controls-panel {
  background: var(--surface);
}

/* ---------- Score strip ---------- */
.score-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 28px;
}
.score-big {
  font-size: 96px;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--navy-900);
  font-weight: 400;
}
.score-big small {
  font-size: 28px;
  color: var(--mute);
  letter-spacing: -0.02em;
  margin-left: 6px;
  font-weight: 300;
}
.score-pct {
  font-size: 14px;
  color: var(--mute);
  margin-top: 2px;
  letter-spacing: 0.02em;
}
.bar-track {
  height: 4px;
  background: var(--line);
  border-radius: 999px;
  margin-top: 18px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--navy-900), var(--navy-700));
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.stat-tile {
  border: 1px solid var(--line);
  padding: 18px 20px;
  border-radius: 2px;
  background: var(--surface);
}
.stat-tile .n {
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--navy-900);
  line-height: 1;
}
.stat-tile .l {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--mute);
  margin-top: 8px;
}

/* ---------- Scoring grid ---------- */
.scoring-table {
  width: 100%;
  border-collapse: collapse;
}
.scoring-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--paper);
}
.scoring-table tbody tr {
  border-bottom: 1px solid var(--line);
  transition: background 0.15s ease;
  border-left: 3px solid transparent;
}
.scoring-table tbody tr.achieved {
  border-left-color: var(--forest);
}
.scoring-table tbody tr:hover { background: #FCFBF7; }
.scoring-table tbody td {
  padding: 16px 20px;
  font-size: 14px;
  color: var(--ink);
  vertical-align: top;
}
.scoring-table .col-id {
  color: var(--mute);
  font-variant-numeric: tabular-nums;
  width: 48px;
  font-size: 12px;
}
.scoring-table .col-score {
  text-align: right;
  font-variant-numeric: tabular-nums;
  width: 110px;
  font-weight: 500;
}
.scoring-table .col-score small { color: var(--mute); font-weight: 400; }
.scoring-table .col-status {
  width: 140px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.pill-achieved { background: var(--forest-soft); color: #1E5A3F; }
.pill-missed   { background: #F2F2EF; color: var(--mute); }

/* ---------- Transcript ---------- */
.transcript-body {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 17px;
  line-height: 1.75;
  color: #2A3544;
  font-feature-settings: "ss01";
  white-space: pre-wrap;
  word-break: break-word;
}

.transcript-collapsed {
  max-height: 8.5em;
  overflow: hidden;
  position: relative;
  -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent);
  mask-image: linear-gradient(180deg, #000 60%, transparent);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--mute);
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--paper); }

/* ---------- Skeletons ---------- */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #EEEEEA 0%, #F7F6F1 50%, #EEEEEA 100%);
  background-size: 800px 100%;
  animation: shimmer 1.8s infinite linear;
  border-radius: 2px;
}

/* ---------- Empty state waveform ---------- */
.wave-empty {
  display: flex;
  align-items: end;
  gap: 4px;
  height: 56px;
}
.wave-empty span {
  display: block;
  width: 3px;
  background: var(--line-strong);
  border-radius: 2px;
  animation: waveRise 2.6s ease-in-out infinite;
}
@keyframes waveRise {
  0%, 100% { transform: scaleY(0.2); }
  50%      { transform: scaleY(1); }
}

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy-900);
  color: #F9F6EE;
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid rgba(249, 246, 238, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .middle {
  flex: 1;
  text-align: center;
  color: rgba(249, 246, 238, 0.85);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.topbar .middle .subtle { color: rgba(249, 246, 238, 0.45); letter-spacing: 0.14em; font-size: 10px; text-transform: uppercase; display: block; margin-bottom: 2px; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(212, 162, 76, 0.10), transparent 60%),
    radial-gradient(900px 600px at 0% 110%, rgba(212, 162, 76, 0.05), transparent 55%),
    linear-gradient(180deg, #0B2545 0%, #0A1F3B 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #FFFFFF;
  border-radius: 6px;
  padding: 48px 44px 40px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 30px 60px -20px rgba(0, 0, 0, 0.45),
    0 10px 24px -12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.login-mark {
  display: flex;
  justify-content: center;
}

.login-title {
  text-align: center;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--navy-900);
  margin-top: 28px;
}

.login-form {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-field > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--mute);
  letter-spacing: 0.02em;
}
.login-field > input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: #FAFAF7;
  border: 1px solid rgba(11, 37, 69, 0.12);
  border-radius: 4px;
  font-size: 15px;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}
.login-field > input:hover {
  border-color: rgba(11, 37, 69, 0.22);
}
.login-field > input:focus {
  outline: none;
  background: #FFFFFF;
  border-color: var(--navy-900);
  box-shadow: 0 0 0 3px rgba(11, 37, 69, 0.08);
}

.login-error {
  color: #9A2B2B;
  font-size: 13px;
  margin: -4px 0 -2px;
}

.login-btn {
  height: 46px;
  margin-top: 10px;
  background: var(--navy-900);
  color: #F9F6EE;
  border: 0;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
  font-family: inherit;
}
.login-btn:hover { background: #14315C; }
.login-btn:active { transform: translateY(1px); }
.login-btn:disabled { opacity: 0.65; cursor: not-allowed; }
.login-btn:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 3px;
}

/* ---------- Scrollbar restraint ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #DDD7C9; border-radius: 999px; border: 2px solid var(--surface); }
::-webkit-scrollbar-thumb:hover { background: #C9C1AF; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Focus outline for a11y ---------- */
:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
}
button, a, input { outline-offset: 2px; }

/* hide app until Alpine is ready */
[x-cloak] { display: none !important; }
