/* OpDesk console — self-hosted fonts, no external requests. */
@font-face { font-family: "Manrope"; src: url("/static/fonts/manrope.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/static/fonts/plex-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/static/fonts/plex-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/static/fonts/plex-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/static/fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #f8fafc; --panel: #fff; --ink: #0f172a; --muted: #475569; --faint: #94a3b8; --line: #e2e8f0; --line2: #cbd5e1;
  --side: #0b1120; --side-ink: #f8fafc; --side-muted: #94a3b8; --side-line: #1e293b;
  --accent: #0284c7; --accent-d: #0369a1; --ok: #16a34a; --ok-d: #15803d; --err: #dc2626; --err-d: #b91c1c; --warn: #d97706;
  --term: #090d16; --r: 8px; --r-sm: 6px; --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 1px rgba(15, 23, 42, .03);
  --head: "Manrope", system-ui, sans-serif; --body: "IBM Plex Sans", system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--body); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--head); letter-spacing: -.01em; margin: 0; }
.mono { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.mono.big { font-size: 18px; }
.brk { word-break: break-all; }
.note { color: var(--muted); font-size: 13px; margin: 6px 0; }
.err { color: var(--err-d); background: #fef2f2; border: 1px solid #fecaca; padding: 8px 10px; border-radius: var(--r-sm); margin: 8px 0; }
.strong { font-weight: 600; color: var(--ink); }
.caps { text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 600; color: var(--muted); margin: 0; }
.grow { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 16px 12px; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--side-ink); font: 700 17px var(--head); padding: 4px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 7px; background: linear-gradient(135deg, #0ea5e9, #0369a1); color: #fff; font: 800 12px var(--head); letter-spacing: .04em; }
.side nav { flex: 1; overflow-y: auto; }
.nav-group { color: var(--side-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; margin: 14px 10px 6px; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: #cbd5e1; font-weight: 500; transition: background-color .15s ease, color .15s ease; }
.nav-link:hover { background: var(--side-line); color: #fff; text-decoration: none; }
.nav-link.on { background: var(--side-line); color: #38bdf8; box-shadow: inset 2px 0 0 #38bdf8; }
.ic { flex: none; }
.side-foot { border-top: 1px solid var(--side-line); padding-top: 12px; }
.who { margin: 0 0 8px; padding: 0 6px; font-weight: 600; display: flex; flex-direction: column; }
.who small { color: var(--side-muted); font-weight: 400; text-transform: capitalize; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 28px; background: rgba(248, 250, 252, .86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-title { font-size: 20px; font-weight: 700; margin-right: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; flex: none; }
.dot-ok { background: #10b981; box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); animation: live 2s ease-out infinite; }
.dot-err { background: #f43f5e; }
.dot-warn { background: #f59e0b; }
.dot-off { background: var(--faint); }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .55); } 70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
.wrap { padding: 22px 28px 48px; display: flex; flex-direction: column; gap: 16px; animation: rise .25s ease-out; }
.nav-toggle, .burger, .scrim { display: none; }

/* ---------- auth ---------- */
.guest { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, #e0f2fe, transparent 60%), var(--bg); }
.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px; gap: 12px; align-content: center; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: 0 10px 30px rgba(15, 23, 42, .08); animation: rise .3s ease-out; }
.auth-card h1 { font-size: 22px; margin-top: 18px; }
.auth-brand { display: flex; gap: 12px; align-items: center; }
.auth-name { font: 700 16px var(--head); margin: 0; }
.auth-brand .note { margin: 0; }

/* ---------- building blocks ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); align-items: start; }
.g-import { grid-template-columns: minmax(300px, 1fr) minmax(0, 1fr); align-items: start; }
.g-phone { grid-template-columns: minmax(280px, 1fr) minmax(280px, 420px); align-items: start; }
.mini { gap: 8px; margin-top: 10px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 14.5px; font-weight: 700; }
.panel-body { padding: 14px 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .num { font: 600 24px var(--mono); margin: 4px 0 0; letter-spacing: -.02em; }
.stat.accent { border-color: #bae6fd; background: linear-gradient(180deg, #f0f9ff, #fff); }
.stat.accent .num { color: var(--accent-d); }
.mini .stat { padding: 8px 10px; box-shadow: none; }
.mini .stat .num { font-size: 18px; }
.health-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.health { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.health .dot { margin-top: 6px; }
.health.is-bad { border-color: #fecdd3; background: #fff7f8; }
.h-label { margin: 0; font-weight: 600; }
.h-detail { margin: 0; font-size: 12.5px; color: var(--muted); word-break: break-word; }
.row { display: flex; align-items: center; gap: 8px; }
.row.tight { gap: 4px; }
.wrap-row { flex-wrap: wrap; }
.head-row h2.h2 { font-size: 22px; }
.progress { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress.big { height: 10px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #0ea5e9, #0369a1); border-radius: inherit; transition: width .4s ease; }

/* ---------- buttons ---------- */
.btn, button { font: 500 13px var(--body); display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid transparent; background: var(--accent); color: #fff; cursor: pointer; text-decoration: none; transition: background-color .15s ease, border-color .15s ease, transform .08s ease, opacity .15s ease; white-space: nowrap; }
.btn:hover, button:hover { background: var(--accent-d); text-decoration: none; }
.btn:active, button:active { transform: scale(.98); }
.btn:disabled, button:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--panel); color: var(--ink); border-color: var(--line2); }
.btn.ghost:hover { background: #f1f5f9; }
.side .btn.ghost { background: transparent; color: #cbd5e1; border-color: var(--side-line); }
.side .btn.ghost:hover { background: var(--side-line); }
.btn.danger { background: var(--err); }
.btn.danger:hover { background: var(--err-d); }
.btn.ok { background: #059669; }
.btn.ok:hover { background: #047857; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.full { width: 100%; }
.btn.busy::before { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
form.inline { display: inline; margin: 0; }

/* ---------- forms ---------- */
.forms { display: flex; flex-direction: column; gap: 10px; }
.forms.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; margin-top: 12px; }
.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.f small { color: var(--faint); font-weight: 400; }
.f.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); flex-wrap: wrap; }
.f.check small { flex-basis: 100%; }
input, select, textarea { font: 14px var(--body); color: var(--ink); background: #fff; border: 1px solid var(--line2); border-radius: var(--r-sm); padding: 8px 10px; width: 100%; transition: border-color .15s ease, box-shadow .15s ease; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(2, 132, 199, .15); }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; }
audio { height: 32px; max-width: 220px; }
.sr-file { max-width: 170px; font-size: 12px; padding: 4px; }

/* ---------- tables & badges ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; background: #f8fafc; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color .12s ease; }
tbody tr:hover { background: #f8fafc; }
td.empty { text-align: center; color: var(--faint); padding: 26px; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; background: #f1f5f9; color: var(--muted); white-space: nowrap; }
.b-registered, .b-available, .b-connected, .b-running, .b-pressed, .b-transferred, .b-answered, .b-yes, .b-synced, .b-completed, .b-incall, .b-live { background: #dcfce7; color: #15803d; }
.b-queued, .b-sent, .b-paused, .b-waiting, .b-connecting, .b-ringing, .b-calling, .b-retrying { background: #fef3c7; color: #b45309; }
.b-failed, .b-down, .b-busy, .b-declined, .b-noanswer, .b-notregistered, .b-noaudio, .b-stopped, .b-cancelled, .b-error { background: #fee2e2; color: #b91c1c; }
.b-trunk, .b-admin, .b-new { background: #e0f2fe; color: #0369a1; }
.b-line, .b-agent, .b-draft, .b-offline, .b-disabled, .b-idle, .b-customer, .b-no, .b-off { background: #f1f5f9; color: #475569; }

/* ---------- flash & toast ---------- */
.flash { margin: 0; padding: 10px 14px; border-radius: var(--r-sm); border: 1px solid #bbf7d0; background: #f0fdf4; color: #166534; animation: rise .25s ease-out; }
.flash-err { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 380px; background: #0f172a; color: #f8fafc; padding: 10px 14px; border-radius: var(--r-sm); box-shadow: 0 10px 30px rgba(15, 23, 42, .25); opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 50; font-size: 13px; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: #7f1d1d; }

/* ---------- diagnostics terminal & timeline ---------- */
.term { background: var(--term); color: #e2e8f0; border-radius: var(--r-sm); padding: 12px 14px; font: 12px/1.7 var(--mono); margin-top: 12px; min-height: 90px; max-height: 340px; overflow: auto; }
.term.small { min-height: 60px; max-height: 160px; font-size: 11.5px; }
.term p { margin: 0; animation: rise .2s ease-out; }
.t-ok { color: #22c55e; } .t-err { color: #f87171; } .t-info { color: #38bdf8; } .t-warn { color: #f59e0b; } .t-muted { color: #64748b; }
.timeline { list-style: none; margin: 14px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.timeline:empty { display: none; }
.timeline li { position: relative; font-size: 13px; animation: rise .2s ease-out; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--faint); border: 2px solid #fff; }
.timeline li.ok::before { background: #10b981; } .timeline li.bad::before { background: #f43f5e; } .timeline li.wait::before { background: #f59e0b; }

/* ---------- leads ---------- */
.drop { border: 1.5px dashed var(--line2); border-radius: var(--r); padding: 18px; text-align: center; background: #f8fafc; transition: border-color .15s ease, background-color .15s ease; margin-bottom: 10px; }
.drop.over { border-color: var(--accent); background: #f0f9ff; }
.drop p { margin: 0 0 6px; }
.drop small { color: var(--muted); }
.preview { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; font-size: 12.5px; background: #fcfdfe; margin: 8px 0; }
.preview table { font-size: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.filters select, .filters input { width: auto; min-width: 150px; flex: 1; }
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #f8fafc; margin-bottom: 10px; font-size: 12.5px; }
.bulkbar .sep { width: 1px; height: 20px; background: var(--line2); margin: 0 4px; }
.bulkbar #bulk-count { font-weight: 600; margin-right: 4px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 12px; }

/* ---------- webphone ---------- */
.dial-screen { font: 500 22px var(--mono); letter-spacing: .08em; text-align: center; margin: 10px 0; padding: 10px; }
.dial { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.dial button { background: #f1f5f9; color: var(--ink); font: 600 18px var(--mono); padding: 12px 0; border: 1px solid var(--line); }
.dial button:hover { background: #e2e8f0; }
.incoming { border: 1px solid #bae6fd; background: #f0f9ff; border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 10px; animation: rise .2s ease-out; }
.incoming p { margin: 0 0 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4, .health-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-side, .g-import, .g-phone, .g2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; transform: translateX(-100%); transition: transform .2s ease-in-out; }
  .nav-toggle:checked ~ .side { transform: none; }
  .nav-toggle:checked ~ .scrim { display: block; position: fixed; inset: 0; background: rgba(2, 6, 23, .45); z-index: 25; }
  .burger { display: inline-flex; flex-direction: column; gap: 4px; padding: 8px; cursor: pointer; border: 1px solid var(--line2); border-radius: var(--r-sm); background: var(--panel); }
  .burger span { width: 16px; height: 2px; background: var(--ink); display: block; }
  .top { padding: 10px 14px; }
  .wrap { padding: 14px 14px 40px; }
  .g4, .g5, .health-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
