:root {
  --sab-blue: #004481;
  --sab-blue-dark: #00305a;
  --sab-blue-light: #0073cf;
  --sab-cyan: #49a5e6;
  --ok: #1a8f5a;
  --ok-bg: #e4f5ec;
  --bad: #d52b1e;
  --bad-bg: #fdeceb;
  --warn: #b8860b;
  --warn-bg: #fdf4e0;
  --ink: #1a2733;
  --muted: #6b7a89;
  --line: #e3e8ee;
  --bg: #f1f4f8;
  --white: #fff;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 48, 90, 0.10);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Inter", -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }

/* TOPBAR */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--sab-blue); color: #fff; padding: 14px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo-mark { width: 32px; height: 32px; border-radius: 50%; background: conic-gradient(from 180deg, #fff, var(--sab-cyan), #fff); }
.brand strong { font-size: 17px; display: block; }
.brand-sub { font-size: 12px; color: #cfe1f2; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.agent-badge { font-size: 12px; color: #cfe1f2; font-family: monospace; }

.btn { font-family: inherit; font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 8px; border: none; cursor: pointer; transition: .15s; }
.btn-primary { background: #fff; color: var(--sab-blue); }
.btn-primary:hover { background: #e8f1fb; }

.key-warning { background: var(--warn-bg); color: #7a5b00; padding: 12px 24px; font-size: 14px; border-bottom: 1px solid #f0dca0; }
.key-warning code { background: rgba(0,0,0,.07); padding: 1px 6px; border-radius: 4px; }

/* MÉTRICAS */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; padding: 20px 24px; }
.metric { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.metric-value { font-size: 26px; font-weight: 800; color: var(--sab-blue); display: block; }
.metric-label { font-size: 13px; color: var(--muted); }

/* LAYOUT */
.layout { display: grid; grid-template-columns: 1fr 1.1fr; gap: 16px; padding: 0 24px 24px; align-items: start; }

/* LISTA */
.list-panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-toolbar { display: flex; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.list-toolbar input, .list-toolbar select {
  font-family: inherit; font-size: 14px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
}
.list-toolbar input { flex: 1; }
.list-toolbar input:focus, .list-toolbar select:focus { outline: none; border-color: var(--sab-blue-light); }

.table-wrap { max-height: 70vh; overflow-y: auto; }
.calls-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.calls-table thead th {
  position: sticky; top: 0; background: #f7f9fc; text-align: left; font-size: 12px; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.calls-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.calls-table tbody tr { cursor: pointer; transition: background .12s; }
.calls-table tbody tr:hover { background: #f3f8fd; }
.calls-table tbody tr.active { background: #e8f1fb; }
.loading { text-align: center; color: var(--muted); padding: 30px; }

/* BADGES */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.badge.success { background: var(--ok-bg); color: var(--ok); }
.badge.failure { background: var(--bad-bg); color: var(--bad); }
.badge.unknown { background: #eef1f4; color: var(--muted); }

/* DETALLE */
.detail-panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); min-height: 60vh; }
.detail-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60vh; color: var(--muted); text-align: center; padding: 24px; }
.detail-empty-icon { font-size: 44px; margin-bottom: 12px; }
.detail-content { padding: 22px; }

.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.detail-head h2 { font-size: 18px; color: var(--sab-blue); }
.detail-id { font-family: monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 18px; margin: 14px 0 18px; font-size: 14px; }
.detail-meta div span { display: block; }
.detail-meta .dm-label { font-size: 12px; color: var(--muted); }
.detail-meta .dm-value { font-weight: 700; color: var(--ink); }

.detail-section { margin-top: 20px; }
.detail-section h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 10px; }

.summary-box { background: #f7f9fc; border: 1px solid var(--line); border-left: 3px solid var(--sab-blue-light); border-radius: 8px; padding: 14px; font-size: 14px; line-height: 1.55; }

/* SENTIMIENTO */
.sentiment-bar { display: flex; align-items: center; gap: 12px; }
.sentiment-meter { flex: 1; height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--bad), var(--warn), var(--ok)); position: relative; }
.sentiment-knob { position: absolute; top: -4px; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--sab-blue); transform: translateX(-50%); }
.sentiment-label { font-weight: 700; font-size: 14px; min-width: 90px; text-align: right; }

.topics { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-chip { background: #eef4fb; color: var(--sab-blue); font-size: 13px; font-weight: 600; padding: 5px 12px; border-radius: 999px; }

/* AUDIO */
audio { width: 100%; margin-top: 4px; }

/* TRANSCRIPCIÓN */
.transcript { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; padding-right: 6px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.msg .msg-role { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; opacity: .7; margin-bottom: 3px; }
.msg .msg-time { font-size: 11px; opacity: .55; margin-left: 6px; }
.msg.agent { align-self: flex-start; background: #eef4fb; color: var(--ink); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--sab-blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.tool { align-self: center; background: #f3f0e8; color: #8a6d3b; font-size: 12px; font-style: italic; }

.hidden { display: none !important; }
.error-box { background: var(--bad-bg); color: var(--bad); padding: 14px; border-radius: 8px; font-size: 14px; }

@media (max-width: 980px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .layout { grid-template-columns: 1fr; }
}
