:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #12201d;
  --muted: #5d6b68;
  --line: #dde3e1;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e3f2ef;
  --call: #16a34a;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #b45309;
  --radius: 16px;
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1513;
    --surface: #16211e;
    --ink: #e7efed;
    --muted: #93a39f;
    --line: #26332f;
    --brand: #2dd4bf;
    --brand-ink: #062521;
    --brand-soft: #123430;
    --call: #22c55e;
    --danger: #f97066;
    --danger-soft: #3a1714;
    --warn: #f59e0b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1513; --surface: #16211e; --ink: #e7efed; --muted: #93a39f; --line: #26332f;
  --brand: #2dd4bf; --brand-ink: #062521; --brand-soft: #123430; --call: #22c55e;
  --danger: #f97066; --danger-soft: #3a1714; --warn: #f59e0b; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
  min-height: 100vh;
}
[hidden] { display: none !important; }
h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -0.01em; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.agent { font-size: 13px; color: var(--muted); }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card.empty { text-align: center; padding: 32px 20px; }
.card.focus { text-align: center; position: relative; overflow: hidden; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.cname { font-size: 26px; margin-bottom: 2px; word-break: break-word; }
.cnum { font-size: 20px; font-variant-numeric: tabular-nums; color: var(--muted); margin-bottom: 16px; letter-spacing: .02em; }
.countdown { font-size: 15px; color: var(--brand); font-weight: 600; }
.last { margin-bottom: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  user-select: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.call { background: var(--call); border-color: var(--call); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.big { min-height: 60px; font-size: 19px; width: 100%; margin: 6px 0 12px; border-radius: 14px; }
.btn.call.big::before {
  content: ""; width: 22px; height: 22px; margin-right: 10px; background: currentColor;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6.6 10.8a15.1 15.1 0 0 0 6.6 6.6l2.2-2.2c.3-.3.7-.4 1-.2 1.1.4 2.3.6 3.6.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1A17 17 0 0 1 3 4c0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.5.6 3.6.1.3 0 .7-.2 1z"/></svg>') center/contain no-repeat;
          mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6.6 10.8a15.1 15.1 0 0 0 6.6 6.6l2.2-2.2c.3-.3.7-.4 1-.2 1.1.4 2.3.6 3.6.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1A17 17 0 0 1 3 4c0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.5.6 3.6.1.3 0 .7-.2 1z"/></svg>') center/contain no-repeat;
}
.row { display: flex; gap: 10px; }
.row > .btn { flex: 1; }
.stack { display: grid; gap: 10px; }
.link { color: var(--brand); font-size: 14px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.field input, .field select, .toolbar input, .toolbar select {
  font: inherit; font-weight: 400; min-height: 46px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
  width: 100%;
}
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.switch { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; font-size: 15px; }
.switch input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }

.preview { font-size: 14px; border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.preview div { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.preview div span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

.progress-wrap { margin: 4px 0 14px; }
.progress-text { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; gap: 8px; }
.progress-text span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--brand); transition: width .3s; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  font: inherit; font-size: 14px; min-height: 38px; padding: 0 14px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer;
}
.chips button.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }

.pulse {
  width: 64px; height: 64px; margin: 6px auto 12px; border-radius: 50%; background: var(--call);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--call) 50%, transparent);
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 22px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.toolbar { display: flex; gap: 10px; margin-bottom: 10px; }
.toolbar input { flex: 1; min-width: 0; }
.toolbar select { width: auto; }
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 8px;
}
.list .who { flex: 1; min-width: 0; }
.list .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .who span { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.list .tag { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.list .tag.called { background: var(--brand-soft); color: var(--brand); }
.list .tag.skipped { color: var(--warn); }
.list .mini {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--call); display: grid; place-items: center; text-decoration: none;
}
.list .mini svg { width: 18px; height: 18px; fill: currentColor; }
.list .current { border-color: var(--brand); }
.list .meta { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs button {
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer;
}
.tabs svg { width: 24px; height: 24px; fill: currentColor; }
.tabs button.active { color: var(--brand); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  max-width: calc(100% - 32px); z-index: 20; text-align: center;
}
