:root {
  --bg: #11151c;
  --panel: #1a202b;
  --panel-2: #222a38;
  --line: #2e3748;
  --text: #e8ecf3;
  --muted: #94a0b4;
  --accent: #6ea8fe;
  --accent-ink: #0b1a33;
  --good: #58c98b;
  --warn: #f2b84b;
  --bad: #f07178;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.15rem; }
p { margin: 0.4em 0; }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--bad); min-height: 1.3em; font-size: 0.9rem; }

input, textarea, select, button { font: inherit; color: inherit; }
input[type=text], input[type=password], textarea, select {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
button { cursor: pointer; border: 0; border-radius: 10px; padding: 12px 16px; background: var(--panel-2); }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.primary.live { background: var(--bad); color: #2a0b0e; }
button.big { width: 100%; padding: 16px; font-size: 1.05rem; border-radius: var(--radius); }
button.link { background: none; color: var(--muted); text-decoration: underline; padding: 8px 0; }
button:disabled { opacity: 0.55; cursor: default; }

.screen { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); text-align: center; display: grid; gap: 6px; justify-items: center; }
.login-card form { width: 100%; display: grid; gap: 10px; margin-top: 18px; }

#app { height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; }
.tab { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 14px 16px 0; }
.bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-bottom: 10px; }
.timer { font-variant-numeric: tabular-nums; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; }

.transcript { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0 12px; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; margin: auto 0; }
.bubble { max-width: 86%; padding: 10px 13px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.bubble.caller { align-self: flex-end; background: #233149; border-color: #31456a; border-bottom-right-radius: 5px; }
.bubble.assistant { align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble.partial { opacity: 0.6; }
.bubble .who { display: block; font-size: 0.72rem; color: var(--muted); margin-bottom: 2px; }
.bubble .en { display: block; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.92rem; }
.chip { align-self: center; font-size: 0.82rem; padding: 5px 12px; border-radius: 999px; background: var(--panel-2); color: var(--muted); max-width: 92%; text-align: center; }
.chip.message { color: var(--good); }
.chip.suspicious { color: var(--bad); }
.chip.note { color: var(--warn); }

.call-controls { display: grid; gap: 8px; padding: 10px 0 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 8px; }
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.card ul { margin: 6px 0 0; padding-left: 20px; }
.risk-high { border-color: var(--bad); }
.badge { display: inline-block; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); margin-left: 6px; vertical-align: middle; }
.badge.high { background: #4a1f24; color: var(--bad); }

.list { overflow-y: auto; display: grid; gap: 8px; padding-bottom: 12px; align-content: start; flex: 1; min-height: 0; }
.row { text-align: left; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.row strong { display: block; }
#history-detail { overflow-y: auto; flex: 1; min-height: 0; padding-bottom: 12px; }
#history-detail .transcript { overflow: visible; }
.detail-actions { display: flex; justify-content: space-between; margin-bottom: 8px; }

.form { display: grid; gap: 14px; overflow-y: auto; padding-bottom: 8px; }
.form label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.form label.check { grid-template-columns: auto 1fr; align-items: start; gap: 10px; color: var(--text); }
.form input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; }
#tab-settings { overflow-y: auto; }
.name-box { display: grid; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.name-box .buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.name-box .buttons button { flex: 1; min-width: 120px; }
.name-box .transcript { flex: none; max-height: 180px; padding: 0; }
.name-box .transcript:empty { display: none; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { background: none; border-radius: 0; padding: 14px 0; color: var(--muted); }
.tabs button.active { color: var(--accent); font-weight: 650; }

/* v3: settings sections, live question card, outcomes */
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 12px; margin: 0; }
legend { padding: 0 6px; font-weight: 650; color: var(--text); }
.form { overflow: visible; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.buttons button { flex: 1; min-width: 120px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input[type=time], input[type=number], input[type=email] { width: 100%; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; color: inherit; font: inherit; }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.days label { display: flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; color: var(--text); }
.days input { width: 16px; height: 16px; margin: 0; }
.qa-head { display: grid; gap: 2px; }
.qa-list { display: grid; gap: 10px; }
.qa { display: grid; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.qa button { justify-self: end; padding: 6px 10px; font-size: 0.85rem; }
.panel { display: grid; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 14px 0 0; }
.panel h3 { margin: 0; font-size: 1rem; }
.panel .list { flex: none; padding: 0; }
.booking { display: flex; justify-content: space-between; gap: 10px; align-items: center; background: var(--panel-2); border-radius: 10px; padding: 10px 12px; }
.booking.cancelled { opacity: 0.5; text-decoration: line-through; }
.booking button { padding: 6px 10px; font-size: 0.85rem; }
.ask-card { position: sticky; top: 0; z-index: 5; margin: 10px 16px 0; background: #2b2410; border: 1px solid var(--warn); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; }
.ask-title { color: var(--warn); font-size: 0.85rem; margin: 0; }
.ask-question { font-weight: 650; margin: 0; }
.ask-options button { background: var(--warn); color: #2b2410; font-weight: 650; }
.ask-form { display: flex; gap: 8px; }
.ask-form input { flex: 1; }
.badge.resolved { background: #17382a; color: var(--good); }
.badge.needs { background: #3d3214; color: var(--warn); }
.outcome { font-size: 0.9rem; margin-top: 2px; }
.chip.ask { color: var(--warn); }
.chip.booking, .chip.answer { color: var(--good); }
.src { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.src > label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.src label.check { display: grid; grid-template-columns: auto 1fr; gap: 10px; color: var(--text); }
.src label.check input { width: 20px; height: 20px; margin-top: 2px; }
.filebtn { flex: 1; min-width: 120px; text-align: center; cursor: pointer; border-radius: 10px; padding: 12px 16px; background: var(--panel-2); color: var(--text); font-size: 1rem; }
.sms-box { display: grid; gap: 8px; }
.keybox { display: grid; gap: 6px; background: var(--panel-2); border-radius: 10px; padding: 10px; }
.keybox code { word-break: break-all; font-size: 0.82rem; }

.cands { display: grid; gap: 6px; margin: 6px 0 10px; }
.cand { display: flex; gap: 8px; align-items: center; }
.cand-text { flex: 1; font-weight: 600; }

.badge.phone { background: #1d2f4a; color: #9cc3ff; }

/* Google sign-in expired: shown above every tab until the owner reconnects. */
.reconnect-banner { margin: 12px; padding: 12px 14px; border: 1px solid var(--warn); border-radius: var(--radius); background: var(--panel); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.reconnect-banner[hidden] { display: none; }
.reconnect-banner p { margin: 0; flex: 1 1 220px; }

/* v4: Secretary tasks and Sales tabs */
.tabs { grid-template-columns: repeat(5, 1fr); }
.tabs button { font-size: 0.88rem; padding: 14px 0; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; flex: none; }
.filters button { flex: none; padding: 7px 12px; border-radius: 999px; font-size: 0.85rem; background: var(--panel); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.filters button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.matter-row .reason { display: block; margin: 2px 0; }
.detail { overflow-y: auto; flex: 1; min-height: 0; padding-bottom: 12px; }
.kv { display: grid; grid-template-columns: 7.5em 1fr; gap: 8px; font-size: 0.92rem; padding: 3px 0; }
.kv .k { color: var(--muted); }
.card h3.gap { margin-top: 12px; }
.card .next { color: var(--accent); }
.events { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.ev { display: grid; gap: 2px; border-left: 3px solid var(--line); padding-left: 10px; }
.ev-call { border-color: var(--accent); }
.ev-email, .ev-text { border-color: #9cc3ff; }
.ev-approval { border-color: var(--good); }
.ev-when { color: var(--muted); font-size: 0.8rem; }
.approvals { display: grid; gap: 8px; margin-bottom: 8px; }
.approval { background: #2b2410; border: 1px solid var(--warn); border-radius: var(--radius); padding: 12px; display: grid; gap: 6px; }
.approval.decided { opacity: 0.6; }
.approval-kind { color: var(--warn); font-size: 0.82rem; margin: 0; }
.approval-q { font-weight: 650; margin: 0; }
.stage-head { font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; font-weight: 600; }
.badge.st-needs_you { background: #3d3214; color: var(--warn); }
.badge.st-active { background: #1d2f4a; color: #9cc3ff; }
.badge.st-waiting { background: var(--panel-2); color: var(--muted); }
.badge.st-resolved, .badge.stage-won { background: #17382a; color: var(--good); }
.badge.stage-lost, .badge.stage-do_not_call { background: #4a1f24; color: var(--bad); }
.badge.stage-interested, .badge.stage-meeting_booked, .badge.stage-proposal_sent { background: #1d2f4a; color: #9cc3ff; }
.badge.appt { background: #17382a; color: var(--good); }
.badge.fu { background: #1d2f4a; color: #9cc3ff; }
.row.upcoming { display: block; }
.filters { scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.approval .muted:empty { display: none; }
