:root {
  --bg: #f3f9ff;
  --card: #ffffff;
  --card2: #e8f4ff;
  --line: #cfe5f8;
  --text: #0b2a43;
  --muted: #587691;
  --neon: #2aa7f2;
  --neon2: #0b6fb8;
  --good: #0f9d68;
  --bad: #d9304f;
  --warn: #b97a00;
  --glow: 0 6px 18px rgba(42, 167, 242, 0.28);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; }
[hidden] { display: none !important; }
h1 { margin: 6px 0 0; font-size: 30px; letter-spacing: 0.5px; }
h2 { margin: 0 0 12px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.bad { color: var(--bad); }
.good { color: var(--good); }
.plain { list-style: none; margin: 8px 0; padding: 0; }
.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.plain li:last-child { border-bottom: 0; }

.pmark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 52%), linear-gradient(180deg, #4cbafa, #0f78c8);
  color: #fff; font-weight: 800; text-shadow: 0 1px 1px rgba(0, 60, 120, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), inset 0 -3px 5px rgba(0, 50, 110, 0.25), 0 4px 10px rgba(42, 167, 242, 0.4);
}
.pmark.big { width: 72px; height: 72px; font-size: 38px; }

.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(180deg, #ffffff, var(--bg)); }
.gatebox { width: 100%; max-width: 360px; text-align: center; }
.gatebox form { display: grid; gap: 12px; margin: 22px 0 10px; }

.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.pill { font-size: 12px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: #fff; }
.pill.ok { color: var(--good); border-color: rgba(15, 157, 104, 0.4); }
.pill.warn { color: var(--warn); border-color: rgba(185, 122, 0, 0.4); }

main { padding: 14px 14px calc(88px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.tab { display: none; gap: 12px; }
.tab.active { display: grid; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 14px; box-shadow: 0 1px 3px rgba(11, 111, 184, 0.06); }
.hero { text-align: center; background: linear-gradient(180deg, #dff0ff, #ffffff); box-shadow: var(--glow); }
.state { color: var(--neon2); font-size: 13px; letter-spacing: 1.2px; text-transform: uppercase; }
.who { font-size: 28px; font-weight: 750; margin: 6px 0 2px; word-break: break-word; }
.sub { color: var(--muted); }
.timer { font-size: 34px; font-variant-numeric: tabular-nums; margin-top: 8px; color: var(--good); }

.label { color: var(--neon2); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; margin: 10px 0 6px; display: block; }
.opener { font-size: 18px; margin: 0 0 6px; }
.points { margin: 0; padding-left: 20px; }
.points li { margin: 6px 0; font-size: 17px; }

.controls { display: grid; gap: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  appearance: none; border: 1px solid #b9dcf7; color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.35) 50%, rgba(255, 255, 255, 0) 51%), linear-gradient(180deg, #e9f6ff, #bfe1fa);
  box-shadow: inset 0 1px 0 #fff, inset 0 -3px 6px rgba(11, 111, 184, 0.14), 0 5px 12px rgba(11, 111, 184, 0.18);
  border-radius: 999px; padding: 12px 18px; font: inherit; font-weight: 650; cursor: pointer; min-height: 48px;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:active { transform: translateY(1px) scale(0.985); box-shadow: inset 0 1px 0 #fff, inset 0 -2px 4px rgba(11, 111, 184, 0.18), 0 2px 6px rgba(11, 111, 184, 0.18); }
.btn.big { min-height: 60px; font-size: 18px; }
.btn.primary {
  border-color: #0e6db8; color: #fff; text-shadow: 0 1px 1px rgba(0, 60, 120, 0.45);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.14) 50%, rgba(255, 255, 255, 0) 51%), linear-gradient(180deg, #46b7f9, #0f78c8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), inset 0 -4px 8px rgba(0, 50, 110, 0.28), 0 8px 18px rgba(42, 167, 242, 0.42);
}
.btn.danger {
  border-color: #e58aa0; color: #a8183a;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 51%), linear-gradient(180deg, #ffe3e9, #f9b9c6);
  box-shadow: inset 0 1px 0 #fff, inset 0 -3px 6px rgba(168, 24, 58, 0.14), 0 5px 12px rgba(217, 48, 79, 0.2);
}
.btn[disabled] { opacity: 0.5; }

input, textarea, select {
  width: 100%; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; font: inherit; min-height: 48px;
  box-shadow: inset 0 2px 4px rgba(11, 111, 184, 0.07);
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--neon); outline-offset: 0; }
.field { display: grid; gap: 6px; margin: 10px 0; font-size: 14px; color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--neon); }

details summary { cursor: pointer; font-weight: 600; }
details > * { margin-top: 10px; }

.list { display: grid; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
}
.card .item { background: var(--card2); }
.item .info { min-width: 0; flex: 1; }
.item .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .btn { min-height: 40px; padding: 8px 12px; flex: none; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; }
.tag.done { color: var(--good); border-color: rgba(15, 157, 104, 0.4); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); z-index: 6;
}
.tabs button {
  appearance: none; background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600;
  padding: 16px 4px; cursor: pointer;
}
.tabs button.on { color: var(--neon2); box-shadow: inset 0 3px 0 var(--neon); }

dialog { border: 1px solid var(--line); border-radius: 26px; background: var(--card); color: var(--text); width: min(92vw, 520px); padding: 18px; max-height: 90vh; border-radius: 26px; }
dialog::backdrop { background: rgba(11, 42, 67, 0.45); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); z-index: 20;
  background: #0b2a43; border: 1px solid #0b2a43; color: #fff; padding: 12px 16px; border-radius: 14px;
  max-width: 90vw; box-shadow: var(--glow);
}

/* ---------- v4: header count, six tabs, dial circle, pipeline, payments, settings sections ---------- */
.topright { display: flex; align-items: center; gap: 10px; }
.pipe { appearance: none; border: 0; background: none; cursor: pointer; display: grid; text-align: right; line-height: 1; padding: 0 2px; color: var(--text); }
.pipe b { font-size: 30px; font-weight: 800; color: var(--neon2); font-variant-numeric: tabular-nums; }
.pipe span { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.tabs { grid-template-columns: repeat(6, 1fr); }
.tabs button { font-size: 12.5px; padding: 15px 0; position: relative; }
.tabs button i { position: absolute; top: 7px; left: 50%; margin-left: 14px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--neon); color: #fff; font: 700 11px/17px system-ui; text-align: center; padding: 0 4px; }
.ptitle { margin: 0; font-size: 28px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 14px; }
.linkbtn { appearance: none; background: none; border: 0; color: var(--neon2); text-decoration: underline; font: inherit; padding: 8px; cursor: pointer; }
.sech { margin: 0 0 6px; font-size: 18px; color: var(--neon2); }
.card[id^="set-"] { scroll-margin-top: 70px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; background: var(--card2); color: var(--neon2); }
.chip:empty { display: none; }
.chip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--neon)); display: inline-block; }
.hero { position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 7px; background: var(--spine, var(--neon)); }
.cbnote { margin-top: 6px; font-size: 14px; color: var(--warn); }

.dialrow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 6px 0; }
.side { display: grid; justify-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.circle {
  appearance: none; width: 62px; height: 62px; border-radius: 50%; border: 1px solid #b9dcf7; color: var(--neon2); cursor: pointer;
  display: grid; place-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.35) 50%, rgba(255, 255, 255, 0) 51%), linear-gradient(180deg, #e9f6ff, #bfe1fa);
  box-shadow: inset 0 1px 0 #fff, inset 0 -3px 6px rgba(11, 111, 184, 0.14), 0 5px 12px rgba(11, 111, 184, 0.18);
}
.circle:active { transform: scale(0.96); }
.circle[disabled] { opacity: 0.4; }
svg.i { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.bigdial {
  appearance: none; width: 168px; height: 168px; border-radius: 50%; border: 1px solid #0e6db8; color: #fff; cursor: pointer;
  display: grid; place-items: center; align-content: center; gap: 2px; text-shadow: 0 1px 1px rgba(0, 60, 120, 0.45);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.12) 50%, rgba(255, 255, 255, 0) 51%), linear-gradient(180deg, #55c0fb, #0f78c8);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.7), inset 0 -8px 14px rgba(0, 50, 110, 0.28), 0 14px 28px rgba(42, 167, 242, 0.45);
}
.bigdial b { font-size: 28px; font-weight: 800; }
.bigdial small { font-size: 14px; opacity: 0.95; font-variant-numeric: tabular-nums; }
.bigdial:active { transform: scale(0.97); }
.bigdial[disabled] { opacity: 0.55; box-shadow: none; }
.bigdial.end { border-color: #b01a3c; background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.1) 50%, rgba(255, 255, 255, 0) 51%), linear-gradient(180deg, #ff7d98, #d9304f); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.65), inset 0 -8px 14px rgba(120, 0, 30, 0.28), 0 14px 28px rgba(217, 48, 79, 0.4); }
.bigdial.ready { animation: ringpulse 2.6s ease-out infinite; }
@keyframes ringpulse { 0% { box-shadow: inset 0 2px 0 rgba(255,255,255,.7), 0 14px 28px rgba(42,167,242,.45), 0 0 0 0 rgba(85,192,251,.5); } 70% { box-shadow: inset 0 2px 0 rgba(255,255,255,.7), 0 14px 28px rgba(42,167,242,.45), 0 0 0 22px rgba(85,192,251,0); } 100% { box-shadow: inset 0 2px 0 rgba(255,255,255,.7), 0 14px 28px rgba(42,167,242,.45), 0 0 0 0 rgba(85,192,251,0); } }
@media (prefers-reduced-motion: reduce) { .bigdial.ready { animation: none; } }

.outcomes .btn { gap: 8px; }
.outcomes .btn i { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--neon)); flex: none; }

.voicebar { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 8px 8px 8px 16px; }
.voicebar .say { flex: 1; min-width: 0; display: grid; font-size: 13.5px; color: var(--muted); }
.voicebar .say b { color: var(--text); font-size: 14.5px; }
.mic { appearance: none; width: 52px; height: 52px; border-radius: 50%; border: 1px solid #b9dcf7; color: var(--neon2); display: grid; place-items: center; flex: none; cursor: pointer; background: linear-gradient(180deg, #fff, #dff0ff); }
.mic.on { color: #fff; border-color: #0e6db8; background: linear-gradient(180deg, #55c0fb, #0f78c8); animation: ringpulse 1.8s ease-out infinite; }
.mic.paused { opacity: 0.55; }
.voicebar.heard { border-color: var(--neon); }

.filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.fchip { appearance: none; flex: none; padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1.5px solid var(--line); font: inherit; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.fchip i { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--neon)); }
.fchip[aria-pressed="true"] { background: linear-gradient(180deg, #55c0fb, #0f78c8); color: #fff; border-color: #0e6db8; }

.group { margin-top: 6px; }
.group h3 { margin: 10px 2px 6px; font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; text-transform: uppercase; letter-spacing: 0.8px; }
.prow { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 11px 12px 11px 18px; margin-bottom: 8px; overflow: hidden; }
.prow::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--spine, var(--neon)); }
.prow .t { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.prow .t span:first-child { overflow-wrap: anywhere; }
.prow .s { font-size: 13.5px; color: var(--muted); }
.prow .w { font-size: 13.5px; color: var(--neon2); font-weight: 600; margin-top: 2px; }
.prow .acts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.prow .acts .btn { min-height: 38px; padding: 6px 14px; font-size: 14px; }
.pill2 { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--card2); color: var(--neon2); white-space: nowrap; align-self: start; }
.pill2.won { background: #dcfce7; color: #166534; }
.pill2.callback { background: #fef3c7; color: #92400e; }
.pill2.overdue { background: #ffe4e6; color: #9f1239; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 10px 14px 10px 20px; overflow: hidden; }
.tile::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 7px; background: var(--c, var(--neon)); }
.tile .n { font-size: 28px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .lb { font-size: 13.5px; color: var(--muted); }
.empty { text-align: center; padding: 22px 10px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 4px; }
