/* ============================================================
   Panel-Dashboard · Real Flow AI · v3 (preview)
   - Soporte dual: [data-theme="dark"] (default) + [data-theme="light"]
   - Tokens semánticos · cero hardcoded
   - Tipografía Inter · spacing/sombras refinadas
   ============================================================ */

* { box-sizing: border-box; }

html { color-scheme: dark light; }
html, body {
  margin: 0; padding: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-page);
  color: var(--text);
  transition: background-color 200ms ease, color 200ms ease;
}

:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

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

  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition:      200ms cubic-bezier(0.4, 0, 0.2, 1);

  --brand-orange:        #f97316;
  --brand-orange-bright: #fb923c;
  --brand-cyan:          #06b6d4;
  --brand-purple:        #8b5cf6;
}

[data-theme="dark"] {
  --bg-page:      #0a0e14;
  --bg-panel:     #11161e;
  --bg-subtle:    #161c25;
  --bg-elevated:  #1c2330;
  --bg-deep:      #060a10;
  --bg-hover:     #1f2733;

  --border:        #232a36;
  --border-soft:   #1a212c;
  --border-strong: #353e4d;
  --border-focus:  #f97316;

  --text:        #e6edf3;
  --text-strong: #ffffff;
  --text-muted:  #8b95a3;
  --text-dim:    #5d6772;

  --green:         #3fb950;
  --green-bright:  #56d364;
  --green-bg:      rgba(63, 185, 80, 0.12);
  --green-border:  rgba(63, 185, 80, 0.32);

  --amber:         #e3b341;
  --amber-bright:  #f1c75a;
  --amber-bg:      rgba(227, 179, 65, 0.12);
  --amber-border:  rgba(227, 179, 65, 0.32);

  --coral:         #da3633;
  --coral-bright:  #ff7b7b;
  --coral-bg:      rgba(218, 54, 51, 0.14);
  --coral-border:  rgba(218, 54, 51, 0.36);

  --orange:        #f97316;
  --orange-bright: #fb923c;
  --orange-bg:     rgba(249, 115, 22, 0.14);
  --orange-border: rgba(249, 115, 22, 0.36);

  --cyan:          #06b6d4;
  --cyan-bg:       rgba(6, 182, 212, 0.12);

  --purple:        #a78bfa;
  --purple-bg:     rgba(167, 139, 250, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow:    0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);

  --bar-bg: var(--bg-deep);
}

[data-theme="light"] {
  --bg-page:      #f7f8fa;
  --bg-panel:     #ffffff;
  --bg-subtle:    #f1f3f5;
  --bg-elevated:  #f7f8fa;
  --bg-deep:      #eceef1;
  --bg-hover:     #f1f3f5;

  --border:        #e4e7eb;
  --border-soft:   #ecedf1;
  --border-strong: #c1c7d0;
  --border-focus:  #f97316;

  --text:        #1a202c;
  --text-strong: #0d1117;
  --text-muted:  #5b6776;
  --text-dim:    #8b95a3;

  --green:         #16a34a;
  --green-bright:  #22c55e;
  --green-bg:      #ecfdf5;
  --green-border:  #a7f3d0;

  --amber:         #b45309;
  --amber-bright:  #d97706;
  --amber-bg:      #fffbeb;
  --amber-border:  #fcd34d;

  --coral:         #dc2626;
  --coral-bright:  #ef4444;
  --coral-bg:      #fef2f2;
  --coral-border:  #fecaca;

  --orange:        #ea580c;
  --orange-bright: #f97316;
  --orange-bg:     #fff7ed;
  --orange-border: #fed7aa;

  --cyan:          #0891b2;
  --cyan-bg:       #ecfeff;

  --purple:        #7c3aed;
  --purple-bg:     #f5f3ff;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow:    0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.18);

  --bar-bg: #eceef1;
}

a { color: var(--cyan); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--orange-bright); }

button { font-family: inherit; }

::selection { background: var(--orange); color: white; }

:where(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.dashboard { max-width: 1280px; margin: 0 auto; }

/* ===== TOPBAR ===== */
.topbar {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.brand { display: flex; align-items: center; gap: 10px; }

.av {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-orange), var(--brand-orange-bright));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  box-shadow: 0 2px 6px rgba(249, 115, 22, 0.35);
}

.bn {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.bs {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.topbar-right { display: flex; align-items: center; gap: var(--space-3); }

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--green);
  text-transform: uppercase;
  padding: 4px 10px;
  background: var(--green-bg);
  border-radius: var(--radius-pill);
  border: 1px solid var(--green-border);
}

.ld {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 0 6px var(--green);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* User chip (sesión activa + logout) */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  max-width: 220px;
}

.user-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.user-chip-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.user-chip-logout:hover {
  color: var(--coral);
  background: var(--coral-bg);
}

/* Theme toggle */
.theme-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: inline-block; }
[data-theme="light"] .theme-toggle .icon-sun  { display: inline-block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Period selector buttons */
.period-selector {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px;
}

.period-selector .db {
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.period-selector .db:hover { color: var(--text); }

.period-selector .db.on {
  background: var(--bg-panel);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ===== PANEL NAV ===== */
.panel-nav {
  display: flex;
  gap: 4px;
  margin: 16px 20px 0;
  padding: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: max-content;
}

.panel-nav-link {
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  text-decoration: none;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.panel-nav-link:hover { color: var(--text); background: var(--bg-hover); }

.panel-nav-link.on {
  background: var(--orange);
  color: white;
}
.panel-nav-link.on:hover { background: var(--orange-bright); color: white; }

/* ===== KPIs ===== */
.kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-3);
  padding: 20px;
}
.kpis-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) { .kpis, .kpis-4 { grid-template-columns: repeat(2, 1fr); } }

.kpi {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow); }

.kv {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-strong);
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kv.o { color: var(--orange); }
.kv.y { color: var(--amber); }
.kv.g { color: var(--green); }
.kv.r { color: var(--coral); }
.kv.p { color: var(--purple); }

.kl {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* ===== BODY ===== */
.body { padding: 4px 20px 20px; }

/* ===== CONTRACT BAR ===== */
.contract-bar {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.contract-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.progress-track {
  flex: 1;
  height: 10px;
  background: var(--bar-bg);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
  min-width: 200px;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: var(--radius-pill);
  transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1), background-color 400ms ease;
}

.progress-fill.warn { background: var(--amber); }
.progress-fill.crit { background: var(--coral); }

.progress-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 16px;
  background: var(--text-muted);
  left: 50%;
  border-radius: 1px;
}

.pct-value {
  font-size: 18px;
  font-weight: 700;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  text-align: right;
  color: var(--text-strong);
}

/* ===== TRIAGE ===== */
.triage {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 768px) { .triage { grid-template-columns: 1fr; } }

.tbox {
  border-radius: var(--radius-md);
  padding: 14px 16px 14px 20px;
  border: 1px solid;
  background: var(--bg-panel);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.tbox::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
}

.tbox.crit { border-color: var(--coral-border); }
.tbox.crit::before { background: var(--coral); }
.tbox.mod  { border-color: var(--amber-border); }
.tbox.mod::before  { background: var(--amber); }
.tbox.low  { border-color: var(--green-border); }
.tbox.low::before  { background: var(--green); }

.tnum {
  font-size: 30px;
  font-weight: 700;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.tnum.r { color: var(--coral); }
.tnum.y { color: var(--amber); }
.tnum.g { color: var(--green); }

.tlabel {
  font-size: 13px;
  color: var(--text);
  margin-top: 4px;
  font-weight: 500;
}

.tbadge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  margin-top: 8px;
  display: inline-block;
  font-weight: 500;
}

.tb-r { background: var(--coral-bg); color: var(--coral); }
.tb-y { background: var(--amber-bg); color: var(--amber); }
.tb-g { background: var(--green-bg); color: var(--green); }

/* ===== TOOLBAR (legacy) ===== */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

.tl-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
  display: flex;
  align-items: center;
  gap: 6px;
}

.bc {
  background: var(--coral);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.divider { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }

.filter-btns, .date-btns { display: flex; gap: 4px; }

.fb, .db {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.fb:hover, .db:hover { color: var(--text); border-color: var(--border-strong); }

.fb.on {
  background: var(--orange);
  color: white;
  border-color: var(--orange);
}

.date-group { display: flex; align-items: center; gap: 6px; }
.date-label { font-size: 13px; color: var(--text-dim); }
.spacer { flex: 1; }

.search {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  width: 220px;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-bg);
}

/* ===== PENDING TABLE (legacy) ===== */
.table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.thead {
  display: grid;
  grid-template-columns: 20px 200px 1fr 150px 80px 100px 100px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  align-items: center;
}

.th {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.row {
  display: grid;
  grid-template-columns: 20px 200px 1fr 150px 80px 100px 100px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--transition-fast);
}

.row:last-child { border-bottom: none; }
.row:hover { background: var(--bg-hover); }
.row.crit { border-left: 3px solid var(--coral); }
.row.mod  { border-left: 3px solid var(--amber); }
.row.low  { border-left: 3px solid var(--green); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dr { background: var(--coral); box-shadow: 0 0 6px var(--coral-border); }
.dy { background: var(--amber); }
.dg { background: var(--green); }

.cell-client { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cname { font-size: 14px; color: var(--text); font-weight: 600; }

.cnum {
  font-size: 12px;
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

.cmsg {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
  padding-right: 8px;
}

.tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  display: inline-block;
  font-weight: 500;
  white-space: nowrap;
}

.tag-r { background: var(--coral-bg); color: var(--coral); }
.tag-y { background: var(--amber-bg); color: var(--amber); }
.tag-g { background: var(--green-bg); color: var(--green); }

.ago {
  font-size: 12px;
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.actions { display: flex; gap: 4px; align-items: center; }

.btn-sm {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-muted);
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: all var(--transition-fast);
}

.btn-sm:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-hover); }

.btn-o {
  background: var(--orange);
  color: white;
  border-color: var(--orange);
}
.btn-o:hover { background: var(--orange-bright); color: white; border-color: var(--orange-bright); }

.btn-g {
  background: var(--bg-panel);
  border-color: var(--green-border);
  color: var(--green);
}
.btn-g:hover { background: var(--green-bg); color: var(--green); border-color: var(--green); }

/* ===== SECTION ===== */
.section { margin-bottom: var(--space-6); }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-3);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-title .count {
  background: var(--bg-elevated);
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-transform: none;
  letter-spacing: 0;
}

.see-all { font-size: 12px; color: var(--text-muted); }
.see-all a { color: var(--cyan); }

/* ===== CONV LIST ===== */
.conv-list {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.conv-item {
  background: var(--bg-panel);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-4);
  align-items: center;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-soft);
}

.conv-item:last-child { border-bottom: none; }

.conv-item.conv-pending { grid-template-columns: 12px 1fr auto auto auto; }

.conv-item .dot-wrap { display: flex; align-items: center; justify-content: center; }

.conv-item .name .cnum {
  font-weight: 400;
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  margin-left: 6px;
  font-size: 12px;
}

.see-more {
  text-align: center;
  padding: 14px;
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-soft);
}

.conv-item:hover { background: var(--bg-hover); }

.conv-item .name {
  font-weight: 600;
  color: var(--text-strong);
  font-size: 14px;
}

.conv-item .preview {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 600px;
}

.conv-item .status-tag {
  font-size: 10px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.conv-item .status-tag.active   { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.conv-item .status-tag.handoff  { background: var(--coral-bg); color: var(--coral); border: 1px solid var(--coral-border); }
.conv-item .status-tag.closed   { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border); }

.conv-item .ts {
  font-size: 11px;
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

/* ===== EMPTY / LOADING ===== */
.empty, .loading {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.empty .emoji {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.7;
}

/* ===== CONVERSATION DETAIL ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  margin: 16px 20px 0;
  font-weight: 500;
  transition: color var(--transition-fast);
}
.back-link:hover { color: var(--text); }

.conv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: var(--space-3);
  background: var(--bg-panel);
}

.conv-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.01em;
}

.conv-header small {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 3px;
}

.status-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-badge.ok      { background: var(--green-bg);  color: var(--green);  border-color: var(--green-border); }
.status-badge.warn    { background: var(--amber-bg);  color: var(--amber);  border-color: var(--amber-border); }
.status-badge.crit    { background: var(--coral-bg);  color: var(--coral);  border-color: var(--coral-border); }
.status-badge.neutral { background: var(--bg-elevated); color: var(--text-muted); border-color: var(--border); }

.message-thread {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: var(--shadow-sm);
}

.msg {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  max-width: 80%;
  font-size: 13.5px;
  line-height: 1.55;
  border: 1px solid transparent;
}

.msg.user {
  background: var(--bg-elevated);
  align-self: flex-start;
  border-color: var(--border);
  border-bottom-left-radius: 3px;
  color: var(--text);
}

.msg.assistant {
  background: var(--orange-bg);
  border-color: var(--orange-border);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
  color: var(--text);
}

.msg.human {
  background: var(--green-bg);
  border-color: var(--green-border);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
  color: var(--text);
}

.msg.system {
  background: var(--bg-subtle);
  align-self: center;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  max-width: 70%;
  text-align: center;
}

.msg .role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 700;
}

.msg .ts {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

/* ===== ESCALATION CARDS ===== */
.escalations { display: grid; gap: var(--space-3); }

.esc-card {
  background: var(--coral-bg);
  border: 1px solid var(--coral-border);
  border-left: 3px solid var(--coral);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.esc-card.handled {
  background: var(--bg-panel);
  border-color: var(--border);
  border-left-color: var(--green);
}

.esc-card .name { font-weight: 600; font-size: 14px; color: var(--text-strong); }
.esc-card .meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.esc-card .reason {
  display: inline-block;
  background: var(--coral-bg);
  color: var(--coral);
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 11px;
  margin-right: 6px;
  font-weight: 600;
  border: 1px solid var(--coral-border);
}

.esc-card .quote {
  margin: 10px 0 4px 0;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-left: 2px solid var(--coral);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 12.5px;
  font-style: italic;
  color: var(--text);
}

.section-title.urgent .count {
  background: var(--coral-bg);
  color: var(--coral);
  border-color: var(--coral-border);
}

/* Refresh button (conversation.html · inline styles override) */
#refresh-now {
  padding: 6px 12px !important;
  border-radius: var(--radius) !important;
  border: 1px solid var(--border) !important;
  background: var(--bg-elevated) !important;
  color: var(--text) !important;
  font-size: 12px !important;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
#refresh-now:hover {
  background: var(--bg-hover) !important;
  border-color: var(--border-strong) !important;
}
