:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1c1f24; --muted: #6b7280; --line: #e2e5ea;
  --accent: #1f6feb; --ok: #1a7f37; --bad: #cf222e; --warn: #9a6700; --hover: #eef2f8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #181b21; --text: #e6e8eb; --muted: #9aa3ae; --line: #2a2f37;
    --accent: #4c8dff; --ok: #3fb950; --bad: #f85149; --warn: #d29922; --hover: #1f2430;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); cursor: pointer; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .4; cursor: default; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); width: 100%; }
.muted, .placeholder { color: var(--muted); }

/* layout */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; }
.lab { font-size: 11px; color: var(--warn); border: 1px solid var(--warn); border-radius: 4px; padding: 0 4px; margin-left: 6px; }
.status { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.topbar form { margin: 0; }
.banner { background: var(--warn); color: #fff; text-align: center; padding: 6px; font-size: 13px; cursor: pointer; }

main { display: grid; grid-template-columns: 320px 1fr 260px; gap: 12px; padding: 12px; height: calc(100% - 52px); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto; }

#customers { list-style: none; margin: 10px 0 0; padding: 0; }
#customers li { display: flex; justify-content: space-between; gap: 8px; padding: 8px; border-radius: 8px; cursor: pointer; }
#customers li:hover { background: var(--hover); }
#customers li.active { background: var(--hover); outline: 1px solid var(--accent); }
#customers .who { display: flex; flex-direction: column; min-width: 0; }
#customers .who span, #customers .num { color: var(--muted); font-size: 12px; }
#customers .empty { color: var(--muted); cursor: default; }

.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-head h2 { margin: 0; font-size: 20px; }
.card-head p { margin: 2px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: 70px 1fr; gap: 4px 12px; margin: 16px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
h3 { font-size: 14px; margin: 18px 0 8px; }
.history { width: 100%; border-collapse: collapse; font-size: 13px; }
.history th, .history td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.history th { color: var(--muted); font-weight: 500; }
.tag { padding: 1px 6px; border-radius: 4px; font-size: 12px; background: var(--hover); }
.tag.answered { color: var(--ok); } .tag.failed, .tag.rejected, .tag.missed { color: var(--bad); } .tag.cancelled { color: var(--warn); }

/* right column: phone */
#dial-form { display: flex; gap: 6px; }
#dial-form input { flex: 1; }
#keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 8px; }
#keypad button { padding: 6px 0; }
#log { list-style: none; padding: 0; margin: 8px 0 0; font: 11px/1.4 ui-monospace, Menlo, monospace; color: var(--muted); }

/* call bar */
#callbar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 10px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
#callbar[hidden] { display: none; }

/* incoming pop-up and wrap-up */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; }
.overlay[hidden] { display: none; }
.dialog { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(380px, 92vw); }
.dialog h2 { margin: 4px 0; }
.dialog .row { display: flex; gap: 8px; margin-top: 14px; }
.dialog .row button { flex: 1; padding: 10px; }
.eyebrow { color: var(--accent); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
#wrap { position: fixed; right: 16px; bottom: 16px; width: 300px; }
#wrap[hidden] { display: none; }
#wrap textarea { min-height: 70px; margin-top: 6px; }

/* login */
.login { max-width: 360px; margin: 12vh auto; }
.login label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 12px; }
.login button { width: 100%; margin-top: 16px; padding: 10px; }
.error { color: var(--bad); font-size: 13px; }

@media (max-width: 980px) {
  main { grid-template-columns: 1fr; height: auto; }
}
