:root {
  --bg: #f6f7f5;
  --panel: #ffffff;
  --ink: #18201d;
  --muted: #5d6a65;
  --line: #e3e7e4;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3f1;
  --warn: #b45309;
  --warn-soft: #fdf1e2;
  --bad: #b91c1c;
  --bad-soft: #fde8e8;
  --good: #15803d;
  --good-soft: #e3f5e8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 4px 16px rgba(16, 24, 20, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412; --panel: #171e1b; --ink: #e7ece9; --muted: #98a6a0; --line: #26302c;
    --accent: #2dd4bf; --accent-ink: #052e2a; --accent-soft: #123a35;
    --warn: #f59e0b; --warn-soft: #3a2a10; --bad: #f87171; --bad-soft: #3b1717;
    --good: #4ade80; --good-soft: #13321e; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.5 "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; font-weight: 700; }
.brand-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; }
.brand-dot::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent-ink); }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.nav a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 10px; border-radius: 8px; color: var(--ink); font-weight: 500;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav .count { font-size: 12px; background: var(--warn-soft); color: var(--warn); border-radius: 99px; padding: 0 8px; }
.side-foot { margin-top: auto; font-size: 13px; }
.main { padding: 28px 32px 60px; max-width: 1200px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.kpi .sub { font-size: 13px; color: var(--muted); }
.two { grid-template-columns: 1.4fr 1fr; }

.banner { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.good { background: var(--good-soft); color: var(--good); }

/* pipeline */
.pipe { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--bg); margin: 6px 0 14px; }
.pipe span { display: block; height: 100%; }
.legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* controls */
button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.05); }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.sm { padding: 5px 10px; font-size: 13px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg); }
td.check, th.check { width: 32px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* selection bar */
.selbar {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); z-index: 10;
  background: var(--ink); color: var(--bg);
  border-radius: 12px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.selbar button { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* calls / transcript */
.call { border-top: 1px solid var(--line); padding: 14px 0; }
.call:first-child { border-top: 0; padding-top: 0; }
.transcript { margin-top: 10px; display: grid; gap: 6px; font-size: 14px; }
.msg { padding: 8px 12px; border-radius: 10px; max-width: 85%; }
.msg.agent { background: var(--accent-soft); }
.msg.user { background: var(--bg); justify-self: end; }
.msg b { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: block; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10,15,13,.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { background: var(--panel); border-radius: 14px; padding: 22px; width: 100%; max-width: 460px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .panel { width: 100%; max-width: 360px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  transition: .2s; pointer-events: none; z-index: 30; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--bad); color: #fff; }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }

@media print {
  .side, .noprint, #toast { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  body { background: #fff; color: #000; font-size: 12px; }
  .panel { box-shadow: none; break-inside: avoid; }
  a { color: inherit; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 10px 0 0; }
  .nav { display: flex; gap: 2px; overflow-x: auto; width: 100%; }
  .side-foot { display: none; }
  .main { padding: 18px 16px 60px; }
  .two, .filters { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}
