:root {
    color-scheme: light dark;
    --bg: #f4f5f7; --panel: #ffffff; --text: #1c2027; --muted: #626b78; --line: #dde0e5;
    --accent: #2563a8; --accent-text: #ffffff; --danger: #b3261e;
    --ok: #1b7a43; --ok-bg: #e2f4ea; --warn: #8a5a00; --warn-bg: #fbf0d7; --bad: #b3261e; --bad-bg: #fbe6e4;
    --them: #e7e9ee; --them-text: #1c2027; --ai: #2563a8; --ai-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171c; --panel: #1e2229; --text: #e8eaed; --muted: #9aa3af; --line: #333943;
        --accent: #6aa5e8; --accent-text: #0c1420; --danger: #f2877f;
        --ok: #6fd39b; --ok-bg: #17331f; --warn: #e8c36f; --warn-bg: #3a2e12; --bad: #f2877f; --bad-bg: #40201e;
        --them: #2d323b; --them-text: #e8eaed; --ai: #2f6db3; --ai-text: #ffffff;
    }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .25rem; }
main { margin: 0 auto; padding: 24px 24px 48px; }
@media (max-width: 560px) { main { padding-left: 16px; padding-right: 16px; } }
.btn[hidden] { display: none; }
.scam-email summary { cursor: pointer; font-weight: 600; }
.scam-email p { white-space: pre-wrap; overflow-wrap: anywhere; margin: 10px 0 0; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.filters label:not(.check) { display: block; margin: 0 0 4px; }
.filters .check { padding-bottom: 8px; }
.filter-search { flex: 1 1 280px; max-width: 520px; }
.filters select { min-width: 150px; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin-top: 14px; }
.star { background: none; border: 0; padding: 2px 4px; font: inherit; font-size: 1.35rem; line-height: 1; color: var(--muted); cursor: pointer; }
.star:hover { color: var(--warn); }
.star.on { color: #d99a00; }
.star-cell { width: 1%; padding-right: 0 !important; }
.call-title { display: flex; align-items: center; gap: 6px; }
.call-title form { margin: 0; }
.voice-actions { text-align: right; width: 1%; }
.voice-pick { margin-top: 0; }
.voice-pick select { flex: 1 1 240px; width: auto; }
.form .voice-pick .btn { margin-top: 0; align-self: center; }
.help:empty { display: none; }
.account-link { color: var(--text); }
.signout { margin: 0; }
.item > .form { padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--line); }
.user-actions { padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--line); }
.add-user { margin-top: 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.login-logo { align-self: center; margin-bottom: 8px; }
.login h1 { text-align: center; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.calls-table th, .calls-table td { padding: 13px 16px; font-size: 1rem; }
.calls-table td.actions { text-align: right; }
.row-actions { display: inline-flex; gap: 8px; align-items: center; }
form[hidden] { display: none; }
.calls-table tbody tr:hover { background: var(--bg); }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 32px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 6px 32px; flex: 1; }
.topbar nav a { color: var(--text); text-decoration: none; padding: 2px 0; }
.topbar nav a:hover { color: var(--accent); }
.linklike { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.healthy { background: var(--ok); } .dot.degraded { background: var(--warn); } .dot.down { background: var(--bad); }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.head-actions, .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sub, .help { color: var(--muted); margin: 2px 0; }
.help { font-size: .87rem; }
.empty { color: var(--muted); padding: 12px 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.grid .card { margin: 0; }
.item p { margin: 6px 0; }
.clip { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.status-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.status-down { border-color: var(--bad); }

.form { display: flex; flex-direction: column; gap: 6px; }
.form h2 { margin-top: 16px; } .form h2:first-child { margin-top: 0; }
.form .btn, .form .row { margin-top: 10px; align-self: flex-start; }
.form .row .btn { margin-top: 0; }
.login { margin: 12vh auto 0; max-width: 380px; }
label { font-weight: 600; font-size: .9rem; margin-top: 6px; }
input, select, textarea { width: 100%; padding: 8px 10px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
input[type=checkbox] { width: auto; }
/* Very wide selects open a native list that doesn't fit on screen. */
select { max-width: 640px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.inline input:not([type=checkbox]) { flex: 1 1 180px; width: auto; }
.check { display: flex; gap: 6px; align-items: center; margin: 0; font-weight: 400; }
.list { list-style: none; margin: 8px 0; padding: 0; }
.list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }

.btn { display: inline-block; padding: 7px 14px; font: inherit; font-weight: 600; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--accent-text); }
.btn.subtle { font-weight: 400; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.alert.error { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.validation-summary-valid { display: none; }
.validation ul { margin: 0; padding-left: 18px; }

.pill { display: inline-block; padding: 1px 9px; font-size: .8rem; font-weight: 600; border-radius: 999px; background: var(--line); color: var(--text); }
.pill.healthy, .pill.completed { background: var(--ok-bg); color: var(--ok); }
.pill.degraded, .pill.ringing, .pill.queued { background: var(--warn-bg); color: var(--warn); }
.pill.down, .pill.failed { background: var(--bad-bg); color: var(--bad); }
.pill.inprogress { background: var(--accent); color: var(--accent-text); }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: .85rem; font-weight: 600; }
tr:last-child td { border-bottom: 0; }

.recording { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.recording[hidden] { display: none; }
.recording audio { flex: 1 1 260px; min-width: 0; }
.chat-wrap { padding: 0; overflow: hidden; }
.legend { display: flex; justify-content: space-between; padding: 8px 16px; color: var(--muted); font-size: .85rem; border-bottom: 1px solid var(--line); }
.chat { display: flex; flex-direction: column; gap: 8px; padding: 16px; max-height: 62vh; overflow-y: auto; }
.chat:empty { display: none; }
.chat-wrap > .empty { padding: 16px; margin: 0; }
.bubble { max-width: min(70%, 900px); padding: 8px 12px; border-radius: 16px; overflow-wrap: anywhere; }
.bubble time { display: block; font-size: .72rem; opacity: .7; margin-top: 2px; }
.bubble.scammer { align-self: flex-start; background: var(--them); color: var(--them-text); border-bottom-left-radius: 4px; }
.bubble.ai { align-self: flex-end; background: var(--ai); color: var(--ai-text); border-bottom-right-radius: 4px; }
.bubble.system { align-self: center; max-width: 90%; background: transparent; color: var(--muted); font-size: .85rem; text-align: center; }
.bubble.interrupted .text::after { content: " (cut off)"; opacity: .75; font-style: italic; }
.typing { padding: 0 16px 12px; color: var(--muted); font-size: .87rem; font-style: italic; }
.typing[hidden] { display: none; }
@media (max-width: 560px) { .bubble { max-width: 88%; } }

/* Button icons: add data-icon="name" to a button. They take the button's text color. */
.btn[data-icon], .linklike[data-icon] { display: inline-flex; align-items: center; gap: 6px; }
.btn[hidden] { display: none; }
[data-icon]::before {
    content: ""; flex: none; width: 1em; height: 1em; background: currentColor;
    -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat;
}
[data-icon="loader"]::before { animation: icon-spin 1s linear infinite; }
@keyframes icon-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { [data-icon="loader"]::before { animation: none; } }
[data-icon="phone"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1 1 .4 1.9.7 2.8a2 2 0 0 1-.5 2.1L8.1 9.9a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.8.7a2 2 0 0 1 1.7 2z'/%3E%3C/svg%3E"); }
[data-icon="phone-off"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.7 13.3a16 16 0 0 1-2.6-3.4l1.2-1.3a2 2 0 0 0 .5-2.1c-.3-.9-.6-1.8-.7-2.8a2 2 0 0 0-2-1.7h-3a2 2 0 0 0-2 2.2 19.8 19.8 0 0 0 3.1 8.6c.6 1 1.3 1.8 2 2.6'/%3E%3Cpath d='M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19 19 0 0 1-2.7-2.1'/%3E%3Cpath d='M14.1 15.9l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.8.7a2 2 0 0 1 1.7 2'/%3E%3Cpath d='M22 2 2 22'/%3E%3C/svg%3E"); }
[data-icon="headphones"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 18v-6a9 9 0 0 1 18 0v6'/%3E%3Crect x='2.5' y='14' width='5' height='7' rx='2'/%3E%3Crect x='16.5' y='14' width='5' height='7' rx='2'/%3E%3C/svg%3E"); }
[data-icon="volume"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5 6 9H2v6h4l5 4z'/%3E%3Cpath d='M15.5 8.5a5 5 0 0 1 0 7'/%3E%3Cpath d='M19 5a10 10 0 0 1 0 14'/%3E%3C/svg%3E"); }
[data-icon="plus"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
[data-icon="check"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"); }
[data-icon="x"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E"); }
[data-icon="left"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M12 19l-7-7 7-7'/%3E%3C/svg%3E"); }
[data-icon="right"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M12 5l7 7-7 7'/%3E%3C/svg%3E"); }
[data-icon="save"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z'/%3E%3Cpath d='M17 21v-8H7v8M7 3v5h8'/%3E%3C/svg%3E"); }
[data-icon="play"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3l14 9-14 9z'/%3E%3C/svg%3E"); }
[data-icon="stop"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='5' width='14' height='14' rx='2'/%3E%3C/svg%3E"); }
[data-icon="loader"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 1 1-6.2-8.6'/%3E%3C/svg%3E"); }
[data-icon="trash"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6M10 11v6M14 11v6'/%3E%3C/svg%3E"); }
[data-icon="edit"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 3a2.8 2.8 0 0 1 4 4L7.5 20.5 2 22l1.5-5.5z'/%3E%3C/svg%3E"); }
[data-icon="filter"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 3H2l8 9.5V19l4 2v-8.5z'/%3E%3C/svg%3E"); }
[data-icon="star"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2l3.1 6.3 6.9 1-5 4.9 1.2 6.8-6.2-3.2L5.8 21 7 14.2 2 9.3l6.9-1z'/%3E%3C/svg%3E"); }
[data-icon="ban"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M4.9 4.9l14.2 14.2'/%3E%3C/svg%3E"); }
[data-icon="key"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7.5' cy='15.5' r='5.5'/%3E%3Cpath d='M11.4 11.6 21 2M16 7l3 3M19 4l2 2'/%3E%3C/svg%3E"); }
[data-icon="lock"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E"); }
[data-icon="unlock"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 9.9-1'/%3E%3C/svg%3E"); }
[data-icon="user-plus"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M19 8v6M22 11h-6'/%3E%3C/svg%3E"); }
[data-icon="log-in"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4M10 17l5-5-5-5M15 12H3'/%3E%3C/svg%3E"); }
[data-icon="log-out"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9'/%3E%3C/svg%3E"); }
[data-icon="refresh"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 0 1 15-6.7L21 8M21 3v5h-5M21 12a9 9 0 0 1-15 6.7L3 16M3 21v-5h5'/%3E%3C/svg%3E"); }
