/* Click2Call brand: green #3B9C49 (hover #2E7A3A, light #4DB860), charcoal #111827 */
:root {
  --bg: #f5f5f7; --card: #ffffff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb; --key: #f3f4f6;
  --brand: #3B9C49; --brand-hover: #2E7A3A; --brand-soft: rgba(59,156,73,.14);
  --red: #e5372d; --amber: #d97706;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000000; --card: #16181d; --ink: #f3f4f6; --muted: #9ca3af; --line: #2d3139; --key: #24272e;
    --brand: #4DB860; --brand-hover: #3B9C49; --brand-soft: rgba(77,184,96,.18); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh; min-height: 100dvh; }
.shell { max-width: 400px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 16px 24px; }
.card { background: var(--card); border-radius: 22px; padding: 22px 22px 20px;
  box-shadow: 0 1px 2px rgba(17,24,39,.04), 0 10px 30px rgba(17,24,39,.06); }

.brand { text-align: center; margin: 4px 0 20px; }
.brand img { display: block; margin: 0 auto; height: 56px; width: auto; }
.brand p { color: var(--muted); margin: 10px 0 0; font-size: 15px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 5px; }
input, select { width: 100%; font: inherit; color: var(--ink); background: transparent; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; outline: none; }
select { background: var(--key); border-color: transparent; padding-right: 10px; }
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.hint { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.error { color: var(--red); font-size: 14px; min-height: 1em; margin: 10px 0 0; }
.fine { font-size: 12px; color: var(--muted); text-align: center; margin: 18px 0 0; }
.warn { text-align: center; color: var(--amber); font-size: 13px; margin: -6px 0 10px; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .4; cursor: default; }
.btn { background: var(--key); border-radius: 12px; padding: 12px 16px; font-weight: 500; }
.btn.primary { width: 100%; margin-top: 16px; background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--red); }
.link { color: var(--brand); font-size: 14px; padding: 4px 0; font-weight: 500; }

.bar { display: flex; justify-content: space-between; align-items: center; }
.mark img { display: block; height: 32px; width: auto; }
.iconbtn { color: var(--muted); padding: 6px; border-radius: 10px; }
.iconbtn:hover { background: var(--key); }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 10px 0 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c7c7cc; flex: 0 0 auto; }
.dot.ok { background: var(--brand); } .dot.warn { background: var(--amber); } .dot.err { background: var(--red); }
.dnd { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--amber); background: rgba(217,119,6,.12);
  padding: 2px 8px; border-radius: 20px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--key); border-radius: 11px; padding: 3px; margin-bottom: 4px; }
.seg button { padding: 7px 0; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 6px; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(17,24,39,.12); }
.badge { background: var(--red); color: #fff; font-size: 11px; font-weight: 600; min-width: 18px; height: 18px;
  border-radius: 9px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; }

.display { position: relative; margin: 10px 0 2px; }
.display input { border: 0; font-size: 30px; text-align: center; letter-spacing: .5px; padding: 10px 44px;
  font-variant-numeric: tabular-nums; }
.display input:focus { box-shadow: none; }
.icon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: 22px; color: var(--muted); padding: 8px; }

.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; margin: 12px 10px 20px; }
.pad button { aspect-ratio: 1; border-radius: 50%; background: var(--key); font-size: 28px; font-weight: 400;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; transition: filter .1s; }
.pad button:active { filter: brightness(.9); }
.pad button small { font-size: 9px; letter-spacing: 1.6px; color: var(--muted); margin-top: 3px; font-weight: 600; }
.pad.small { margin: 0 24px 14px; gap: 10px 16px; }
.pad.small button { font-size: 22px; }

.round { display: flex; align-items: center; justify-content: center; width: 68px; height: 68px;
  border-radius: 50%; color: #fff; margin: 0 auto; transition: transform .1s, background .15s; }
.round:active { transform: scale(.95); }
.round.call { background: var(--brand); }
.round.call:hover { background: var(--brand-hover); }
.round.end { background: var(--red); }
.pair { display: flex; justify-content: space-around; margin: 30px 0 10px; }
.pair .round { margin: 0; }

.who { text-align: center; padding: 22px 0 22px; }
.who .name { font-size: 28px; font-weight: 600; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.who .label { color: var(--muted); font-size: 14px; margin-top: 4px; font-variant-numeric: tabular-nums; }
#incoming .who .label { margin: 0 0 6px; }

.ctl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--key); border-radius: 14px; padding: 14px 0; font-size: 14px; font-weight: 500; }
.tile[aria-pressed="true"] { background: var(--ink); color: var(--card); }

.xfer { display: flex; gap: 8px; margin-bottom: 22px; }
.xfer input { padding: 10px 12px; font-size: 15px; }
.xfer .btn { flex: 0 0 auto; padding: 10px 14px; font-size: 15px; }

/* Recents */
.list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 430px; overflow-y: auto; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .dir { width: 18px; color: var(--muted); flex: 0 0 auto; text-align: center; font-size: 14px; }
.list .main { flex: 1; min-width: 0; text-align: left; }
.list .num { font-weight: 500; font-variant-numeric: tabular-nums; }
.list .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.list li.missed .num, .list li.missed .dir { color: var(--red); }
.list .when { font-size: 12px; color: var(--muted); text-align: right; flex: 0 0 auto; }
.list .cb { color: var(--brand); padding: 6px; border-radius: 50%; flex: 0 0 auto; }
.list .cb:hover { background: var(--brand-soft); }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 40px 0 30px; margin: 0; }
.listfoot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted);
  padding-top: 10px; border-top: 1px solid var(--line); margin-top: 6px; }

/* Settings */
#settings h2 { font-size: 18px; font-weight: 600; margin: 4px 0 6px; }
.switch { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; margin: 20px 0 0;
  color: var(--ink); font-size: 15px; cursor: pointer; }
.switch input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); }
.switch small { grid-column: 2; color: var(--muted); font-size: 12px; }
.switch.keep { margin: 14px 0 0; font-size: 14px; }

/* Install */
.nudge { display: flex; align-items: center; gap: 10px; background: var(--brand-soft); border-radius: 12px;
  padding: 10px 10px 10px 12px; margin: -4px 0 14px; font-size: 13px; line-height: 1.35; }
.nudge span { flex: 1; }
.btn.small { padding: 7px 12px; font-size: 13px; background: var(--brand); color: #fff; flex: 0 0 auto; }
.nudge .x { color: var(--muted); font-size: 20px; line-height: 1; padding: 2px 4px; }
.btn.brand { width: 100%; background: var(--brand); color: #fff; margin-bottom: 10px; }
.steps { font-size: 13px; color: var(--ink); margin: 0; padding-left: 20px; }
.steps li { margin: 4px 0; }
.steps code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--key); padding: 1px 5px; border-radius: 5px; }
.acct { font-size: 13px; color: var(--muted); margin: 20px 0 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

@media (max-width: 360px) { .pad { gap: 10px 14px; margin: 10px 4px 16px; } .pad button { font-size: 24px; } }

/* Second call + consult transfer */
.altbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  background: var(--key); border-radius: 12px; padding: 9px 10px 9px 12px; margin: -6px 0 14px; font-size: 13px; }
.altbar span#altText { font-weight: 500; font-variant-numeric: tabular-nums; }
.altbtns { display: flex; gap: 6px; }
.btn.small.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.xfer .btn { padding: 10px 11px; font-size: 14px; }
.xferbar { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin: -10px 0 22px; }
.xferbar .btn.brand { margin: 0; }

/* Launcher + pop-up call window */
.hint.center { text-align: center; }
.setup { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.setup h3 { margin: 0 0 8px; font-size: 15px; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist > li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.checklist > li:last-child { border-bottom: 0; }
.checklist > li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.checklist small { color: var(--muted); font-size: 13px; }
.checklist .note { color: var(--brand); }
.checklist .switch { margin: 0; }
.checklist .steps { margin: 2px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.ck { flex: 0 0 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); box-sizing: border-box; margin-top: 1px; }
.checklist > li.done .ck { background: var(--brand); border-color: var(--brand); position: relative; }
.checklist > li.done .ck::after { content: ''; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.ck.info { border-style: dashed; }
.report { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.report textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); resize: vertical; }
.report .row { margin-top: 4px; }
.fine.left { text-align: left; margin: 2px 0 0; }
.checklist .btn { width: auto; margin: 2px 0 0; flex: 0 0 auto; }
.checklist .switch span { font-weight: 600; }
.btn.ghost.wide { width: 100%; margin-top: 10px; background: transparent; color: var(--ink); border: 1px solid var(--line); }
.scanner { margin-top: 4px; }
.scanview { position: relative; border-radius: 16px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; }
.scanview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanframe { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.9); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
body.callmode .shell { padding-top: 12px; }
body.callmode .seg, body.callmode #iconSettingsWrap, body.callmode #btnSettings,
body.callmode .nudge, body.callmode #section-fine, body.callmode .fine { display: none !important; }

/* Diagnostics */
.diagbtn { width: 100%; margin-top: 18px; }
#diag h2 { font-size: 18px; font-weight: 600; margin: 4px 0 10px; }
.dh { font-size: 14px; font-weight: 600; margin: 18px 0 6px; }
.dh span { font-weight: 400; color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; margin: 0 0 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; word-break: break-word; }
.kv dd.ok { color: var(--brand); } .kv dd.bad { color: var(--red); }
.tests { list-style: none; padding: 0; margin: 10px 0 0; font-size: 13px; }
.tests li { padding: 5px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 20px 1fr; gap: 6px; }
.tests li small { grid-column: 2; color: var(--muted); }
.switch.small { margin: 4px 0 6px; font-size: 13px; }
.log { background: var(--key); border-radius: 10px; padding: 10px; font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  max-height: 240px; overflow: auto; white-space: pre-wrap; margin: 0; color: var(--ink); }

/* Push-to-ring */
#btnPushTest { margin: 6px 0 0 30px; font-size: 13px; }
