:root {
  --bg: #f4f5f7;
  --card: #fff;
  --text: #1c1f24;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #1f6feb;
  --accent-ink: #fff;
  --danger: #d1242f;
  --ok: #1a7f37;
  --warn: #b35900;
  --warn-bg: #fff4e5;
  --sel: #e8f0fe;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216; --card: #171b21; --text: #e6e8eb; --muted: #9aa3ad; --line: #2a3038;
    --accent: #4c8dff; --sel: #1d2a3f; --warn-bg: #2b2114;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; }
h2 { font-size: 1.15rem; } h3 { font-size: .9rem; margin-top: .25rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; white-space: nowrap; }
.tag { font-size: .7rem; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem; margin-left: .4rem; }
.campaign-pick { display: flex; align-items: center; gap: .5rem; flex: 1; max-width: 34rem; }
.campaign-pick label { margin: 0; font-size: .85rem; color: var(--muted); }
.campaign-pick select { flex: 1; margin: 0; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--bg); color: var(--text); }
.status { display: flex; gap: .8rem; align-items: center; font-size: .9rem; white-space: nowrap; }
.pill { border-radius: 999px; padding: .15rem .6rem; font-size: .75rem; font-weight: 600; }
.pill-grey { background: var(--line); }
.pill-green { background: #d4f4dd; color: var(--ok); }
.pill-amber { background: #fde7cf; color: var(--warn); }
.pill-red { background: #fde0e2; color: var(--danger); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; }

.centre { max-width: 32rem; margin: 6rem auto; text-align: center; padding: 0 1rem; }
.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: .5rem;
  padding: .5rem .9rem; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: default; }

.layout { display: grid; grid-template-columns: minmax(18rem, 24rem) 1fr; gap: 1rem; padding: 1rem; min-height: calc(100vh - 3.2rem); align-content: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.list { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: .75rem; overflow: hidden; max-height: calc(100vh - 5.5rem); }
.list-head { display: flex; gap: .5rem; align-items: center; padding: .6rem; border-bottom: 1px solid var(--line); }
.list-head input { flex: 1; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--bg); }
.accounts { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.accounts li { padding: .55rem .8rem; border-bottom: 1px solid var(--line); cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: .15rem .5rem; }
.accounts li:hover { background: var(--sel); }
.accounts li.selected { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.accounts .name { font-weight: 600; }
.accounts .sub { color: var(--muted); font-size: .82rem; grid-column: 1; }
.accounts .last { color: var(--muted); font-size: .8rem; grid-column: 1; }
.accounts .last.recent { color: var(--warn); }
.badge { font-size: .7rem; align-self: start; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .45rem; white-space: nowrap; }
.badge.connected, .badge.meeting { color: var(--ok); border-color: var(--ok); }
.badge.attempted, .badge.brochure { color: var(--warn); border-color: var(--warn); }
.badge.not { color: var(--danger); border-color: var(--danger); }
.tps { font-size: .7rem; color: var(--danger); font-weight: 600; margin-left: .3rem; }
.hint { font-size: .75rem; padding: .4rem .8rem; margin: 0; border-top: 1px solid var(--line); }

.panel { display: flex; flex-direction: column; gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: .75rem; padding: 1rem 1.2rem; }
.row { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; flex-wrap: wrap; }
.row input { padding: .45rem .6rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--bg); min-width: 12rem; }

.acct-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.acct-side { text-align: right; font-size: .85rem; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: .5rem; padding: .5rem .7rem; margin: .6rem 0; font-size: .85rem; }
.two-col { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1.5rem; margin-top: 1rem; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

.contacts { list-style: none; margin: 0; padding: 0; }
.contacts li { padding: .55rem 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: .15rem .6rem; align-items: center; }
.contacts .name { font-weight: 600; }
.contacts .title { color: var(--muted); font-size: .82rem; grid-column: 1; }
.contacts .nums { grid-column: 1; display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .2rem; }
.contacts .last { grid-column: 2; grid-row: 1; color: var(--muted); font-size: .78rem; }
.contacts .none { color: var(--muted); font-size: .82rem; }

.activity { list-style: none; margin: 0; padding: 0; max-height: 28rem; overflow-y: auto; }
.activity li { padding: .5rem 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 5.2rem 1fr; gap: .1rem .6rem; font-size: .88rem; }
.activity .date { color: var(--muted); font-variant-numeric: tabular-nums; grid-row: span 3; }
.activity .subject { font-weight: 600; }
.activity .kind { font-size: .7rem; border-radius: 999px; padding: .05rem .4rem; border: 1px solid var(--line); color: var(--muted); margin-right: .3rem; vertical-align: 1px; }
.activity .kind.call { color: var(--accent); border-color: var(--accent); }
.activity .kind.open { color: var(--warn); border-color: var(--warn); }
.activity .who { color: var(--muted); font-size: .8rem; }
.activity .desc { color: var(--muted); font-size: .8rem; white-space: pre-line; }
.activity .desc.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }

.recent-wrap { margin-top: 1.2rem; }
.recent-wrap summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.recent { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: .5rem; }
.recent th, .recent td { text-align: left; padding: .35rem .4rem; border-bottom: 1px solid var(--line); }
.recent th { color: var(--muted); font-weight: 500; }
.recent .err { color: var(--danger); }

.call-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.call-name { font-size: 1.3rem; font-weight: 600; }
.call-timer { font-variant-numeric: tabular-nums; font-size: 1.1rem; text-align: right; }
.rec { margin: .8rem 0; font-size: .85rem; color: var(--danger); display: flex; align-items: center; gap: .8rem; }
.rec #rec-on { display: inline-flex; align-items: center; gap: .4rem; }
.rec .link { font-size: .85rem; padding: 0; }
.rec-dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--danger); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.controls { display: flex; gap: .5rem; flex-wrap: wrap; }
.meters { display: grid; grid-template-columns: auto 1fr; gap: .3rem .6rem; align-items: center; margin: 0 0 1rem; font-size: .8rem; color: var(--muted); max-width: 22rem; }
.meter { display: contents; }
.bar { height: .5rem; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--ok); transition: width .1s linear; }
.keypad { display: grid; grid-template-columns: repeat(3, 4rem); gap: .4rem; margin-top: 1rem; }
.keypad button { padding: .7rem 0; border: 1px solid var(--line); border-radius: .5rem; background: var(--bg); cursor: pointer; font-size: 1.1rem; }
.call-context { margin-top: 1rem; font-size: .85rem; color: var(--muted); white-space: pre-line; }

.dispositions { display: flex; flex-wrap: wrap; gap: .4rem; margin: .8rem 0; }
.dispositions button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: .4rem .8rem; cursor: pointer; }
.dispositions button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
label { display: block; margin-top: .75rem; font-size: .85rem; color: var(--muted); }
textarea, select { display: block; width: 100%; margin-top: .25rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--bg); color: var(--text); }

.stats { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .2rem 1.4rem; padding: .6rem 1.2rem; background: var(--card); border: 1px solid var(--line); border-radius: .75rem; }
.stat { display: flex; flex-direction: column; min-width: 4.5rem; }
.stat.sep { border-left: 1px solid var(--line); padding-left: 1.4rem; }
.stat .n { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .l { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat.progress { flex-direction: row; flex-wrap: wrap; gap: .3rem; align-items: center; min-width: 0; }
.stat.progress .badge { font-size: .72rem; }
#st-note { font-size: .75rem; margin-left: auto; }
.audio-panel { grid-column: 1 / -1; display: grid; gap: .8rem; }
.audio-panel .mode, #browser-audio { display: grid; grid-template-columns: 2fr 1fr auto; gap: 1rem; align-items: end; }
.audio-panel label { margin-top: 0; }
.audio-panel .row { margin-top: 0; }
.audio-panel input { display: block; width: 100%; margin-top: .25rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--bg); color: var(--text); }
@media (max-width: 760px) { .audio-panel .mode, #browser-audio { grid-template-columns: 1fr; } }

.toast {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: .5rem; font-size: .9rem; max-width: 90vw; z-index: 10;
}
