:root {
  --bg: #f4f5f7; --panel: #ffffff; --line: #e5e7eb; --text: #111827; --muted: #6b7280;
  --primary: #2563eb; --primary-600: #1d4ed8; --primary-50: #eff6ff;
  --green: #16a34a; --green-50: #ecfdf5; --amber: #d97706; --amber-50: #fffbeb;
  --red: #dc2626; --red-50: #fef2f2; --sidebar: #0f172a; --sidebar-text: #cbd5e1;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0 0 8px; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; font-size: 15px; }
.nav button { width: 100%; text-align: left; background: none; border: 0; color: var(--sidebar-text); padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav button.active { background: rgba(37,99,235,.25); color: #fff; }
.nav .badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }
.sidebar .spacer { flex: 1; }
.sidebar .me { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.sidebar .me .name { color: #fff; font-weight: 600; }
.sidebar .me button { background: none; border: 0; color: var(--sidebar-text); cursor: pointer; padding: 0; text-align: left; }
.sidebar .me button:hover { color: #fff; }
.main { padding: 22px 26px 90px; min-width: 0; }
.view { display: none; } .view.active { display: block; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h1 { margin: 0; margin-right: auto; }

/* ---------------------------------------------------------------- cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-title h2, .card-title h3 { margin: 0; margin-right: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dialer-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .dialer-grid { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .app { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } .grid-2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- buttons */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 550; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: #f9fafb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; } .btn.primary:hover { background: var(--primary-600); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.amber { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.lg { padding: 12px 20px; font-size: 15px; border-radius: 11px; }
.btn.wide { width: 100%; justify-content: center; }
.btn.icon { padding: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f3f4f6; color: var(--muted); }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; }
.pill.ok { background: var(--green-50); color: var(--green); } .pill.ok .dot { background: var(--green); }
.pill.warn { background: var(--amber-50); color: var(--amber); } .pill.warn .dot { background: var(--amber); }
.pill.bad { background: var(--red-50); color: var(--red); } .pill.bad .dot { background: var(--red); }
.pill.info { background: var(--primary-50); color: var(--primary); } .pill.info .dot { background: var(--primary); }
.dot.pulse { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ---------------------------------------------------------------- forms */
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 550; color: #374151; }
input[type=text], input[type=password], input[type=number], input[type=search], input:not([type]), select, textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px; background: #fff; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { resize: vertical; min-height: 90px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 550; font-size: 13px; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: #d1d5db; position: relative; cursor: pointer; margin: 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--primary); } .switch input:checked::after { left: 18px; }
.error { background: var(--red-50); color: var(--red); border-radius: 8px; padding: 8px 12px; font-size: 13px; }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:hover td { background: #fafafa; }
.table-wrap { overflow-x: auto; }
.progress { height: 6px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }

/* ---------------------------------------------------------------- dialer */
.status-banner { border-radius: var(--radius); padding: 14px 18px; display: flex; align-items: center; gap: 14px; margin-bottom: 14px; border: 1px solid var(--line); background: #fff; }
.status-banner .big { font-size: 17px; font-weight: 650; }
.status-banner .timer { margin-left: auto; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.status-banner.dialing { background: var(--primary-50); border-color: #bfdbfe; }
.status-banner.connected { background: var(--green-50); border-color: #a7f3d0; }
.status-banner.voicemail { background: var(--amber-50); border-color: #fde68a; }
.status-banner.wrapup { background: #f9fafb; }
.status-banner.offline { background: #f9fafb; color: var(--muted); }
.lead-head { display: flex; align-items: flex-start; gap: 16px; }
.lead-head .name { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.lead-head .biz { font-size: 16px; color: #374151; margin-top: 2px; }
.lead-head .phone { font-size: 15px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.lead-head .from { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); }
.lead-head .from b { display: block; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 18px; margin-top: 16px; }
.fields .f { border-top: 1px solid var(--line); padding-top: 8px; min-width: 0; }
.fields .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.fields .v { font-size: 14px; font-weight: 500; word-break: break-word; margin-top: 2px; }
.fields .v.empty { color: #d1d5db; font-weight: 400; }
.outcomes { display: flex; flex-wrap: wrap; gap: 8px; }
.outcomes .btn.on { background: var(--primary-50); border-color: var(--primary); color: var(--primary); }
.outcomes .btn.on.interested { background: var(--green-50); border-color: var(--green); color: var(--green); }
.outcomes .btn.on.dnc, .outcomes .btn.on.not_interested, .outcomes .btn.on.wrong_number { background: var(--red-50); border-color: var(--red); color: var(--red); }
.notes-area { min-height: 130px; font-size: 14px; }
.saved-hint { font-size: 12px; color: var(--muted); height: 16px; }
.controls { position: fixed; left: 220px; right: 0; bottom: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: 12px 26px; display: flex; gap: 10px; align-items: center; z-index: 20; }
@media (max-width: 800px) { .controls { left: 0; } }
.controls .spacer { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* sms */
.thread { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; padding: 4px 2px; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 14px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.msg.out { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.in { align-self: flex-start; background: #f1f3f5; border-bottom-left-radius: 4px; }
.msg .meta { display: block; font-size: 11px; opacity: .7; margin-top: 3px; }
.composer { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 140px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; background: #fff; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.queue li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.queue li:last-child { border-bottom: 0; }
.queue .n { color: var(--muted); width: 22px; font-variant-numeric: tabular-nums; }
.queue .who { font-weight: 550; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue ul { list-style: none; margin: 0; padding: 0; }
.history li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; display: flex; gap: 10px; }
.history ul { list-style: none; margin: 0; padding: 0; }

/* ---------------------------------------------------------------- modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 16px; width: min(760px, 100%); max-height: 92vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(1100px, 100%); }
.modal h2 { margin-bottom: 14px; }
.dropzone { border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 34px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .12s, background .12s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-50); }
.toast-wrap { position: fixed; right: 20px; top: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); max-width: 380px; animation: fadein .15s; }
.toast.err { background: var(--red); } .toast.ok { background: var(--green); }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px) } to { opacity: 1; transform: none } }

/* ---------------------------------------------------------------- checklists, stats, help */
.checklist ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 9px; background: #f9fafb; }
.checklist li.done { background: var(--green-50); }
.checklist li.todo { background: var(--amber-50); }
.checklist .mark { font-size: 15px; width: 22px; text-align: center; flex: none; }
.checklist .what { font-weight: 600; }
.checklist .how { color: var(--muted); font-size: 13px; margin-top: 2px; }
.checklist li .btn { margin-left: auto; flex: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.hours { display: grid; grid-template-columns: repeat(auto-fit, minmax(48px, 1fr)); gap: 6px; align-items: end; }
.hours .h { text-align: center; font-size: 11px; color: var(--muted); }
.hours .bar { background: var(--primary-50); border-radius: 6px 6px 2px 2px; height: 70px; position: relative; overflow: hidden; margin-bottom: 4px; }
.hours .bar > div { position: absolute; bottom: 0; left: 0; right: 0; background: var(--primary); border-radius: 6px 6px 0 0; }
.hours .pct { font-weight: 600; color: var(--text); font-size: 12px; }
kbd { display: inline-block; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; font-size: 12px; background: #fff; font-family: inherit; font-weight: 600; min-width: 22px; text-align: center; }
.help-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.help-tabs button { border: 0; background: none; padding: 8px 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.help-tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.help-step { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.help-step:last-child { border-bottom: 0; }
.help-step .num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; }
.help-step b { display: block; font-size: 15px; margin-bottom: 2px; }
.help-step span { color: var(--muted); }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.help-grid > div { background: #f9fafb; border-radius: 12px; padding: 14px; }
.help-grid .ic { font-size: 22px; margin-bottom: 6px; }
.help-grid b { display: block; margin-bottom: 3px; }
.help-grid span { color: var(--muted); font-size: 13px; }
.keys { display: flex; flex-direction: column; gap: 8px; }
.keys > div { display: flex; align-items: center; gap: 10px; }
.keys kbd { min-width: 34px; padding: 4px 8px; font-size: 13px; }
.keys span { color: var(--text); }
.rec-audio { height: 28px; vertical-align: middle; max-width: 220px; }
.callbacks li.due .who { color: var(--amber); }

/* ---------------------------------------------------------------- getting started (quiet stepper) */
.gs { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.gs-steps { display: flex; gap: 0; flex: 1; flex-wrap: wrap; }
.gs-step { display: flex; align-items: center; gap: 8px; padding: 4px 14px 4px 0; margin-right: 14px; font-size: 13px; color: var(--muted); position: relative; }
.gs-step:not(:last-child)::after { content: ""; position: absolute; right: 0; top: 50%; width: 1px; height: 18px; background: var(--line); transform: translateY(-50%); }
.gs-step .n { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #cbd5e1; color: var(--muted); display: grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; }
.gs-step.done { color: var(--text); } .gs-step.done .n { background: var(--green); border-color: var(--green); color: #fff; }
.gs-step.now { color: var(--text); font-weight: 600; } .gs-step.now .n { border-color: var(--primary); color: var(--primary); }
.gs-step .lnk { color: var(--primary); cursor: pointer; font-weight: 600; margin-left: 2px; }
.gs-close { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1; }
.gs-close:hover { color: var(--text); }

/* ---------------------------------------------------------------- inbox */
.inbox-grid { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .inbox-grid { grid-template-columns: 1fr; } }
.convos { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
.convos li { padding: 10px 12px; border-radius: 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
.convos li:hover { background: #f9fafb; }
.convos li.on { background: var(--primary-50); }
.convos li.awaiting .who::before { content: "●"; color: var(--primary); margin-right: 6px; font-size: 10px; vertical-align: middle; }
.convos .preview { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0; }

/* ---------------------------------------------------------------- login */
.login-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, #0f172a, #1e3a8a); }
.login-card { background: #fff; padding: 32px; border-radius: 18px; width: min(380px, 92vw); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-card h1 { margin: 0; } .login-card p { margin: -8px 0 4px; }
.login-logo { width: 44px; height: 44px; border-radius: 12px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 22px; }
