/* Regal CRM. Quiet navy-and-brass working surface; the dialer's line strip is the one loud thing. */
:root {
  --ink: #172338;          /* sidebar, headings */
  --ink-2: #22314b;
  --paper: #f3f5f8;        /* app background */
  --surface: #ffffff;
  --line: #dfe4ec;
  --line-2: #eef1f5;
  --text: #1c2433;
  --muted: #5b6578;
  --faint: #8b94a5;
  --brass: #b8892e;        /* brand */
  --brass-soft: #f6eedc;
  --go: #1f8a5b;           /* ready / connected */
  --go-soft: #e3f3ea;
  --talk: #2463c9;         /* on a call */
  --talk-soft: #e4ecfa;
  --wrap: #b7791f;         /* wrap-up */
  --wrap-soft: #fbf0dc;
  --screen: #7a4cc2;       /* call screener */
  --screen-soft: #efe7fb;
  --stop: #b83a3a;
  --stop-soft: #f8e5e5;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(23, 35, 56, .06), 0 2px 8px rgba(23, 35, 56, .04);
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1624; --surface: #161f30; --line: #27334a; --line-2: #1c2638;
    --text: #e6eaf1; --muted: #a2adc0; --faint: #77839a; --ink: #0b111c; --ink-2: #131c2c;
    --brass-soft: #3a2f17; --go-soft: #12301f; --talk-soft: #142645; --wrap-soft: #3a2a10;
    --screen-soft: #2a1d44; --stop-soft: #3d1919;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.nowrap { white-space: nowrap; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--paper);
  font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased; }
a { color: var(--talk); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* ------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 208px 1fr; height: 100vh; }
.nav { background: var(--ink); color: #c9d2e1; display: flex; flex-direction: column; padding: 18px 12px; gap: 2px; }
.brand { display: flex; align-items: baseline; gap: 8px; padding: 2px 10px 22px; color: #fff; }
.brand b { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.brand b::first-letter { color: var(--brass); }
.brand span { font-size: 12px; color: #8c9ab3; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: #c9d2e1; font-weight: 500; }
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav a:hover { background: var(--ink-2); text-decoration: none; color: #fff; }
.nav a.on { background: #24344f; color: #fff; box-shadow: inset 3px 0 0 var(--brass); }
.nav .grow { flex: 1; }
.nav .me { font-size: 12.5px; color: #8c9ab3; padding: 10px; border-top: 1px solid #24324a; }
.nav .me a { display: inline; padding: 0; color: #c9d2e1; }
.nav .live { margin: 4px 10px 10px; font-size: 12px; padding: 6px 8px; border-radius: var(--radius-sm);
  background: #24344f; color: #e8edf5; display: none; }
.nav .live.show { display: block; }
.sim { margin: 0 10px 10px; font-size: 12px; padding: 7px 9px; border-radius: var(--radius-sm);
  background: var(--brass-soft); color: #6d5016; line-height: 1.35; }
@media (prefers-color-scheme: dark) { .sim { color: #e8cf96; } }

.main { overflow: auto; display: flex; flex-direction: column; min-width: 0; }
.page { padding: 22px 28px 40px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.sub { color: var(--muted); font-size: 13px; }

.flash { margin: 14px 28px 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--talk-soft);
  border: 1px solid var(--line); }

/* ------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c4ccd8; text-decoration: none; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--brass); border-color: var(--brass); color: #1b1407; } }
.btn.go { background: var(--go); border-color: var(--go); color: #fff; }
.btn.stop { background: var(--stop); border-color: var(--stop); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { height: 28px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 7px 10px; min-height: 34px; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px var(--brass-soft); }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 550; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.card-b { padding: 14px 16px; }
.card + .card { margin-top: 16px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px;
  font-size: 12.5px; font-weight: 550; background: var(--line-2); color: var(--text); white-space: nowrap; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.tag { font-size: 12px; color: var(--muted); }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 9px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 1; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr:hover td { background: var(--paper); }
.t .name a { color: var(--text); font-weight: 600; }
.t .num { text-align: right; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ------------------------------------------------ leads list: index column + table */
.split { display: grid; grid-template-columns: 236px 1fr; gap: 20px; align-items: start; }
.index { position: sticky; top: 0; }
.index h3 { font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 16px 8px 6px; }
.index h3:first-child { margin-top: 0; }
.index a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); color: var(--text); }
.index a:hover { background: var(--surface); text-decoration: none; }
.index a.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.index a i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.index a span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.index a em { font-style: normal; color: var(--faint); font-size: 12.5px; }

.toolbar { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--line-2); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; padding: 3px 4px 3px 9px; border-radius: 999px;
  background: var(--brass-soft); color: var(--text); }
.chip a { color: var(--muted); padding: 0 5px; }
.bulk { display: none; gap: 8px; align-items: center; padding: 8px 12px; background: var(--talk-soft); border-bottom: 1px solid var(--line); }
.bulk.show { display: flex; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 12px; color: var(--muted); }

/* ------------------------------------------------ lead page */
.lead-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; }
.lead-head h1 { font-size: 24px; }
.lead-head .meta { color: var(--muted); margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.lead-grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.facts dt { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.facts dd { margin: 2px 0 0; }
.phone-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.phone-row:last-child { border-bottom: 0; }
.phone-row .n { font-weight: 600; flex: 1; white-space: nowrap; }
.phone-row select { width: 46px; }
.kv { display: grid; grid-template-columns: 42% 1fr; gap: 6px; margin-bottom: 6px; }
.kv input { min-width: 0; }
.phone-row.bad .n { text-decoration: line-through; color: var(--faint); }
.phone-row form { display: inline; }
.lt { font-size: 11.5px; padding: 1px 6px; border-radius: 4px; background: var(--line-2); color: var(--muted); }
.lt.mobile { background: var(--talk-soft); color: var(--talk); }
.dnc-flag { background: var(--stop-soft); color: var(--stop); padding: 8px 12px; border-radius: var(--radius-sm); font-weight: 600; margin-bottom: 12px; }

.composer textarea { width: 100%; min-height: 84px; border-radius: var(--radius) var(--radius) 0 0; }
.composer .actions { display: flex; justify-content: flex-end; gap: 8px; padding: 8px; border: 1px solid var(--line);
  border-top: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--paper); }

.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.tl li:last-child { border-bottom: 0; }
.tl .ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--line-2); color: var(--muted); }
.tl .ic svg { width: 14px; height: 14px; }
.tl .call .ic { background: var(--talk-soft); color: var(--talk); }
.tl .call.miss .ic { background: var(--line-2); color: var(--faint); }
.tl .status .ic { background: var(--brass-soft); color: var(--brass); }
.tl .who { font-size: 12.5px; color: var(--muted); }
.tl .body { white-space: pre-wrap; margin-top: 3px; }
.tl audio { height: 32px; margin-top: 6px; width: 100%; max-width: 360px; }

/* ------------------------------------------------ dialer */
.dial-top { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 14px 28px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 3; }
.state { display: flex; align-items: center; gap: 14px; }
.state .big { font-size: 20px; font-weight: 750; letter-spacing: -.01em; }
.state .dot { flex: none; width: 14px; height: 14px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 5px var(--line-2); }
.st-ready .dot { background: var(--go); box-shadow: 0 0 0 5px var(--go-soft); }
.st-on_call .dot { background: var(--talk); box-shadow: 0 0 0 5px var(--talk-soft); }
.st-wrap_up .dot { background: var(--wrap); box-shadow: 0 0 0 5px var(--wrap-soft); }
.st-connecting .dot { background: var(--brass); box-shadow: 0 0 0 5px var(--brass-soft); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .st-connecting .dot { animation: none; } }

/* The switchboard: one lamp per line in flight. */
.board { display: flex; gap: 6px; align-items: flex-end; min-height: 46px; padding: 12px 28px; background: var(--ink);
  overflow-x: auto; }
.board .label { color: #8c9ab3; font-size: 12px; margin-right: 10px; align-self: center; white-space: nowrap; }
.lamp { width: 34px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.lamp b { width: 18px; height: 18px; border-radius: 50%; background: #2b3a55; border: 2px solid #3a4b69; }
.lamp small { font-size: 10px; color: #8c9ab3; max-width: 34px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lamp.dialing b { background: #4a5d80; border-color: #6d82a8; animation: ring 1s steps(2) infinite; }
.lamp.answered b, .lamp.waiting b { background: #e2b14a; border-color: #f4d58f; }
.lamp.bridging b, .lamp.bridged b { background: #39b37a; border-color: #8fe0b8; box-shadow: 0 0 10px #39b37a; }
.lamp.screen b { background: #9b6ae0; border-color: #cdb0f5; }
.lamp.abandoning b { background: #d05555; border-color: #f0a0a0; }
@keyframes ring { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .lamp.dialing b { animation: none; } }
.board .reps { margin-left: auto; display: flex; gap: 12px; color: #c9d2e1; font-size: 12.5px; align-items: center; white-space: nowrap; }
.board .reps span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #6d7a92; }
.board .reps .ready::before { background: #39b37a; }
.board .reps .on_call::before { background: #5b93ee; }
.board .reps .wrap_up::before { background: #e2b14a; }

.dial-body { display: grid; grid-template-columns: 1fr 360px; gap: 20px; padding: 20px 28px 40px; align-items: start; }
.waiting-box { padding: 60px 30px; text-align: center; color: var(--muted); }
.waiting-box h2 { margin-bottom: 6px; }
.screened-banner { display: none; background: var(--screen); color: #fff; padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 14px; font-weight: 600; }
.screened-banner.show { display: block; }
.screened-banner p { font-weight: 400; margin: 6px 0 0; opacity: .95; }
.connected-strip { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--talk-soft); margin-bottom: 14px; }
.connected-strip .timer { font-size: 18px; font-weight: 700; color: var(--talk); }
.dispo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dispo button { height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-weight: 550; cursor: pointer; color: var(--text); text-align: left; padding: 0 12px; }
.dispo button:hover { border-color: var(--brass); }
.dispo button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.kbd { font-size: 11px; color: var(--faint); float: right; margin-top: 2px; }
.dispo button.on .kbd { color: #b5c0d3; }

/* ------------------------------------------------ home */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.stats > .card + .card { margin-top: 0; }
.stat { padding: 14px 16px; }
.stat b { display: block; font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 12.5px; }
.bar { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; }
.bar i { display: block; height: 100%; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

@media (max-width: 1100px) {
  .split, .lead-grid, .dial-body, .cols { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px; }
  .brand, .nav .grow, .nav .me, .sim { display: none; }
  .page { padding: 16px; }
  .dial-top, .board { padding-left: 16px; padding-right: 16px; }
  .dial-body { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
