:root {
  --bg: #0f1117;
  --surface: #171b24;
  --surface2: #1e2430;
  --border: rgba(255, 255, 255, 0.08);
  --fg: #f3f4f6;
  --muted: #9ca3af;
  --accent: #e85d04;
  --accent-soft: rgba(232, 93, 4, 0.15);
  --warn: #f59e0b;
  --ok: #22c55e;
  --radius: 14px;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(232,93,4,.12), transparent), var(--bg);
  color: var(--fg);
}

.shell { max-width: 1200px; margin: 0 auto; padding: 24px 20px 40px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card { width: min(420px, 100%); }
.login-card h1 { margin: 0 0 6px; font-size: 1.5rem; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--fg);
  margin-bottom: 14px;
}
button, .btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}
button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
}
button:disabled { opacity: .6; cursor: not-allowed; }
.err { color: #f87171; font-size: .9rem; min-height: 1.2em; margin-bottom: 8px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.topbar h1 { margin: 0; font-size: 1.35rem; }
.topbar .sub { color: var(--muted); font-size: .9rem; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metric {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.metric .n { font-size: 1.6rem; font-weight: 700; }
.metric .l { color: var(--muted); font-size: .82rem; }
.metric.warn .n { color: var(--warn); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-size: .88rem;
}
.tab.active { background: var(--accent-soft); border-color: color-mix(in oklch, var(--accent) 40%, transparent); color: #fff; }
.tab .badge {
  margin-left: 6px;
  background: var(--warn);
  color: #111;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: .75rem;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 14px;
  min-height: 520px;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.list { overflow: auto; max-height: 560px; }
.conv {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.conv:hover, .conv.active { background: rgba(255,255,255,.04); }
.conv .name { font-weight: 600; font-size: .95rem; }
.conv .preview { color: var(--muted); font-size: .82rem; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: .75rem; color: var(--muted); }
.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
}
.status.waiting { background: rgba(245,158,11,.2); color: var(--warn); }
.status.closed { background: rgba(156,163,175,.15); color: var(--muted); }
.status.other { background: rgba(34,197,94,.15); color: var(--ok); }

.thread { display: flex; flex-direction: column; min-height: 520px; }
.thread-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.messages {
  flex: 1;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .92rem;
  line-height: 1.45;
}
.bubble.in { align-self: flex-start; background: var(--surface2); border: 1px solid var(--border); }
.bubble.out { align-self: flex-end; background: linear-gradient(145deg, color-mix(in oklch, var(--accent) 90%, white), var(--accent)); color: #fff; }
.bubble .time { display: block; margin-top: 6px; font-size: .72rem; opacity: .75; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 40px 20px;
  font-size: .95rem;
}
.nota {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.25);
  color: #fcd34d;
  font-size: .86rem;
}