/* Dashboard (dark) */
body.app { background: var(--bg); font-size: 15px; }
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; background: var(--bg); }
.side .brand { padding: 4px 8px 18px; }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--muted); padding: 8px 10px; border-radius: var(--r-sm); font-weight: 500; }
.side nav a:hover { background: var(--panel); color: var(--text); }
.side nav a[aria-current="page"] { background: var(--panel-2); color: var(--text); }
.side nav a svg { flex: none; opacity: .85; }
.side .foot { margin-top: auto; display: grid; gap: 10px; }
.wallet { display: block; text-decoration: none; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; background: var(--panel); }
.wallet span { display: block; color: var(--faint); font-size: 12.5px; }
.wallet b { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.userline { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 4px; font-size: 13px; color: var(--faint); }
.userline span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userline button { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 4px; }
.userline button:hover { color: var(--text); }
@media (max-width: 880px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { position: sticky; z-index: 5; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { padding: 0; margin-right: auto; }
  .side nav { order: 3; width: 100%; display: flex; overflow-x: auto; scrollbar-width: none; }
  .side nav a { white-space: nowrap; }
  .side .foot { margin: 0; display: flex; align-items: center; }
  .wallet { padding: 6px 10px; } .wallet span { display: none; } .wallet b { font-size: 15px; }
  .userline span { display: none; }
}

main.view { padding: 32px clamp(16px, 4vw, 48px) 96px; max-width: 1180px; width: 100%; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.head h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.head p { margin: 6px 0 0; color: var(--muted); }
.head .who { display: flex; gap: 14px; align-items: center; }

.card { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 20px; }
.card + .card { margin-top: 14px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.card .sub { color: var(--muted); margin: -8px 0 16px; font-size: 14px; }
.note { border: 1px solid rgba(242, 193, 78, .3); background: var(--turmeric-soft); border-radius: var(--r); padding: 12px 14px; margin-bottom: 18px; font-size: 14px; color: #EADBB0; }
.note b { color: var(--turmeric); font-weight: 600; }

.avatar { display: inline-grid; place-items: center; border-radius: 50%; font-weight: 600; color: var(--hue); background: color-mix(in srgb, var(--hue) 14%, transparent); border: 1px solid color-mix(in srgb, var(--hue) 40%, transparent); flex: none; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.live, .status.interested, .status.booked, .status.running, .status.done, .status.completed, .status.active { color: var(--leaf); border-color: var(--leaf-line); }
.status.callback, .status.retry, .status.calling, .status.ringing, .status.in_progress, .status.draft, .status.paused, .status.invite_sent { color: var(--turmeric); border-color: rgba(242, 193, 78, .35); }
.status.not_interested, .status.failed, .status.wrong_number, .status.busy, .status.no_answer, .status.not_connected { color: var(--chilli); border-color: rgba(255, 107, 87, .35); }

/* New-agent composer */
.composer { border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--panel); margin-bottom: 28px; transition: border-color .12s; }
.composer:focus-within { border-color: var(--leaf); }
.composer textarea { border: 0; background: transparent; padding: 16px 18px 6px; font-size: 16px; min-height: 72px; resize: none; box-shadow: none; }
.composer textarea:focus { box-shadow: none; }
.composer .bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.composer select { width: auto; padding: 7px 30px 7px 10px; font-size: 14px; }
.composer .bar .primary { margin-left: auto; }

.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.agent { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; text-decoration: none; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 16px; transition: border-color .12s; }
.agent:hover { border-color: var(--line-strong); }
.agent h3 { margin: 0; font-size: 15.5px; font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.agent p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }

/* Agent page */
.steps-row { display: flex; gap: 0; margin: 0 0 24px; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.steps-row li { flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 14px; color: var(--faint); background: var(--bg); }
.steps-row li + li { border-left: 1px solid var(--line); }
.steps-row li i { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 600; border: 1px solid var(--line-strong); }
.steps-row li.done { color: var(--muted); }
.steps-row li.done i { background: var(--leaf); border-color: var(--leaf); color: var(--leaf-ink); }
.steps-row li.now { color: var(--text); background: var(--panel); }
.steps-row li.now i { border-color: var(--leaf); color: var(--leaf); }
@media (max-width: 640px) { .steps-row { flex-direction: column; } .steps-row li + li { border-left: 0; border-top: 1px solid var(--line); } }

.split { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }

.call { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); position: sticky; top: 24px; overflow: hidden; }
@media (max-width: 980px) { .call { position: static; } }
.call .top { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; color: var(--muted); }
.call .top .timer { font-variant-numeric: tabular-nums; color: var(--text); }
.call .stage { display: grid; justify-items: center; gap: 6px; padding: 26px 18px 18px; }
.call .state { font-weight: 600; margin-top: 8px; }
.call .hint { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; text-align: center; min-height: 20px; }
.convo { display: grid; gap: 10px; max-height: 300px; overflow-y: auto; padding: 0 18px 16px; }
.convo:empty { display: none; }
.msg { font-size: 14px; line-height: 1.5; }
.msg small { display: block; font-size: 12px; color: var(--faint); margin-bottom: 2px; }
.msg.agent { border-left: 2px solid var(--leaf); padding-left: 10px; }
.msg.customer { border-left: 2px solid var(--line-strong); padding-left: 10px; color: var(--muted); }
.ring { border-top: 1px solid var(--line); padding: 14px 18px; }
.ring form { display: flex; gap: 8px; }

details.more { border-top: 1px solid var(--line); }
details.more:first-of-type { border-top: 0; }
details.more summary { cursor: pointer; font-weight: 500; padding: 14px 0; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.more summary::after { content: ''; width: 8px; height: 8px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); margin-right: 4px; transition: transform .15s; }
details.more[open] summary::after { transform: rotate(-135deg); }
details.more summary::-webkit-details-marker { display: none; }
details.more > div { padding: 2px 0 18px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; flex-wrap: wrap; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; padding: 7px 12px; font-size: 14px; color: var(--muted); }
.seg label + label span { border-left: 1px solid var(--line-strong); }
.seg input:checked + span { background: var(--leaf-soft); color: var(--leaf); }
.seg input:focus-visible + span { outline: 2px solid var(--leaf); outline-offset: -2px; }
.check { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; font-size: 14px; }

.savebar { position: sticky; bottom: 16px; margin-top: 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; border: 1px solid var(--line-strong); border-radius: var(--r); padding: 10px 10px 10px 16px; background: rgba(17, 24, 21, .92); backdrop-filter: blur(8px); }
.savebar span { color: var(--muted); font-size: 13.5px; }

/* Tables / lists */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--faint); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 13px; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--panel); }
.table td .sub { color: var(--faint); font-size: 13px; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; background: var(--bg); }
.table-wrap .table tr:last-child td { border-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 20px; }
.stat { background: var(--bg); padding: 16px 18px; }
.stat span { color: var(--faint); font-size: 13px; }
.stat b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.meter { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; display: flex; }
.meter i { display: block; height: 100%; }

.empty { border: 1px dashed var(--line-strong); border-radius: var(--r-lg); padding: 40px 28px; text-align: center; }
.empty h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.empty p { margin: 0 auto 18px; color: var(--muted); max-width: 46ch; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--faint); }
dl.kv dd { margin: 0; word-break: break-word; }
code.inline { background: var(--bg); border: 1px solid var(--line); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }

.drawer-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--panel); border-left: 1px solid var(--line); z-index: 21; overflow-y: auto; padding: 22px; }
.drawer .x { float: right; }
.drawer h2 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text); padding: 10px 16px; border-radius: var(--r-sm); z-index: 50; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
.toast.err { border-color: rgba(255, 107, 87, .5); color: #FFD3CC; }

/* Auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(400px, 100%); }
.auth-card .brand { margin-bottom: 32px; }
.auth-card h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; }
.auth-card > p { color: var(--muted); margin: 0 0 24px; }
.auth-card .switch { color: var(--muted); font-size: 14px; margin-top: 18px; }

.checks { list-style: none; padding: 0; margin: 10px 0 0; }
.checks li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.checks .ok { color: var(--leaf); }
.checks .no { color: var(--chilli); }
.convo .msg { display: block; border-top: 0; border-right: 0; border-bottom: 0; border-radius: 0; background: none; }
.userline button { white-space: nowrap; }

/* ---- client access, voices, enhance ---- */
.imp { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border: 1px solid var(--leaf-line); background: rgba(54, 199, 126, .08); border-radius: var(--r); padding: 10px 14px; margin-bottom: 18px; font-size: 14px; }
.imp b { color: var(--leaf); font-weight: 600; }
.note.warn { border-color: rgba(255, 107, 87, .35); background: rgba(255, 107, 87, .08); color: #F4C7BF; }
.note.warn b { color: var(--chilli); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -8px 0 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-selected="true"] { color: var(--text); border-bottom-color: var(--leaf); }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.cardhead h2 { margin: 0; }
.cardhead .muted { font-size: 13px; }
.enh { border: 1px solid var(--leaf-line); background: rgba(54, 199, 126, .06); border-radius: var(--r); padding: 14px; margin-bottom: 16px; font-size: 14px; }
.enh b { color: var(--leaf); font-weight: 600; }
.enh .enh-line { margin: 8px 0; color: var(--text); }
.enh pre { white-space: pre-wrap; font: inherit; color: var(--muted); margin: 0 0 8px; }
.enh ul { margin: 0 0 12px; padding-left: 18px; color: var(--muted); }
.linkbox { margin-top: 16px; border: 1px solid var(--line-strong); border-radius: var(--r); padding: 12px 14px; background: var(--panel-2); }
.linkbox p { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.linkrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.linkrow code { flex: 1 1 260px; overflow-wrap: anywhere; }
.inline-form { display: flex; gap: 6px; margin-top: 6px; }
.inline-form input { width: 96px; padding: 6px 10px; }
details.card.more { padding-top: 4px; padding-bottom: 4px; }
td select { padding: 6px 10px; }
