:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2433; --muted: #667085; --line: #e3e6eb;
  --accent: #1f6feb; --accent-text: #ffffff; --danger: #b42318; --ok: #067647; --warn: #b54708;
  --hot: #c4320a; --warm: #b54708; --chip: #eef1f5; --in: #1f6feb; --out: #98a2b3;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131a; --panel: #171c24; --text: #e6e9ef; --muted: #98a2b3; --line: #2a313c;
    --accent: #4c8dff; --accent-text: #0b1020; --danger: #f97066; --ok: #47cd89; --warn: #fdb022;
    --hot: #ff7a45; --warm: #fdb022; --chip: #222a35; --in: #4c8dff; --out: #667085;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 0 0 8px; }
.boot { padding: 40px; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
nav.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
nav.side .brand { font-weight: 700; font-size: 17px; padding: 4px 10px 14px; }
nav.side a { color: var(--text); padding: 8px 10px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
nav.side a:hover { background: var(--chip); text-decoration: none; }
nav.side a.active { background: var(--chip); font-weight: 600; }
nav.side .grow { flex: 1; }
nav.side .who { color: var(--muted); font-size: 12px; padding: 8px 10px; word-break: break-all; }
main { padding: 24px 28px 60px; max-width: 1180px; width: 100%; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  nav.side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  nav.side .brand { padding: 8px 10px; } nav.side .grow, nav.side .who { display: none; }
  main { padding: 16px; }
}

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; box-shadow: var(--shadow); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.two { grid-template-columns: 1fr 1fr; } @media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.tile .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--chip); color: var(--text); white-space: nowrap; }
.badge.hot { background: var(--hot); color: #fff; } .badge.warm { background: var(--warm); color: #fff; }
.badge.handed_off { background: var(--accent); color: var(--accent-text); }
.badge.dead, .badge.do_not_contact { color: var(--muted); } .badge.danger { background: var(--danger); color: #fff; }
.badge.ok { background: var(--ok); color: #fff; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 12px; background: var(--chip); margin: 1px 3px 1px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--chip); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

button, .btn { font: inherit; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--danger); }
button:disabled { opacity: .55; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
textarea { width: 100%; min-height: 150px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.field { margin: 0 0 12px; }

/* conversation */
.msg { border-left: 3px solid var(--out); padding: 4px 0 4px 12px; margin: 0 0 14px; }
.msg.in { border-left-color: var(--in); }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg pre, pre.body { white-space: pre-wrap; word-wrap: break-word; margin: 0; font: inherit; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.login { max-width: 380px; margin: 12vh auto; }
.notice { background: var(--chip); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 0 0 12px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; } #toast.err { background: var(--danger); color: #fff; }

/* utilities */
.mt { margin-top: 14px; } .mt-s { margin-top: 6px; } .mb { margin-bottom: 14px; }
a.card.block, a.tile { display: block; color: var(--text); }
a.card.block:hover, a.tile:hover { text-decoration: none; border-color: var(--muted); }
textarea.short { min-height: 80px; }
input.wide { width: 100%; min-width: 220px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
button.small-btn { padding: 4px 10px; font-size: 13px; }

button.wide-btn { width: 100%; padding: 10px 14px; }
summary { cursor: pointer; }
