/* Neutral graphite base. Green is reserved for calling, red for ending/missing calls, ink for primary actions. */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f3f3f0;
  --surface-3: #eaeae6;
  --border: #e4e4df;
  --border-strong: #d3d3cc;
  --text: #1c1c1a;
  --muted: #6c6c66;
  --faint: #9b9b94;

  --ink: #1c1c1a;
  --ink-hover: #34342f;
  --on-ink: #ffffff;

  --accent: #0d8a5c;
  --accent-hover: #0a7550;
  --accent-soft: #e2f3eb;
  --on-accent: #ffffff;

  --good: #0d8a5c;
  --good-soft: #e2f3eb;
  --bad: #c42f3c;
  --bad-soft: #fbe9eb;
  --danger: #d33a46;
  --danger-hover: #ba2f3a;
  --on-danger: #ffffff;
  --warn: #9a5b05;
  --warn-soft: #fbf1de;
  --info: #3d5a9e;
  --info-soft: #e9eef8;

  --ring: color-mix(in srgb, var(--accent) 45%, transparent);
  --shadow-sm: 0 1px 2px rgba(24, 24, 18, 0.05);
  --shadow: 0 1px 2px rgba(24, 24, 18, 0.04), 0 2px 8px rgba(24, 24, 18, 0.04);
  --shadow-lg: 0 2px 6px rgba(24, 24, 18, 0.06), 0 18px 48px rgba(24, 24, 18, 0.16);
  --backdrop: rgba(20, 20, 16, 0.42);

  --radius: 14px;
  --radius-ctl: 9px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0e;
    --surface: #171716;
    --surface-2: #1f1f1d;
    --surface-3: #292926;
    --border: #2a2a27;
    --border-strong: #3a3a36;
    --text: #ececea;
    --muted: #a2a29b;
    --faint: #75756f;

    --ink: #ececea;
    --ink-hover: #ffffff;
    --on-ink: #141413;

    --accent: #34c48b;
    --accent-hover: #4dd39c;
    --accent-soft: rgba(52, 196, 139, 0.13);
    --on-accent: #062a1c;

    --good: #4fcf98;
    --good-soft: rgba(79, 207, 152, 0.12);
    --bad: #f27a83;
    --bad-soft: rgba(242, 122, 131, 0.12);
    --danger: #e5484d;
    --danger-hover: #ec5d62;
    --on-danger: #ffffff;
    --warn: #eeb35a;
    --warn-soft: rgba(238, 179, 90, 0.11);
    --info: #98ade6;
    --info-soft: rgba(152, 173, 230, 0.13);

    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 20px 60px rgba(0, 0, 0, 0.6);
    --backdrop: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; scrollbar-gutter: stable; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -0.012em; text-wrap: balance; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.ic { width: 16px; height: 16px; flex: none; display: block; }
.ic.lg { width: 20px; height: 20px; }
.ic.xl { width: 26px; height: 26px; }
.ic.hangup { transform: rotate(135deg); }

/* ---------- header ---------- */
.topbar {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 0 20px; min-height: 56px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.brand { font-weight: 650; letter-spacing: -0.015em; display: flex; align-items: center; gap: 10px; font-size: 0.95rem; white-space: nowrap; }
.brand-sub { color: var(--muted); font-weight: 500; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; flex: none;
}
.brand-mark .ic { width: 15px; height: 15px; }
.nav { display: flex; gap: 2px; align-items: center; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-3); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.user { display: flex; align-items: center; gap: 9px; padding-right: 10px; margin-right: 4px; border-right: 1px solid var(--border); }
.user-text { display: grid; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 0.85rem; }
.user-role { color: var(--muted); font-size: 0.75rem; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--surface-3); color: var(--text);
  display: grid; place-items: center; font-size: 0.72rem; font-weight: 650; letter-spacing: 0.02em; flex: none;
}
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 0; background: none;
  color: var(--muted); cursor: pointer;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
@media (max-width: 640px) {
  .topbar-inner { gap: 8px 10px; padding: 8px 16px; }
  .brand-sub, .user-text { display: none; }
  .nav { order: 3; width: 100%; }
  .user { border-right: 0; padding-right: 0; }
}

main { max-width: 1160px; margin: 0 auto; padding: 24px 20px 56px; }
@media (max-width: 640px) { main { padding: 16px 16px 48px; } }

/* ---------- cards & layout ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-phone { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 920px) { .grid-phone { grid-template-columns: 372px 1fr; } }
.stack { display: grid; gap: 14px; }
.stack.loose { gap: 20px; }
.stack.tight { gap: 6px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 3px; }
.page-head .row { flex-wrap: nowrap; }
.page-head select { width: auto; min-width: 170px; }
.empty { padding: 40px 12px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 8px; }
.empty .ic { width: 22px; height: 22px; color: var(--faint); }
.empty h2 { color: var(--text); }

/* ---------- forms ---------- */
label.field { display: grid; gap: 6px; font-size: 0.82rem; font-weight: 550; color: var(--text); }
label.field > span.hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"], select, textarea {
  width: 100%; background-color: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-ctl);
  padding: 8px 11px; min-height: 38px; font-size: 0.92rem; font-weight: 400;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
textarea { resize: vertical; min-height: 76px; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; background-color: var(--surface-2); cursor: not-allowed; }
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; font-size: 0.9rem; cursor: pointer; }
.check input { margin-top: 2px; }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px 16px; margin: 0; display: grid; gap: 10px; }
legend { padding: 0 6px; font-weight: 600; font-size: 0.88rem; }
.option {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: start; cursor: pointer;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  transition: border-color 120ms var(--ease), background-color 120ms var(--ease);
}
.option:hover { background: var(--surface-2); }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option input { margin-top: 2px; grid-row: span 2; }
.option b { font-weight: 600; }
.option .desc { color: var(--muted); font-size: 0.83rem; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 640px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.member-list { display: grid; max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.member-row { display: flex; align-items: center; gap: 2px; padding: 2px 6px 2px 12px; border-bottom: 1px solid var(--border); }
.member-row:last-child { border-bottom: 0; }
.member-row .check { padding: 8px 0; }
.member-row .icon-btn { width: 32px; height: 32px; }
.member-row .icon-btn:disabled { opacity: 0.3; cursor: default; background: none; }
.option-head { font-size: 0.72rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 4px; }
.form-error {
  color: var(--bad); background: var(--bad-soft); border-radius: 10px; padding: 9px 12px; font-size: 0.88rem;
  border: 1px solid color-mix(in srgb, var(--bad) 22%, transparent);
}

/* A checkbox styled as an on/off toggle. */
input[type="checkbox"].switch {
  appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 999px;
  background: var(--border-strong); position: relative; cursor: pointer; margin: 0;
  transition: background-color 160ms var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 180ms var(--ease);
}
input[type="checkbox"].switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.toggle-row { display: flex; align-items: center; gap: 14px; cursor: pointer; padding: 16px 20px; }
.toggle-row .grow { display: grid; gap: 1px; }
.toggle-row b { font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px;
  border-radius: var(--radius-ctl); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer;
  font-weight: 550; font-size: 0.88rem; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition-property: background-color, border-color, color, transform;
  transition-duration: 120ms; transition-timing-function: var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover:not(:disabled) { background: var(--ink-hover); border-color: var(--ink-hover); }
.btn.good { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.good:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--bad); box-shadow: none; }
.btn.danger-ghost:hover:not(:disabled) { background: var(--bad-soft); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 0.8rem; gap: 5px; border-radius: 8px; }
.btn.small .ic { width: 14px; height: 14px; }
.btn.block { width: 100%; }
.btn.big { min-height: 48px; font-size: 0.95rem; border-radius: 12px; padding: 0 18px; }
.btn.square { padding: 0; width: 48px; }
@media (prefers-reduced-motion: reduce) { .btn:active:not(:disabled) { transform: none; } }

/* ---------- status chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem;
  font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; line-height: 1.5;
}
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: var(--info-soft); color: var(--info); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }

/* ---------- dialer ---------- */
.dial-wrap { border-bottom: 1px solid var(--border); transition: border-color 120ms var(--ease); }
.dial-wrap:focus-within { border-bottom-color: var(--accent); }
.dial-wrap input.dial-input {
  border: 0; box-shadow: none; background: transparent; border-radius: 0;
  text-align: center; font-size: 1.7rem; font-weight: 500; letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums; min-height: 56px; padding: 4px 8px;
}
.dial-wrap input.dial-input::placeholder { color: var(--faint); font-weight: 400; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  min-height: 56px; border-radius: 12px; border: 0; background: var(--surface-2); cursor: pointer;
  font-size: 1.3rem; font-weight: 500; display: grid; place-items: center; align-content: center; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  transition: background-color 100ms var(--ease), transform 100ms var(--ease);
}
.key small { display: block; font-size: 0.58rem; font-weight: 600; letter-spacing: 0.14em; color: var(--faint); margin-top: 3px; min-height: 0.7rem; }
.key:hover { background: var(--surface-3); }
.key:active { transform: scale(0.96); }
@media (prefers-reduced-motion: reduce) { .key:active { transform: none; } }
.dial-actions { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; align-items: center; }

.active-call { text-align: center; display: grid; gap: 20px; justify-items: center; padding: 32px 20px 20px; }
.call-avatar {
  width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.call-avatar.ringing { animation: ring 1.6s var(--ease) infinite; }
.active-call .who-line { font-size: 1.55rem; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.call-meta { display: grid; gap: 6px; justify-items: center; }
.call-state { display: flex; gap: 10px; align-items: center; justify-content: center; }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.9rem; }
.controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; }
.ctl {
  display: grid; justify-items: center; gap: 6px; padding: 12px 8px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; font-size: 0.8rem; font-weight: 550; color: var(--text);
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease), color 120ms var(--ease), transform 100ms var(--ease);
}
.ctl:hover:not(:disabled) { background: var(--surface-3); }
.ctl:active:not(:disabled) { transform: scale(0.97); }
.ctl:disabled { opacity: 0.45; cursor: not-allowed; }
.ctl[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.active-call .keypad, .active-call > .btn { width: 100%; }

.banner {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 50;
  width: min(420px, calc(100% - 24px)); background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow-lg); padding: 16px; display: grid; gap: 14px;
}
.banner-top { display: flex; gap: 14px; align-items: center; }
.banner .call-avatar { width: 52px; height: 52px; animation: ring 1.6s var(--ease) infinite; }
.eyebrow { font-size: 0.72rem; font-weight: 650; color: var(--accent); text-transform: uppercase; letter-spacing: 0.07em; }
.banner .who-line { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.banner .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@keyframes ring {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  70%, 100% { box-shadow: 0 0 0 14px transparent; }
}
@media (prefers-reduced-motion: reduce) { .call-avatar, .banner .call-avatar { animation: none !important; } }

/* ---------- lists & tables ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab {
  background: none; border: 0; padding: 12px 12px 11px; cursor: pointer; color: var(--muted); font-weight: 550;
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 7px;
  transition: color 120ms var(--ease), border-color 120ms var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--ink); }
.badge {
  background: var(--accent); color: var(--on-accent); border-radius: 999px; padding: 0 6px; min-width: 18px;
  font-size: 0.7rem; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
}
.list-card { padding: 0 20px 6px; }
.list-card .tabs { margin: 0 -20px 4px; padding: 0 12px; }

.list { display: grid; }
.list-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--border); }
.table-card .list-foot { padding: 12px 16px; }
.item {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 4px 14px; padding: 13px 0;
  border-bottom: 1px solid var(--border); align-items: center;
}
.item:last-child { border-bottom: 0; }
.item .icon {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted);
}
.item .icon.in { color: var(--good); background: var(--good-soft); }
.item .icon.out { color: var(--info); background: var(--info-soft); }
.item .icon.miss { color: var(--bad); background: var(--bad-soft); }
.item .icon.vm { color: var(--warn); background: var(--warn-soft); }
.item .title { font-weight: 600; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; }
.item .title .dot { color: var(--accent); }
.item .sub { color: var(--muted); font-size: 0.82rem; text-wrap: pretty; }
.item .meta { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.item .dur { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }
.item .extra { grid-column: 2 / -1; }
@media (max-width: 560px) {
  .item { grid-template-columns: 36px 1fr; }
  .item .meta { grid-column: 2; justify-content: flex-start; flex-wrap: wrap; }
}
audio { width: 100%; height: 36px; margin-top: 8px; }

.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th {
  text-align: left; font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color 100ms var(--ease); }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.nowrap { white-space: nowrap; }
.person { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.person .avatar { width: 28px; height: 28px; }
.dir { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dir.in .ic { color: var(--good); }
.dir.out .ic { color: var(--info); }

.line-grid { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 760px) { .line-grid { grid-template-columns: 1fr 1fr; } }
.line-card { display: grid; gap: 16px; }
.line-num { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 0.87rem; margin: 0; padding-top: 16px; border-top: 1px solid var(--border); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ---------- callouts ---------- */
.callout {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 10px; font-size: 0.86rem;
  background: var(--warn-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  text-wrap: pretty; overflow-wrap: anywhere;
}
.callout .ic { color: var(--warn); margin-top: 2px; }
.callout.info { background: var(--surface-2); border-color: var(--border); }
.callout.info .ic { color: var(--muted); }
.callout.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.callout.good .ic { color: var(--good); }

/* ---------- dialog & toast ---------- */
dialog {
  border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text);
  width: min(680px, calc(100% - 24px)); max-height: calc(100% - 24px); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: dlg-in 180ms var(--ease); }
dialog::backdrop { background: var(--backdrop); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
.dialog-body { padding: 22px; display: grid; gap: 16px; }
.dialog-foot {
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 22px;
  border-top: 1px solid var(--border); background: var(--surface-2); position: sticky; bottom: 0;
}
.dialog-foot .spacer { margin-right: auto; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; justify-items: end; }
.toast {
  background: var(--ink); color: var(--on-ink); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg);
  max-width: 380px; font-size: 0.88rem; font-weight: 500; animation: toast-in 200ms var(--ease);
}
.toast.bad { background: var(--danger); color: var(--on-danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { dialog[open], .toast { animation: none; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-col { width: min(380px, 100%); }
.login-card { padding: 28px; }
.login-card .brand { margin-bottom: 10px; }
.login-head { display: grid; gap: 4px; margin-bottom: 4px; }
.login-head h1 { font-size: 1.3rem; }
.login-foot { text-align: center; color: var(--faint); font-size: 0.78rem; margin-top: 16px; }

/* ---------- setup ---------- */
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row code {
  flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); padding: 6px 10px; border-radius: 8px;
  overflow-x: auto; white-space: nowrap; font-family: var(--mono); font-size: 0.8rem;
}
.copy-label { font-size: 0.82rem; font-weight: 550; }
ol.steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; counter-reset: step; }
ol.steps li { counter-increment: step; display: grid; grid-template-columns: 24px 1fr; gap: 12px; align-items: start; text-wrap: pretty; }
ol.steps li::before {
  content: counter(step); width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3);
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 650; font-variant-numeric: tabular-nums;
}
.check-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.check-row:last-of-type { border-bottom: 0; }
.check-row .grow { display: grid; gap: 2px; }
.check-row .ic { margin-top: 2px; }
.check-row .ok { color: var(--good); }
.check-row .no { color: var(--bad); }
.check-row .wait { color: var(--warn); }

/* ---------- messages ---------- */
.msg-page { display: flex; flex-direction: column; gap: 12px; height: calc(100vh - 56px - 72px); min-height: 460px; }
.msg-layout { display: grid; grid-template-columns: 340px 1fr; gap: 16px; flex: 1; min-height: 0; }
.msg-list, .msg-thread { padding: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.msg-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.convo-list { overflow-y: auto; flex: 1; }
.convo {
  display: grid; gap: 4px; width: 100%; text-align: left; padding: 12px 16px; background: none; border: 0;
  border-bottom: 1px solid var(--border); cursor: pointer; color: inherit;
  transition: background-color 100ms var(--ease);
}
.convo:hover { background: var(--surface-2); }
.convo.active { background: var(--accent-soft); }
.convo-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.convo-name { font-weight: 600; font-variant-numeric: tabular-nums; }
.convo-time { color: var(--muted); font-size: 0.75rem; white-space: nowrap; }
.convo-preview { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-meta { display: flex; align-items: center; gap: 8px; }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.thread-head .back { display: none; }
.thread-name { font-weight: 600; font-variant-numeric: tabular-nums; }
.thread-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.thread-empty { margin: auto; }
.bubble-row { display: flex; }
.bubble-row.out { justify-content: flex-end; }
.bubble { max-width: min(78%, 480px); padding: 8px 12px; border-radius: 16px; display: grid; gap: 4px; overflow-wrap: anywhere; }
.bubble.in { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.out { background: var(--ink); color: var(--on-ink); border-bottom-right-radius: 4px; }
.bubble.failed { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad); }
.bubble-text { white-space: pre-wrap; }
.bubble-meta { font-size: 0.7rem; opacity: 0.7; font-variant-numeric: tabular-nums; }
.bubble-media { font-size: 0.85rem; color: inherit; text-decoration: underline; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 140px; resize: none; }
@media (max-width: 820px) {
  .msg-page { height: calc(100vh - 120px); }
  .msg-layout { grid-template-columns: 1fr; }
  .msg-layout .msg-thread { display: none; }
  .msg-layout.has-thread .msg-list { display: none; }
  .msg-layout.has-thread .msg-thread { display: flex; }
  .thread-head .back { display: grid; }
}

/* ---------- connect AgentPhone (messages) ---------- */
.connect-card { max-width: 640px; margin: 0 auto; padding: 24px; }
.connect-head { display: flex; gap: 16px; align-items: flex-start; }
.connect-head .call-avatar { width: 48px; height: 48px; flex: none; }
.connect-head h2 { margin-bottom: 4px; }
ol.steps a { color: var(--accent); }
.msg-list-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 8px 12px 8px 16px; border-top: 1px solid var(--border); }

/* ---------- calling inside the app shell (top bar, thread header) ---------- */
.topbar-mid { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; }
.topbar-mid:empty { display: none; }
.topbar-status { display: flex; align-items: center; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 3px 8px 3px 4px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; background: var(--surface); }
.status-pill .chip { background: transparent; }
.status-pill input[type="checkbox"].switch { width: 30px; height: 18px; }
.status-pill .switch::after { top: 2px; left: 2px; width: 14px; height: 14px; }
.status-pill .switch:checked::after { transform: translateX(12px); }

.incoming-box { display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 10px; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 14px; max-width: 100%; flex: 0 0 auto; }
.incoming-box .call-avatar { width: 34px; height: 34px; flex: none; animation: ring 1.6s var(--ease) infinite; }
.incoming-text { flex: none; }
.incoming-text .eyebrow { font-size: 0.68rem; white-space: nowrap; }
.incoming-text .who-line { font-size: 1rem; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.incoming-actions { display: flex; gap: 6px; margin-left: auto; flex: none; }
@media (prefers-reduced-motion: reduce) { .incoming-box .call-avatar { animation: none; } }

.thread-title { min-width: 0; }
.thread-calls:empty { display: none; }
.call-start, .call-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.call-controls .call-who { font-variant-numeric: tabular-nums; }
.call-controls .btn[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.thread-keypad:empty, .msg-callstrip:empty { display: none; }
.keypad-panel { padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.keypad-panel .keypad { max-width: 260px; margin: 0 auto; }
.msg-callstrip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.msg-callstrip .call-controls { justify-content: flex-start; }
/* On this page the header is wider than the content so the incoming-call box fits beside the tabs;
   on narrower screens it drops to its own row. */
.topbar-inner.wide { max-width: 1480px; }
@media (max-width: 1280px) { .topbar-mid:not(:empty) { order: 5; flex-basis: 100%; padding-bottom: 8px; } }
@media (max-width: 900px) {
  .incoming-box { flex-wrap: wrap; width: 100%; flex: 1 1 100%; }
  .incoming-text { flex: 1 1 auto; min-width: 0; }
  .incoming-actions { margin-left: 0; width: 100%; }
  .incoming-actions .btn { flex: 1; }
  .thread-head { flex-wrap: wrap; }
  .thread-calls { flex-basis: 100%; order: 5; }
  .call-start, .call-controls { justify-content: flex-start; }
}
