:root {
  --bg: #15140f;
  --bg2: #1b1a15;
  --panel: #201f19;
  --panel2: #282620;
  --line: #34312a;
  --line2: #45413a;
  --text: #efe9da;
  --muted: #a29a85;
  --faint: #6f695a;
  --amber: #ffb020;
  --amber-ink: #1a1405;
  --green: #4fc48b;
  --red: #ff6a5a;
  --blue: #73b8ff;
  --violet: #c39bff;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --sans: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}
:root.light {
  --bg: #f3efe4;
  --bg2: #ebe6d8;
  --panel: #fffdf7;
  --panel2: #f6f2e7;
  --line: #ddd5c2;
  --line2: #c9bfa8;
  --text: #1d1b16;
  --muted: #6a6352;
  --faint: #9a917c;
  --amber: #e89400;
  --amber-ink: #1a1405;
  --green: #17895a;
  --red: #d23b2a;
  --blue: #1f6fc4;
  --violet: #7b4fd0;
  --shadow: 0 10px 30px rgba(60,50,20,.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255,176,32,.07), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(255,255,255,.018) 23px 24px),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
}
:root.light body { background: radial-gradient(1200px 600px at 85% -10%, rgba(232,148,0,.10), transparent 60%), var(--bg); }
.hidden { display: none !important; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--amber); outline-offset: -1px; border-color: transparent; }
kbd {
  font: 600 11px var(--mono); padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--line2); border-bottom-width: 2px; color: var(--muted); background: var(--panel2);
}

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line2); background: var(--panel2); border-radius: 9px; padding: 8px 14px;
  font-weight: 600; transition: transform .06s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn.green { background: var(--green); border-color: var(--green); color: #07130d; }
.btn.red { color: var(--red); }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; }
.login-box {
  width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; display: grid; gap: 16px; box-shadow: var(--shadow);
}
.login-box label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.err { color: var(--red); margin: 0; min-height: 1em; }

/* ---------- header ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 10px 18px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { font: 700 22px/1 var(--display); letter-spacing: .04em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand em { font-style: normal; color: var(--amber); }
.brand.big { font-size: 30px; justify-content: center; }
.mark {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px;
  background: var(--amber); color: var(--amber-ink); font-size: 18px;
}
.brand.big .mark { width: 34px; height: 34px; font-size: 24px; }
.tabs { display: flex; gap: 2px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tabs button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 7px;
  font: 600 15px var(--display); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.tabs button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 -2px 0 var(--amber); }
.search { position: relative; flex: 1; max-width: 360px; margin-left: auto; }
.search input { padding: 7px 10px; }
.search-res {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; z-index: 30;
}
.search-res .q-item { border-radius: 0; }
.meter { min-width: 210px; }
.meter-num { font: 600 13px var(--mono); color: var(--muted); }
.meter-num b { font-size: 22px; color: var(--text); }
.meter-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 3px 0; }
.meter-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--amber), #ffd36b); transition: width .4s; }
.meter-sub { font-size: 11px; color: var(--muted); }

/* ---------- call grid ---------- */
.tab { flex: 1; }
.call-grid {
  display: grid; grid-template-columns: 290px minmax(0, 1fr) 330px; gap: 14px; padding: 14px 18px;
  align-items: start;
}
.queue, .actions {
  position: sticky; top: 74px; max-height: calc(100vh - 88px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.q-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.q-head b { font: 600 18px var(--mono); color: var(--amber); }
.q-list { display: flex; flex-direction: column; }
.q-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 9px 14px; border-bottom: 1px solid var(--line);
  cursor: pointer; text-align: left; background: transparent; border-left: 3px solid transparent; width: 100%;
  border-top: 0; border-right: 0;
}
.q-item:hover { background: var(--panel2); }
.q-item.on { background: var(--panel2); border-left-color: var(--amber); }
.q-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-score { font: 500 12px var(--mono); color: var(--faint); }
.q-sub { padding: 10px 14px 4px; font: 600 12px var(--display); letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.q-later .q-item { opacity: .7; }
.q-empty { padding: 18px 14px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em;
}
.st-new { color: var(--muted); }
.st-attempting { color: var(--blue); border-color: color-mix(in srgb, var(--blue) 45%, transparent); }
.st-callback { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 45%, transparent); }
.st-interested, .st-preview_sent { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 50%, transparent); }
.st-won { color: var(--green); border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.st-lost, .st-dnc, .st-bad_number, .st-disqualified, .st-exhausted { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }

/* ---------- lead card ---------- */
.card { min-width: 0; display: grid; gap: 14px; animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed var(--line2); border-radius: 14px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.lead-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 18px; align-items: start; }
.lead-name { font: 700 34px/1.02 var(--display); letter-spacing: .01em; margin: 0; word-break: break-word; }
.lead-sub { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; color: var(--muted); }
.call-btn {
  display: grid; justify-items: center; gap: 2px; padding: 12px 18px; border-radius: 14px; background: var(--green);
  color: #06120c; font-weight: 700; text-decoration: none !important; box-shadow: 0 6px 18px color-mix(in srgb, var(--green) 35%, transparent);
  transition: transform .06s, filter .15s;
}
.call-btn:hover { filter: brightness(1.06); }
.call-btn:active { transform: translateY(1px); }
.call-btn .num { font: 600 20px var(--mono); letter-spacing: .01em; }
.call-btn .lbl { font: 700 12px var(--display); letter-spacing: .14em; text-transform: uppercase; }
.alt-phone { font-size: 12px; color: var(--muted); text-align: center; margin-top: 6px; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; margin-top: 14px; }
.fact .k { font: 600 11px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.fact .v { font-weight: 500; word-break: break-word; }
.fact .v.mono { font-family: var(--mono); }
.stars { color: var(--amber); }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.links a { border: 1px solid var(--line2); border-radius: 8px; padding: 5px 10px; color: var(--text); font-size: 13px; }
.links a:hover { border-color: var(--amber); text-decoration: none; }

.angle {
  border-left: 4px solid var(--amber); background: linear-gradient(90deg, color-mix(in srgb, var(--amber) 12%, transparent), transparent 70%);
  padding: 12px 16px; border-radius: 10px; font-size: 15px;
}
.angle .k { font: 700 12px var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--amber); display: block; margin-bottom: 2px; }
.warn { border-left-color: var(--red); background: linear-gradient(90deg, color-mix(in srgb, var(--red) 12%, transparent), transparent 70%); }
.warn .k { color: var(--red); }

.script-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.script-tabs button { border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 4px 12px; font-size: 13px; color: var(--muted); }
.script-tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.script p { margin: 0 0 10px; font-size: 15.5px; line-height: 1.55; }
.script .who { font: 700 12px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-right: 6px; }
.script .say { color: var(--text); }
.script .them { color: var(--muted); font-style: italic; }
.script b.fill { color: var(--amber); font-weight: 600; }
.obj { border-top: 1px solid var(--line); padding: 10px 0; }
.obj:first-child { border-top: 0; padding-top: 0; }
.obj h4 { margin: 0 0 4px; font: 600 16px var(--display); letter-spacing: .03em; }
.obj p { margin: 0; }

.history .h-row { display: grid; grid-template-columns: 120px 1fr; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.history .h-row:first-of-type { border-top: 0; }
.history .h-when { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.notes-pre { white-space: pre-wrap; font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.box h3, .actions h3 { margin: 0 0 10px; font: 700 13px var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }

/* ---------- actions ---------- */
.actions { padding: 14px; display: grid; gap: 14px; }
.outs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.out {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line2);
  background: var(--panel2); text-align: left; font-weight: 600; font-size: 13.5px; transition: border-color .12s, background .12s, transform .06s;
}
.out:hover { border-color: var(--muted); }
.out:active { transform: translateY(1px); }
.out kbd { margin-left: auto; }
.out.good { border-color: color-mix(in srgb, var(--amber) 55%, transparent); color: var(--amber); }
.out.win { border-color: color-mix(in srgb, var(--green) 55%, transparent); color: var(--green); }
.out.neg { color: var(--red); }
.out.full { grid-column: 1 / -1; }
.out.flash { background: var(--amber); color: var(--amber-ink); }
.warmbox { display: grid; gap: 8px; padding: 12px; border: 1px solid color-mix(in srgb, var(--amber) 45%, transparent); border-radius: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.small { font-size: 12px; color: var(--muted); }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); display: grid; gap: 12px; animation: rise .18s ease both; }
.modal-box h2 { margin: 0; font: 700 24px var(--display); letter-spacing: .02em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line2); background: var(--panel2); border-radius: 99px; padding: 6px 12px; font-size: 13px; }
.chip:hover, .chip.on { border-color: var(--amber); color: var(--amber); }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--bg);
  padding: 10px 14px; border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; font-weight: 600;
  max-width: calc(100% - 32px);
}
.toast button { background: transparent; border: 1px solid currentColor; border-radius: 8px; padding: 3px 10px; }
.q-toggle { display: none; }

/* ---------- pipeline ---------- */
.pipe { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; padding: 14px 18px; align-items: start; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.col-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: baseline; }
.col-head h3 { margin: 0; font: 700 17px var(--display); letter-spacing: .06em; text-transform: uppercase; }
.col-head .n { font: 600 16px var(--mono); color: var(--amber); }
.col-help { padding: 8px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.p-card { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.p-card:last-child { border-bottom: 0; }
.p-name { font-weight: 600; cursor: pointer; }
.p-name:hover { color: var(--amber); }
.p-meta { font-size: 12px; color: var(--muted); }
.p-closed { grid-column: 1 / -1; }
.p-closed table { width: 100%; }

/* ---------- stats ---------- */
.stats { padding: 14px 18px 40px; display: grid; gap: 14px; grid-template-columns: repeat(12, 1fr); }
.tile { grid-column: span 2; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.tile .k { font: 700 12px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.tile .v { font: 600 30px/1.1 var(--mono); margin-top: 4px; }
.tile .s { font-size: 12px; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.span4 { grid-column: span 4; } .span6 { grid-column: span 6; } .span8 { grid-column: span 8; } .span12 { grid-column: span 12; }
.panel h3 { margin: 0 0 12px; font: 700 14px var(--display); letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; height: 100%; justify-content: flex-end; }
.bar .stack { width: 100%; max-width: 34px; display: flex; flex-direction: column-reverse; border-radius: 5px 5px 2px 2px; overflow: hidden; background: var(--line); }
.bar .stack i { display: block; }
.bar .lbl { font: 500 10px var(--mono); color: var(--faint); white-space: nowrap; }
.bar .btop { font: 600 11px var(--mono); color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font: 700 11px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.t td.n { font-family: var(--mono); text-align: right; }
table.t th.n { text-align: right; }
.hbar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; min-width: 60px; }
.hbar i { display: block; height: 100%; background: var(--amber); }
.funnel { display: grid; gap: 8px; }
.f-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.f-row .hbar { height: 14px; border-radius: 4px; }
.f-row .n { font-family: var(--mono); text-align: right; }

/* ---------- settings ---------- */
.settings { max-width: 640px; margin: 0 auto; padding: 24px 18px 60px; display: grid; gap: 14px; }
.settings h2 { font: 700 30px var(--display); margin: 0; }
.settings label { display: grid; gap: 6px; font-weight: 500; }
.settings label.row { display: flex; }
.settings label.row input { width: auto; }
.settings small { color: var(--muted); }
.help { margin-top: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.help h3 { margin: 0 0 8px; font: 700 14px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.help td { padding: 4px 10px 4px 0; vertical-align: top; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .call-grid { grid-template-columns: 250px minmax(0, 1fr) 300px; }
  .pipe { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { grid-column: span 4; }
  .span4, .span6, .span8 { grid-column: span 12; }
}
@media (max-width: 900px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 16px; position: static; }
  .search { order: 5; max-width: none; flex-basis: 100%; }
  .meter { order: 2; min-width: 0; flex: 0 1 170px; margin-left: auto; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .tabs button { padding: 6px 10px; flex: 1; }
  .call-grid { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 90px; }
  .queue {
    position: fixed; inset: 0 auto 0 0; width: min(330px, 86vw); max-height: none; z-index: 40; border-radius: 0;
    transform: translateX(-105%); transition: transform .2s; top: 0;
  }
  .queue.open { transform: none; box-shadow: var(--shadow); }
  .actions { position: static; max-height: none; }
  .q-toggle {
    display: block; position: fixed; left: 16px; bottom: 16px; z-index: 41; background: var(--amber); color: var(--amber-ink);
    border: 0; border-radius: 99px; padding: 10px 16px; font: 700 15px var(--display); letter-spacing: .08em; text-transform: uppercase; box-shadow: var(--shadow);
  }
  .lead-head { grid-template-columns: minmax(0, 1fr); }
  .call-btn { width: 100%; }
  .lead-name { font-size: 28px; }
  .pipe { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; }
  .stats { padding: 12px 16px 40px; }
  .tile { grid-column: span 6; }
  .f-row { grid-template-columns: 110px 1fr 60px; }
  .history .h-row { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 520px) {
  .brand { font-size: 19px; }
  .meter-sub { display: none; }
}
