/* EM Quick Close Agent dashboard — hand-written styles, no build step needed. */

:root {
    --ink: #1f2a33;
    --ink-soft: #55636e;
    --ink-faint: #8a969e;
    --paper: #fafbf8;
    --panel: #edf1ee;
    --panel-deep: #e2e8e4;
    --line: #d6ddd8;
    --white: #ffffff;

    --green: #0e6b57;
    --green-soft: #dcefe8;
    --amber: #d9961f;
    --amber-soft: #fbefd6;
    --red: #b8432f;
    --red-soft: #f8e3de;
    --blue: #2f5f8a;
    --blue-soft: #e1ebf4;

    --radius-s: 6px;
    --radius-m: 10px;

    --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
    --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;

    --sidebar: 232px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 15px/1.55 var(--font-body);
    font-variant-numeric: tabular-nums;
    overflow-x: hidden;
    overflow-wrap: break-word;
}

img, svg, video, audio { max-width: 100%; }

a { color: var(--green); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 650;
    line-height: 1.2;
    margin: 0;
    letter-spacing: -0.01em;
}
h1 { font-size: 28px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

p { margin: 0 0 0.8em; }

:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 2px;
    border-radius: 4px;
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* ---------- Shell ---------- */

.shell {
    display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh;
    background: linear-gradient(to right, var(--panel) calc(var(--sidebar) - 1px), var(--line) calc(var(--sidebar) - 1px), var(--line) var(--sidebar), transparent var(--sidebar));
}

.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 22px 14px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 0 8px;
    color: var(--ink); text-decoration: none;
    font-family: var(--font-display); font-weight: 700; font-size: 18px;
}
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--green); color: var(--white);
    display: grid; place-items: center;
}
.brand-mark svg { width: 17px; height: 17px; }
.logo-mark { width: 34px; height: 34px; flex: none; display: block; }
.logo-word { display: flex; flex-direction: column; line-height: 1.05; }
.logo-name { font-size: 16.5px; letter-spacing: -0.01em; white-space: nowrap; }
.logo-sub {
    font-family: var(--font-body); font-size: 10.5px; font-weight: 700;
    letter-spacing: .2em; text-transform: uppercase; color: var(--green); margin-top: 3px;
}
.brand-on-dark { color: #fff; }
.brand-on-dark .logo-sub { color: #f2c46d; }
.brand-on-dark .logo-mark { border-radius: 10px; box-shadow: 0 0 0 2px rgba(255,255,255,.28); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius-s);
    color: var(--ink-soft); text-decoration: none; font-weight: 600;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--panel-deep); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--white); color: var(--ink); box-shadow: inset 3px 0 0 var(--green); }

.sidebar-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.sidebar-foot form { margin: 0; }
.nav-user, .nav-button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 8px 10px; border-radius: var(--radius-s);
    color: var(--ink-soft); font-weight: 600; font: inherit; font-weight: 600; text-align: left;
}
.nav-button { background: none; border: 0; cursor: pointer; }
.nav-button:hover { background: var(--panel-deep); color: var(--ink); }
.nav-user svg, .nav-button svg { width: 18px; height: 18px; flex: none; }

.engine-pill { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.engine-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.engine-pill.is-online::before { background: var(--green); }
.engine-pill.is-offline::before { background: var(--red); }

.main { min-width: 0; padding: 28px 40px 60px; }
.page { max-width: 1180px; }

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 20px; flex-wrap: wrap;
    padding-bottom: 18px; margin-bottom: 26px;
    border-bottom: 1px solid var(--line);
}
.page-head p { margin: 6px 0 0; color: var(--ink-soft); max-width: 62ch; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: 14px; color: var(--ink-soft); text-decoration: none; display: inline-block; margin-bottom: 6px; }
.crumb:hover { color: var(--ink); }

.mobile-bar { display: none; }

/* ---------- Buttons & forms ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 38px; padding: 0 16px;
    border: 1px solid transparent; border-radius: var(--radius-s);
    font: 600 14.5px/1 var(--font-body);
    text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: background-color .12s, border-color .12s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:hover { background: #0b5948; color: var(--white); }
.btn-quiet { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn-quiet:hover { border-color: var(--ink-faint); color: var(--ink); }
.btn-amber { background: var(--amber); color: #2b1d02; }
.btn-amber:hover { background: #c4851a; color: #2b1d02; }
.btn-danger { background: var(--white); color: var(--red); border-color: #e6c3bb; }
.btn-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--ink-soft); font-weight: 600; }
.btn-link:hover { color: var(--ink); }
.btn-small { min-height: 30px; padding: 0 11px; font-size: 13.5px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

form.inline { display: inline; margin: 0; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field label, .field-label { font-weight: 700; font-size: 14px; }
.hint { font-size: 13.5px; color: var(--ink-soft); margin: 0; }
.field .hint code { font-size: 13px; background: var(--panel); padding: 1px 5px; border-radius: 4px; }

.input, .select, .textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    background: var(--white);
    color: var(--ink);
    font: 15px/1.45 var(--font-body);
    padding: 9px 11px;
}
.textarea { min-height: 110px; resize: vertical; }
.textarea.tall { min-height: 260px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--red); }
.error-text { color: var(--red); font-size: 13.5px; font-weight: 600; margin: 0; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.check input { margin-top: 3px; accent-color: var(--green); width: 16px; height: 16px; }
.check strong { display: block; }
.field .check, .field label.check { font-weight: 400; font-size: 14.5px; }

.day-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.day-picker label {
    position: relative; cursor: pointer;
}
.day-picker input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.day-picker span {
    display: inline-block; min-width: 50px; text-align: center;
    padding: 7px 0; border: 1px solid var(--line); border-radius: var(--radius-s);
    background: var(--white); font-weight: 600; font-size: 14px; color: var(--ink-soft);
}
.day-picker input:checked + span { background: var(--green); border-color: var(--green); color: var(--white); }
.day-picker input:focus-visible + span { outline: 2px solid var(--green); outline-offset: 2px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.form-grid .span-2 { grid-column: span 2; }

.form-section {
    display: grid; grid-template-columns: 260px 1fr; gap: 28px;
    padding: 26px 0; border-bottom: 1px solid var(--line);
}
.form-section:first-of-type { padding-top: 0; }
.form-section > header p { color: var(--ink-soft); font-size: 14px; margin-top: 6px; }
.form-foot { display: flex; gap: 10px; justify-content: flex-end; padding-top: 22px; }

/* ---------- Alerts ---------- */

.flash {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 14px; margin-bottom: 20px;
    border-radius: var(--radius-s); border: 1px solid;
    font-weight: 600;
}
.flash svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.flash-success { background: var(--green-soft); border-color: #b5dccd; color: #0a4f40; }
.flash-error { background: var(--red-soft); border-color: #ecc4ba; color: #7d2a1b; }
.flash-warn { background: var(--amber-soft); border-color: #efd39b; color: #6b4708; }

/* ---------- Panels ---------- */

.panel {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
}
.panel-head {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel-head p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-soft); }
.panel-body { padding: 18px; }
.panel-body > :last-child { margin-bottom: 0; }

.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 24px; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 9px 2px 8px; border-radius: 999px;
    font-size: 12.5px; font-weight: 700; white-space: nowrap;
    background: var(--panel); color: var(--ink-soft);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.tone-good { background: var(--green-soft); color: #0a5a49; }
.badge.tone-bad { background: var(--red-soft); color: #8c3121; }
.badge.tone-warn { background: var(--amber-soft); color: #7a510a; }
.badge.tone-info { background: var(--blue-soft); color: var(--blue); }
.badge.tone-live { background: var(--amber); color: #2b1d02; }
.badge.tone-live::before { animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .25; } }

/* ---------- Phone lines board (dashboard signature) ---------- */

.lines {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-m);
    overflow: hidden;
    background: var(--white);
}
.line {
    position: relative;
    padding: 14px 16px 16px 22px;
    min-height: 104px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin: 0 -1px -1px 0;
}
.line::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
    background: var(--panel-deep);
}
.line-no { font-size: 12.5px; color: var(--ink-faint); font-weight: 700; }
.line-idle { color: var(--ink-faint); margin-top: 18px; font-size: 14px; }
.line.is-live::before { background: var(--amber); }
.line.is-live { background: linear-gradient(90deg, #fff9ec, var(--white) 70%); }
.line-who { font-family: var(--font-display); font-weight: 650; font-size: 16px; margin-top: 6px; display: block; color: var(--ink); text-decoration: none; }
.line-who:hover { color: var(--green); }
.line-meta { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.line .badge { margin-top: 10px; }

/* ---------- Figures strip ---------- */

.figures {
    display: grid; grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    margin: 26px 0;
}
.figure { padding: 16px 20px 16px 0; }
.figure + .figure { padding-left: 20px; border-left: 1px solid var(--line); }
.figure-value { font-family: var(--font-display); font-size: 30px; font-weight: 600; line-height: 1.1; }
.figure-label { font-size: 14px; color: var(--ink-soft); margin-top: 4px; }
.figure-label small { display: block; color: var(--ink-faint); font-size: 12.5px; }

/* ---------- Week bars ---------- */

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; align-items: end; height: 150px; padding-top: 8px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.week-bar { width: 100%; max-width: 34px; background: var(--panel-deep); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.week-bar span { position: absolute; left: 0; right: 0; bottom: 0; background: var(--green); border-radius: 4px 4px 0 0; }
.week-label { font-size: 12.5px; color: var(--ink-soft); }
.week-count { font-size: 12.5px; font-weight: 700; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-soft); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Outcome rows ---------- */

.outcomes { list-style: none; margin: 0; padding: 0; }
.outcomes li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.outcomes li:last-child { border-bottom: 0; }
.outcomes .meter { grid-column: span 2; height: 6px; background: var(--panel); border-radius: 3px; overflow: hidden; }
.outcomes .meter span { display: block; height: 100%; background: var(--ink-faint); }
.outcomes .meter.tone-good span { background: var(--green); }
.outcomes .meter.tone-warn span { background: var(--amber); }
.outcomes .meter.tone-bad span { background: var(--red); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th {
    text-align: left; font-weight: 700; font-size: 13px; color: var(--ink-soft);
    padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--paper);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #f6f8f6; }
.table .num { text-align: right; white-space: nowrap; }
.table .muted, .muted { color: var(--ink-soft); }
.table .who { white-space: nowrap; font-weight: 700; color: var(--ink); text-decoration: none; }
.table .who:hover { color: var(--green); }
.table .sub { display: block; font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.table .clip { max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table .summary { min-width: 200px; color: var(--ink-soft); font-size: 14px; }

/* One-line remark that opens on tap/click */
.remark {
    display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
    width: 100%; max-width: 52ch; padding: 0; margin: 0; border: 0; background: none;
    font: inherit; color: inherit; text-align: left; cursor: pointer;
    line-height: 1.45;
}
.remark:hover { color: var(--ink); }
.remark.is-open { display: block; -webkit-line-clamp: unset; color: var(--ink); white-space: normal; }
.row-link { cursor: pointer; }

/* ---------- Toolbar / filters ---------- */

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.toolbar .input, .toolbar .select { width: auto; min-width: 150px; padding: 7px 10px; font-size: 14px; }
.toolbar .grow { flex: 1; min-width: 200px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    display: inline-flex; gap: 6px; align-items: center;
    padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
    background: var(--white); color: var(--ink-soft); font-size: 13.5px; font-weight: 600; text-decoration: none;
}
.chip b { color: var(--ink); }
.chip:hover { border-color: var(--ink-faint); color: var(--ink); }
.chip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--white); }
.chip[aria-current="true"] b { color: var(--white); }

/* ---------- Progress ---------- */

.progress { height: 10px; background: var(--panel); border-radius: 5px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--green); transition: width .6s ease; }
.progress-row { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-soft); margin-bottom: 8px; }
.progress-row strong { color: var(--ink); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 9px 18px; margin: 0; font-size: 14.5px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; font-weight: 600; }
.kv-wide { grid-template-columns: minmax(120px, 34%) 1fr; }
.kv-wide dd { font-weight: 500; white-space: pre-line; overflow-wrap: anywhere; }
@media (max-width: 560px) { .kv-wide { grid-template-columns: 1fr; gap: 2px 0; } .kv-wide dd { margin-bottom: 10px; } }

/* ---------- Campaign list ---------- */

.campaign-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) auto; gap: 24px; align-items: center; padding: 18px; border-bottom: 1px solid var(--line); }
.campaign-row:last-child { border-bottom: 0; }
.campaign-row h3 a { color: var(--ink); text-decoration: none; }
.campaign-row h3 a:hover { color: var(--green); }
.campaign-row .muted { font-size: 13.5px; margin-top: 3px; }

/* ---------- Agents ---------- */

.agent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 18px; }
.agent {
    display: flex; flex-direction: column; gap: 12px;
    padding: 18px; background: var(--white);
    border: 1px solid var(--line); border-radius: var(--radius-m);
}
.agent-top { display: flex; gap: 12px; align-items: center; }
.avatar {
    width: 44px; height: 44px; border-radius: 50%;
    display: grid; place-items: center; flex: none;
    background: var(--green-soft); color: var(--green);
    font-family: var(--font-display); font-weight: 700; font-size: 18px;
}
.avatar.is-male { background: var(--blue-soft); color: var(--blue); }
.agent h3 a { color: var(--ink); text-decoration: none; }
.agent h3 a:hover { color: var(--green); }
.agent-goal { color: var(--ink-soft); font-size: 14px; margin: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.agent-foot { display: flex; gap: 14px; font-size: 13.5px; color: var(--ink-soft); padding-top: 12px; border-top: 1px solid var(--line); margin-top: auto; }
.agent-foot b { color: var(--ink); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tabs a {
    padding: 10px 14px; margin-bottom: -1px;
    color: var(--ink-soft); font-weight: 700; text-decoration: none;
    border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--green); }

.source { display: grid; grid-template-columns: 38px 1fr auto; gap: 14px; align-items: start; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.source:last-child { border-bottom: 0; }
.source-icon { width: 38px; height: 38px; border-radius: 8px; background: var(--panel); display: grid; place-items: center; color: var(--ink-soft); }
.source-icon svg { width: 18px; height: 18px; }
.source h3 { font-family: var(--font-body); font-size: 15px; font-weight: 700; }
.source .muted { font-size: 13.5px; }
.source-actions { display: flex; gap: 8px; align-items: center; }
.source-preview { margin-top: 8px; font-size: 13.5px; color: var(--ink-soft); white-space: pre-line; max-height: 4.6em; overflow: hidden; }

.adder { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-bottom: 1px solid var(--line); }
.adder button {
    background: none; border: 0; border-right: 1px solid var(--line);
    padding: 14px; text-align: left; cursor: pointer;
    font: inherit; color: var(--ink);
    display: flex; flex-direction: column; justify-content: flex-start;
}
.adder button:last-child { border-right: 0; }
.adder button strong { display: block; font-size: 14.5px; }
.adder button span { font-size: 13px; color: var(--ink-soft); }
.adder button[aria-pressed="true"] { background: var(--green-soft); box-shadow: inset 0 -2px 0 var(--green); }
.adder-form { padding: 18px; border-bottom: 1px solid var(--line); background: #fcfdfc; }
[hidden] { display: none !important; }

.knowledge-meter { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--ink-soft); }

.prompt-box {
    white-space: pre-wrap; font: 13.5px/1.6 var(--font-body);
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s);
    padding: 16px; max-height: 560px; overflow: auto; margin: 0;
}

/* ---------- Call detail ---------- */

.call-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.call-hero .avatar { width: 52px; height: 52px; font-size: 20px; background: var(--panel); color: var(--ink); }

.player { display: flex; gap: 14px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--paper); border-radius: var(--radius-m) var(--radius-m) 0 0; }
.player audio { flex: 1; height: 38px; }

.script { padding: 8px 0; }
.script-turn { display: grid; grid-template-columns: 110px 1fr; gap: 16px; padding: 10px 18px; }
.script-turn + .script-turn { border-top: 1px dashed #e5eae6; }
.script-who { font-weight: 700; font-size: 13.5px; color: var(--ink-soft); padding-top: 2px; text-align: right; }
.script-turn.is-agent .script-who { color: var(--green); }
.script-turn.is-agent .script-text { color: var(--ink); }
.script-turn.is-person .script-text { color: #2c3943; }
.script-text { margin: 0; }

.callout {
    padding: 16px 18px; border-radius: var(--radius-m);
    background: var(--green-soft); border: 1px solid #b5dccd;
}
.callout h2 { font-size: 16px; margin-bottom: 6px; }
.callout p:last-child { margin-bottom: 0; }

/* ---------- Dialer ---------- */

.dialer { display: grid; grid-template-columns: 260px 1fr; }
.dialer-pad { padding: 18px; border-right: 1px solid var(--line); background: var(--paper); border-radius: var(--radius-m) 0 0 var(--radius-m); }
.dialer-details { padding: 18px; }
.dialer-number { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: .02em; padding: 10px 12px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
    height: 52px; border: 1px solid var(--line); border-radius: var(--radius-s);
    background: var(--white); color: var(--ink);
    font: 600 20px/1 var(--font-display); cursor: pointer;
}
.key:hover { border-color: var(--ink-faint); }
.key:active { background: var(--panel); }
.key-back { font-size: 18px; color: var(--ink-soft); }
.btn-call { min-height: 46px; padding: 0 26px; font-size: 16px; }

/* ---------- Payments ---------- */

.month-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.month-nav strong { font-family: var(--font-display); font-size: 18px; min-width: 150px; text-align: center; }

.share { margin: -6px 0 26px; }
.share-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--panel); }
.share-bar span { display: block; height: 100%; }
.share-bar span + span { border-left: 2px solid var(--paper); }
.share-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13.5px; color: var(--ink-soft); }
.share-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.share-legend b { color: var(--ink); margin-left: 4px; }

.add-bill { margin-bottom: 24px; }
.add-bill > summary { cursor: pointer; list-style: none; }
.add-bill > summary::-webkit-details-marker { display: none; }
.add-bill:not([open]) > summary { border-bottom: 0; }
.add-bill[open] > summary .btn { transform: rotate(45deg); }

.expense-title { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.expense-title > i { width: 12px; height: 12px; border-radius: 3px; margin-top: 6px; flex: none; }
.expense-title p .muted { display: block; font-size: 13px; }
.expense-total { display: flex; align-items: center; gap: 12px; }
.expense-total strong { font-family: var(--font-display); font-size: 20px; }
.expense-empty { padding: 14px 18px; color: var(--ink-faint); font-size: 14px; }
.usage { border-bottom: 1px solid var(--line); }
.usage-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; font-size: 14px; color: var(--ink-soft); }
.usage-head b { color: var(--ink); }
.usage .table th { background: var(--white); }
.usage-note { padding: 10px 18px 14px; }
.bill-actions { white-space: nowrap; }
.table.bills { table-layout: fixed; }
.table.bills td { overflow-wrap: anywhere; }
.bill-actions .btn { margin-left: 4px; }

/* ---------- Try in browser ---------- */

.talk { display: flex; flex-direction: column; }
.talk-start { padding: 22px 18px; display: flex; flex-direction: column; gap: 14px; max-width: 460px; }
.talk-log { height: 440px; overflow-y: auto; padding: 10px 0; border-bottom: 1px solid var(--line); background: var(--paper); }
.talk-turn { display: grid; grid-template-columns: 96px 1fr; gap: 14px; padding: 9px 18px; }
.talk-who { font-weight: 700; font-size: 13.5px; color: var(--ink-soft); text-align: right; padding-top: 2px; }
.talk-turn.is-agent .talk-who { color: var(--green); }
.talk-text { margin: 0; }
.talk-turn.is-interim .talk-text, .talk-turn.is-thinking .talk-text { color: var(--ink-faint); font-style: italic; }
.talk-turn.is-system { grid-template-columns: 1fr; }
.talk-turn.is-system .talk-text { text-align: center; font-size: 13.5px; color: var(--ink-soft); }
.talk-again { display: flex; justify-content: center; padding: 10px; }
.talk-bar { display: flex; gap: 10px; align-items: center; padding: 12px 14px; }
.talk-type { flex: 1; display: flex; gap: 8px; min-width: 0; }
.talk-type .input { min-width: 0; }
.mic {
    width: 48px; height: 48px; flex: none; border-radius: 50%;
    border: 1px solid var(--line); background: var(--white); color: var(--ink-soft);
    display: grid; place-items: center; cursor: pointer;
}
.mic svg { width: 22px; height: 22px; }
.mic.is-on { background: var(--green); border-color: var(--green); color: var(--white); box-shadow: 0 0 0 5px var(--green-soft); }
.mic:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Empty states ---------- */

.empty { padding: 38px 24px; text-align: center; color: var(--ink-soft); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { max-width: 52ch; margin: 0 auto 14px; }

/* ---------- Pagination ---------- */

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-soft); }
.pager-links { display: flex; gap: 6px; }

/* ---------- Login ---------- */

.auth {
    min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr;
}
.auth-art {
    background: var(--green); color: #e5f3ee;
    padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
    position: relative; overflow: hidden;
}
.auth-art h1 { color: var(--white); font-size: 40px; max-width: 14ch; }
.auth-art p { max-width: 40ch; font-size: 16px; }
.auth-lines { position: absolute; right: -40px; bottom: 80px; width: 70%; opacity: .5; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-form form { width: 100%; max-width: 360px; }
.auth-form h2 { font-size: 26px; margin-bottom: 6px; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .split { grid-template-columns: 1fr; }
    .figures { grid-template-columns: repeat(2, 1fr); }
    .figure:nth-child(3) { padding-left: 0; border-left: 0; }
    .figure:nth-child(n+3) { border-top: 1px solid var(--line); }
    .form-section { grid-template-columns: 1fr; gap: 12px; }
}

@media (max-width: 820px) {
    .shell { grid-template-columns: 1fr; background: none; }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(20, 30, 36, .35); }
    .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20; }
    .main { padding: 22px 18px 50px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .campaign-row { grid-template-columns: 1fr; gap: 12px; }
    .lines { grid-template-columns: repeat(2, 1fr); }
    .line { min-height: 84px; padding: 12px 12px 12px 18px; }
    .line-idle { margin-top: 10px; }
    .adder { grid-template-columns: 1fr; }
    .dialer { grid-template-columns: 1fr; }
    .dialer-pad { border-right: 0; border-bottom: 1px solid var(--line); border-radius: var(--radius-m) var(--radius-m) 0 0; }
    .adder button { border-right: 0; border-bottom: 1px solid var(--line); }
    .script-turn { grid-template-columns: 1fr; gap: 2px; }
    .script-who { text-align: left; }
    .auth { grid-template-columns: 1fr; }
    .auth-art { display: none; }
    h1 { font-size: 24px; }
}


/* ---------- Phones ---------- */

@media (max-width: 820px) {
    .page-head { gap: 14px; margin-bottom: 20px; }
    .page-head > div:first-child { min-width: 0; width: 100%; }
    .page-actions { width: 100%; }
    .page-actions .btn, .page-actions form.inline { flex: 1 1 auto; }
    .page-actions form.inline .btn { width: 100%; }
    .page-actions .engine-pill { width: 100%; }
    h1 { font-size: 23px; overflow-wrap: anywhere; }

    .input, .select, .textarea { font-size: 16px; } /* stops iPhone from zooming in */

    .figures { margin: 20px 0; }
    .figure { padding: 12px 12px 12px 0; }
    .figure + .figure { padding-left: 12px; }
    .figure:nth-child(odd) { padding-left: 0; border-left: 0; }
    .figure-value { font-size: 24px; }

    .panel-head { padding: 12px 14px; flex-wrap: wrap; }
    .panel-body { padding: 14px; }

    .toolbar { padding: 10px 12px; }
    .toolbar .input, .toolbar .select, .toolbar .btn { width: 100%; min-width: 0; flex: 1 1 100%; }
    .chips { width: 100%; }

    .tabs { gap: 0; }
    .tabs a { flex: 1; text-align: center; padding: 10px 6px; font-size: 14px; }

    .source { grid-template-columns: 34px minmax(0, 1fr); gap: 10px; padding: 12px 14px; }
    .source-actions { grid-column: 2; }
    .source-icon { width: 34px; height: 34px; }

    .kv { grid-template-columns: minmax(0, 40%) minmax(0, 1fr); }
    .kv dd { overflow-wrap: anywhere; }

    .call-hero .avatar { width: 44px; height: 44px; }
    .player { flex-wrap: wrap; padding: 12px; }
    .player audio { width: 100%; flex: 1 1 100%; }

    .pager { flex-wrap: wrap; gap: 8px; }

    .form-section { padding: 20px 0; }
    .form-foot { flex-direction: column-reverse; }
    .form-foot .btn { width: 100%; }

    .btn-call { width: 100%; }
    .talk-log { height: 56vh; }
    .talk-turn { grid-template-columns: 1fr; gap: 2px; padding: 8px 14px; }
    .talk-who { text-align: left; }
    .talk-bar { flex-wrap: wrap; }
    .talk-type { order: 3; flex-basis: 100%; }
    .month-nav { justify-content: space-between; }
    .month-nav strong { min-width: 0; }
    .expense-total { width: 100%; justify-content: space-between; padding-left: 24px; }
    .table-stack td.bill-actions { padding-top: 8px; }
    .table-stack colgroup { display: none; }
    .table-stack td.empty-cell { display: none; }
    .table-stack td.bill-actions .btn { margin: 0 6px 0 0; }
    .pv-banner { left: 12px; right: 12px; max-width: none; }

    /* Tables become stacked rows: no sideways scrolling */
    .table-wrap { overflow-x: visible; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack thead { display: none; }
    .table-stack tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table-stack tbody tr:hover td { background: none; }
    .table-stack td { border: 0; padding: 3px 0; max-width: none; text-align: left; }
    .table-stack td.cell-main { padding-bottom: 6px; }
    .table-stack td.cell-main .who { white-space: normal; font-size: 15.5px; }
    .table-stack td[data-label] { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px; align-items: baseline; font-size: 14px; }
    .table-stack td[data-label]::before { content: attr(data-label); color: var(--ink-faint); font-size: 13px; font-weight: 700; }
    .table-stack td.num { text-align: left; }
    .table-stack td.summary { width: 100%; min-width: 0; }
    .table-stack td[data-label] .badge { justify-self: start; }
    .table-stack td[data-label] > .sub { grid-column: 2; margin-top: -4px; }
    .table-stack .clip { max-width: none; white-space: normal; }
    .table-stack .sub { white-space: normal; }
    .table-stack .remark { max-width: none; }
}

@media (max-width: 420px) {
    .main { padding: 18px 14px 44px; }
    .figures { grid-template-columns: 1fr 1fr; }
    .lines { grid-template-columns: 1fr 1fr; }
    .line-who { font-size: 15px; }
    .keypad .key { height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Company details ---------- */

.static-field {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    min-height: 40px; padding: 8px 12px; border-radius: var(--radius-s);
    background: var(--panel-deep); font-weight: 700;
}
.static-field .btn-link { font-size: 13px; color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
.company-text {
    white-space: pre-wrap; overflow-wrap: anywhere;
    font-size: 15px; line-height: 1.65; color: var(--ink);
    max-height: 520px; overflow: auto;
}
.company-basics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px 24px; margin-bottom: 18px; }
.company-basics dt { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.company-basics dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.shared-note {
    display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(14,107,87,.07), rgba(14,107,87,.02));
}
.shared-note h3 { font-size: 15px; margin-bottom: 2px; }
.shared-note p { color: var(--ink-soft); font-size: 13.5px; max-width: 60ch; }
.agent-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); text-decoration: none; color: var(--ink); }
.agent-row:last-child { border-bottom: 0; }
.agent-row .avatar { width: 32px; height: 32px; font-size: 13px; }
.agent-row span.muted { margin-left: auto; font-size: 13px; }

/* ---------- Interested ---------- */

.nav-count {
    margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px;
    background: var(--amber, #d9961f); color: #fff; font-size: 12px; font-weight: 700; text-align: center;
}
.tab-count { margin-left: 4px; font-size: 12.5px; color: var(--ink-faint); font-weight: 700; }
.tabs a[aria-current="page"] .tab-count { color: var(--green); }
.select-small { min-height: 32px; padding: 0 28px 0 10px; font-size: 13.5px; font-weight: 700; width: auto; }
.follow-new { color: #9a6a12; }
.follow-contacted { color: var(--blue); }
.follow-won { color: var(--green); }
.follow-lost { color: var(--ink-soft); }
.follow-form { margin: 0; }
.next-cell .appt { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.next-cell .appt svg { width: 15px; height: 15px; color: var(--green); }
.table .next-cell { min-width: 210px; max-width: 260px; }
.table .next-cell .sub { white-space: normal; line-height: 1.4; margin-top: 2px; }
.table td .sub.clip { display: block; max-width: 170px; }
.table .source-cell { max-width: 150px; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { white-space: nowrap; flex: none; }
.follow-panel textarea { min-height: 90px; }

/* ---------- Live call test ---------- */

.live-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 10px 0 6px; }
.live-people { display: flex; align-items: center; justify-content: center; gap: 18px; width: 100%; max-width: 520px; }
.live-person { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 110px; text-align: center; }
.live-person .muted { font-size: 13px; }
.live-avatar {
    --level: 0;
    width: 76px; height: 76px; font-size: 22px;
    box-shadow: 0 0 0 calc(4px + var(--level) * 14px) rgba(14, 107, 87, calc(.08 + var(--level) * .22));
    transition: box-shadow .08s linear;
}
.live-avatar.is-you { background: var(--panel-deep); color: var(--ink); font-size: 15px; }
.live-line { flex: 1; height: 2px; background: var(--line); position: relative; overflow: hidden; border-radius: 2px; margin-bottom: 44px; }
.live-line span { position: absolute; inset: 0; width: 30%; background: var(--green); transform: translateX(-120%); opacity: 0; }
.live.is-live .live-line span { opacity: 1; animation: live-flow 1.6s ease-in-out infinite; }
@keyframes live-flow { to { transform: translateX(420%); } }
.live-timer { font-family: var(--font-display); font-size: 34px; font-weight: 600; font-variant-numeric: tabular-nums; }
.live-start { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 420px; }
.live-actions, .live-done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.live-done { text-align: center; }
.live-done p { margin-bottom: 12px; }
.try-list { padding-left: 18px; margin: 0; display: grid; gap: 6px; }
@media (prefers-reduced-motion: reduce) { .live.is-live .live-line span { animation: none; } .live-avatar { transition: none; } }
