/* ── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0b0f1a;
  --surface:   #111827;
  --surface2:  #1a2235;
  --border:    #1f2d42;
  --border2:   #2a3a52;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --muted2:    #94a3b8;
  --accent:    #3b82f6;
  --accent2:   #1d4ed8;
  --success:   #22c55e;
  --warn:      #f59e0b;
  --danger:    #ef4444;
  --info:      #818cf8;
  --mono:      'IBM Plex Mono', monospace;
  --sans:      'IBM Plex Sans', system-ui, sans-serif;
  --radius:    10px;
  --radius-lg: 16px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }
.hidden { display: none !important; }
.muted  { color: var(--muted); }
.text-success { color: var(--success); }
.text-warn    { color: var(--warn); }
.text-danger  { color: var(--danger); }
.link-text { color: var(--accent); cursor: pointer; text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 56px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(11,15,26,.92);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.01em;
}

.logo-icon { font-size: 20px; color: var(--accent); }
.nav-hint  { font-size: 12px; color: var(--muted); }

.site-main   { flex: 1; padding: 2.5rem 1.5rem; max-width: 900px; margin: 0 auto; width: 100%; }
.site-footer { text-align: center; padding: 1.5rem; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
  font-family: var(--sans);
}

.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover  { background: var(--accent2); border-color: var(--accent2); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

.btn-secondary { background: transparent; color: var(--muted2); border-color: var(--border2); }
.btn-secondary:hover { border-color: var(--muted2); color: var(--text); }

.btn-ghost  { background: transparent; color: var(--muted); border: none; font-size: 13px; padding: 4px 8px; }
.btn-ghost:hover { color: var(--text); }

.btn-sm   { font-size: 12px; padding: 3px 8px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.btn-arrow { margin-left: 4px; }
.btn-clear { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 6px; }
.btn-clear:hover { color: var(--danger); }

/* ── Upload page ────────────────────────────────────────────────────────── */
.page-upload { max-width: 580px; margin: 0 auto; }

.upload-hero { text-align: center; margin-bottom: 2rem; }
.hero-title  { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 10px; }
.hero-sub    { color: var(--muted2); font-size: 15px; line-height: 1.7; }

.upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.drop-zone {
  border: 1.5px dashed var(--border2);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.drop-zone:hover, .drop-zone:focus { border-color: var(--accent); outline: none; }
.drop-zone.drag-over { border-color: var(--accent); background: rgba(59,130,246,.07); }

.drop-icon  { font-size: 36px; color: var(--muted); margin-bottom: 12px; display: block; }
.drop-label { font-size: 15px; color: var(--muted2); margin-bottom: 6px; }
.drop-hint  { font-size: 12px; color: var(--muted); }

.file-preview { margin-top: -6px; }
.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.file-icon { font-size: 20px; color: var(--accent); }
.file-meta { flex: 1; min-width: 0; }
.file-meta strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta .muted { font-size: 12px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; color: var(--muted2); }
.form-group input,
.form-group select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--accent); }

/* ── Progress card ──────────────────────────────────────────────────────── */
.progress-card {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.progress-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pipeline-steps { margin-bottom: 1.25rem; }

.step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
}

.step-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  background: transparent;
  flex-shrink: 0;
  margin-top: 4px;
  transition: background .3s, border-color .3s;
}

.step.active  .step-dot { border-color: var(--accent); background: var(--accent); animation: pulse 1.2s infinite; }
.step.done    .step-dot { border-color: var(--success); background: var(--success); animation: none; }
.step.error   .step-dot { border-color: var(--danger);  background: var(--danger); animation: none; }

@keyframes pulse { 0%,100% { opacity:1 } 50% { opacity:.35 } }

.step-body  { display: flex; flex-direction: column; gap: 2px; }
.step-label { font-size: 14px; color: var(--muted2); }
.step.active .step-label, .step.done .step-label { color: var(--text); }
.step-detail { font-size: 12px; }

.log-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.log-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.log-label { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.log-body {
  background: #070c14;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted2);
  padding: 10px 14px;
  height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.log-body .log-success { color: var(--success); }
.log-body .log-error   { color: var(--danger); }

.error-banner {
  margin-top: 1.25rem;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--danger);
  font-size: 14px;
}

/* ── Result page ────────────────────────────────────────────────────────── */
.page-result { max-width: 1000px; margin: 0 auto; }

.result-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.result-title { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.result-meta  { font-size: 13px; margin-top: 4px; }
.result-actions { display: flex; gap: 10px; flex-shrink: 0; align-items: center; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.kpi-val   { font-size: 26px; font-weight: 700; line-height: 1; }
.kpi-val small { font-size: 14px; font-weight: 400; color: var(--muted); }
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi-badge { font-size: 13px !important; padding: 4px 12px !important; }

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  align-items: start;
}

.result-col { display: flex; flex-direction: column; gap: 1.25rem; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.r-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}
.r-card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.r-body { font-size: 14px; line-height: 1.75; color: var(--muted2); }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { background: rgba(59,130,246,.12); color: #93c5fd; border-radius: 20px; font-size: 12px; padding: 3px 10px; }
.tag-muted { background: var(--surface2); color: var(--muted2); }

.intent-primary {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  text-transform: capitalize;
}

.dl-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 14px; align-items: start; }
.dl-list dt { color: var(--muted); white-space: nowrap; }
.dl-list dd { color: var(--text); }

.compliance-status { font-size: 20px; font-weight: 600; margin-bottom: 10px; }
.issue-list { list-style: none; }
.issue-list li { font-size: 13px; padding: 3px 0; }

/* ── Score ──────────────────────────────────────────────────────────────── */
.score-headline { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 1rem; }
.score-circle {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  flex-shrink: 0;
}
.score-good { border-color: var(--success); color: var(--success); }
.score-ok   { border-color: var(--warn);    color: var(--warn); }
.score-bad  { border-color: var(--danger);  color: var(--danger); }

.score-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.score-bar-label { font-size: 12px; color: var(--muted2); width: 110px; flex-shrink: 0; }
.score-bar-track { flex: 1; background: var(--surface2); border-radius: 4px; height: 5px; }
.score-bar-fill  { height: 5px; border-radius: 4px; transition: width .4s ease; }
.fill-good { background: var(--success); }
.fill-ok   { background: var(--warn); }
.fill-bad  { background: var(--danger); }
.score-bar-val { font-size: 12px; color: var(--muted2); width: 20px; text-align: right; }

.strengths-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.strengths-head { font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.bullet-list { list-style: none; }
.bullet-list li { font-size: 13px; color: var(--muted2); padding: 2px 0; }
.bullet-list li::before { content: '·  '; color: var(--muted); }

/* ── Key moments ────────────────────────────────────────────────────────── */
.moment-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.moment-time { font-size: 11px; color: var(--info); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; width: 60px; flex-shrink: 0; padding-top: 2px; }
.moment-text { font-size: 13px; color: var(--muted2); }

/* ── CES ────────────────────────────────────────────────────────────────── */
.ces-score { font-size: 36px; font-weight: 700; margin-bottom: 6px; }
.ces-score small { font-size: 16px; font-weight: 400; color: var(--muted); }

/* ── Transcript ─────────────────────────────────────────────────────────── */
.transcript-card { margin-bottom: 2rem; }
.transcript-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.transcript-body { max-height: 520px; overflow-y: auto; padding-right: 6px; display: flex; flex-direction: column; gap: 12px; }

.turn { max-width: 75%; }
.turn-agent    { align-self: flex-start; }
.turn-customer { align-self: flex-end; }

.turn-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.turn-speaker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  padding: 2px 8px;
  border-radius: 4px;
}
.turn-speaker-agent    { background: rgba(59,130,246,.15);  color: #93c5fd; }
.turn-speaker-customer { background: rgba(168,85,247,.15); color: #c084fc; }
.turn-time { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.turn-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted2);
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
}
.turn-customer .turn-text { background: rgba(168,85,247,.07); border-color: rgba(168,85,247,.2); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.badge-success { background: rgba(34,197,94,.15);  color: var(--success); }
.badge-warn    { background: rgba(245,158,11,.15); color: var(--warn); }
.badge-danger  { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge-info    { background: rgba(129,140,248,.15);color: var(--info); }
.badge-muted   { background: var(--surface2); color: var(--muted2); }

/* ── Error page ─────────────────────────────────────────────────────────── */
.page-error { text-align: center; padding: 5rem 1rem; }
.error-code { font-size: 60px; font-weight: 800; color: var(--border2); margin-bottom: 1rem; }
.error-msg  { color: var(--muted2); font-size: 16px; margin-bottom: 2rem; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .kpi-row     { grid-template-columns: repeat(3, 1fr); }
  .result-grid { grid-template-columns: 1fr; }
  .form-row    { grid-template-columns: 1fr; }
  .score-headline { flex-direction: column; }
  .strengths-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .site-main { padding: 1.5rem 1rem; }
}
