/* sipfish – app.css · dark and light theme (data-theme on <html>), desktop and phone layouts */
:root {
  --accent: #17a2b8; --accent-2: #0f7f91; --accent-soft: rgba(23, 162, 184, .14);
  --ok: #1fae5b; --ok-2: #178a48; --bad: #e5484d; --bad-2: #c23338; --warn: #e8a317; --info: #3b82f6;
  --radius: 14px; --radius-s: 9px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --top: 56px; --nav: 84px; --dock: 380px; --status: 30px;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1418; --bg-2: #121a1f; --panel: #172128; --panel-2: #1d2931; --panel-3: #24323b; --line: #2a3a44; --line-2: #33464f;
  --text: #e6eef2; --text-2: #a9bac3; --text-3: #7b8f99; --shadow: 0 10px 30px rgba(0, 0, 0, .45); --hover: rgba(255, 255, 255, .05);
  --key: #1e2a32; --key-hover: #26363f;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef3f5; --bg-2: #e6edf0; --panel: #ffffff; --panel-2: #f5f8f9; --panel-3: #eaf0f2; --line: #dbe4e8; --line-2: #c9d5da;
  --text: #13232b; --text-2: #4b5f69; --text-3: #7a8d96; --shadow: 0 10px 30px rgba(20, 40, 50, .14); --hover: rgba(0, 40, 60, .05);
  --key: #f1f5f7; --key-hover: #e3ecf0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
.mono { font-family: var(--mono); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.wrap { flex-wrap: wrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
svg.i.s { width: 16px; height: 16px; }
svg.i.l { width: 26px; height: 26px; }

/* ---------- app shell ---------- */
#app { display: grid; height: 100vh; height: 100dvh; grid-template-columns: var(--nav) 1fr auto; grid-template-rows: var(--top) 1fr var(--status); grid-template-areas: "top top top" "nav main dock" "status status status"; }
#top { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; z-index: 5; }
#nav { grid-area: nav; display: flex; flex-direction: column; gap: 4px; padding: 10px 8px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; }
#main { grid-area: main; overflow: auto; position: relative; min-width: 0; }
#dock { grid-area: dock; width: var(--dock); background: var(--bg-2); border-left: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
#dock:empty, #dock.empty { display: none; }
#status { grid-area: status; display: flex; align-items: center; gap: 12px; padding: 0 14px; font-size: 12px; color: var(--text-3); background: var(--panel); border-top: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
#status a { color: var(--text-2); text-decoration: none; }
#status a:hover { color: var(--accent); }
#status .st-msg { overflow: hidden; text-overflow: ellipsis; }
#status .st-msg.warn { color: var(--warn); cursor: pointer; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: .2px; color: var(--text); text-decoration: none; margin-right: 6px; }
.brand svg { width: 30px; height: 30px; }
.brand small { font-weight: 500; color: var(--text-3); font-size: 11px; margin-left: -2px; }
#lines { display: flex; gap: 6px; min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 1; }
#lines::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; white-space: nowrap; font-size: 13px; color: var(--text); }
.chip:hover { border-color: var(--line-2); background: var(--panel-3); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.chip .sub { color: var(--text-3); font-size: 12px; }
.dot.ready { background: var(--ok); box-shadow: 0 0 0 3px rgba(31, 174, 91, .18); }
.dot.connecting { background: var(--warn); animation: pulse 1.2s infinite; }
.dot.offline, .dot.failed { background: var(--bad); }
.dot.incomplete, .dot.off { background: var(--text-3); }
@keyframes pulse { 50% { opacity: .35; } }
.topbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; min-width: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text-2); text-decoration: none; font-size: 13px; }
.topbtn:hover { background: var(--hover); color: var(--text); }
.topbtn.on { color: #fff; background: var(--bad); }
.topbtn.on:hover { background: var(--bad-2); }
.badge { position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; }
.navbtn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 62px; border-radius: 12px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-size: 11.5px; font-weight: 600; }
.navbtn:hover { background: var(--hover); color: var(--text); }
.navbtn.active { background: var(--accent-soft); color: var(--accent); }
.navbtn .badge { top: 6px; right: 14px; }
.navsep { flex: 1; }

/* ---------- generic controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 600; font-size: 13px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--panel-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { background: var(--ok-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: var(--bad-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
input.in, select.in, textarea.in { width: 100%; height: 38px; padding: 0 11px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel-2); outline: none; }
textarea.in { height: auto; min-height: 80px; padding: 9px 11px; resize: vertical; }
select.in { padding-right: 28px; }
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.in:disabled, select.in:disabled, textarea.in:disabled { opacity: .65; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type=range] { accent-color: var(--accent); width: 100%; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-weight: 600; font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .lock { color: var(--warn); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 14px; }
.toggle { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; cursor: pointer; }
.toggle .sw { position: relative; flex: none; width: 40px; height: 23px; border-radius: 12px; background: var(--line-2); transition: background .15s; margin-top: 1px; }
.toggle .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle input:checked + .sw { background: var(--accent); }
.toggle input:checked + .sw::after { transform: translateX(17px); }
.toggle input:disabled + .sw { opacity: .5; }
.toggle .tl { font-weight: 600; }
.toggle .th { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--panel-3); gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--text-2); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--panel-3); color: var(--text-2); }
.tag.ok { background: rgba(31, 174, 91, .15); color: var(--ok); }
.tag.bad { background: rgba(229, 72, 77, .14); color: var(--bad); }
.tag.warn { background: rgba(232, 163, 23, .16); color: var(--warn); }
.tag.acc { background: var(--accent-soft); color: var(--accent); }
.kbd { font: 11px var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2); }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-3); }
.empty-state svg { width: 46px; height: 46px; stroke-width: 1.4; opacity: .6; margin-bottom: 10px; }
.empty-state h3 { color: var(--text-2); margin: 0 0 6px; font-size: 16px; }
.note { display: flex; gap: 10px; padding: 11px 13px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; }
.note.warn { background: rgba(232, 163, 23, .1); border-color: rgba(232, 163, 23, .35); }
.note.bad { background: rgba(229, 72, 77, .09); border-color: rgba(229, 72, 77, .35); }
.note.ok { background: rgba(31, 174, 91, .09); border-color: rgba(31, 174, 91, .3); }
.note.info { background: var(--accent-soft); border-color: rgba(23, 162, 184, .35); }
.note svg { flex: none; margin-top: 1px; }
.note p { margin: 0 0 4px; }
.note p:last-child { margin: 0; }

/* ---------- views ---------- */
.view { padding: 22px 26px 40px; max-width: 1180px; margin: 0 auto; }
.view-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.view-head h1 { font-size: 22px; margin: 0; font-weight: 700; flex: 1; min-width: 160px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.card h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h3 { font-size: 13.5px; margin: 16px 0 8px; color: var(--text-2); }
.searchbox { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.searchbox svg { position: absolute; left: 11px; top: 9px; color: var(--text-3); }
.searchbox input { padding-left: 36px; }
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; cursor: pointer; min-width: 0; }
.item:hover { background: var(--hover); }
.item.sel { background: var(--accent-soft); }
.item .meta { flex: 1; min-width: 0; }
.item .t1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t2 { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .acts { display: flex; gap: 4px; opacity: 0; transition: opacity .1s; }
.item:hover .acts, .item:focus-within .acts { opacity: 1; }
.daylabel { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; padding: 14px 12px 6px; }
.avatar { flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 700; color: #fff; user-select: none; }

/* ---------- dialer ---------- */
.phone-layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 18px; align-items: start; }
.dialer { padding: 18px 18px 20px; }
.dial-acc { margin-bottom: 10px; }
.dial-input { position: relative; display: flex; align-items: center; gap: 6px; border-bottom: 2px solid var(--line); padding-bottom: 4px; margin-bottom: 6px; }
.dial-input:focus-within { border-color: var(--accent); }
.dial-input input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 27px; font-weight: 300; letter-spacing: .5px; height: 50px; text-align: center; }
.dial-hint { min-height: 20px; text-align: center; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 10; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); padding: 4px; max-height: 280px; overflow-y: auto; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 4px 14px; }
.key { height: 60px; border-radius: 16px; border: 0; background: var(--key); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; user-select: none; -webkit-tap-highlight-color: transparent; }
.key:hover { background: var(--key-hover); }
.key:active { transform: scale(.97); }
.key b { font-size: 24px; font-weight: 500; }
.key small { font-size: 10px; letter-spacing: 1.8px; color: var(--text-3); margin-top: 3px; min-height: 10px; }
.dial-actions { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 10px; align-items: center; margin: 0 4px; }
.callbtn { height: 58px; border-radius: 29px; border: 0; background: var(--ok); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 15px; box-shadow: 0 6px 16px rgba(31, 174, 91, .35); }
.callbtn:hover { background: var(--ok-2); }
.callbtn:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }
.callbtn svg { width: 24px; height: 24px; }
.roundbtn { justify-self: center; width: 50px; height: 50px; border-radius: 50%; border: 0; background: transparent; color: var(--text-2); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.roundbtn:hover { background: var(--hover); color: var(--text); }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.qcard { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; min-width: 0; }
.qcard:hover { border-color: var(--accent); }
.statusrow { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.stile { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; text-align: left; }
.stile:hover { border-color: var(--line-2); }
.stile .ic { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--panel-3); color: var(--text-2); flex: none; }
.stile.on .ic { background: var(--accent-soft); color: var(--accent); }
.stile.alert .ic { background: rgba(229, 72, 77, .14); color: var(--bad); }
.stile b { display: block; font-size: 13.5px; }
.stile span { font-size: 12px; color: var(--text-3); }

/* ---------- call dock ---------- */
.dock-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 4px; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; }
.callcard { margin: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }
.callcard.mini { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.callcard.mini:hover { border-color: var(--accent); }
.callcard.ended { opacity: .6; }
.cc-top { display: flex; flex-direction: column; align-items: center; padding: 20px 16px 12px; text-align: center; gap: 4px; position: relative; }
.cc-top .who { font-size: 19px; font-weight: 700; margin-top: 8px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-top .num { color: var(--text-2); font-size: 13px; }
.cc-top .state { margin-top: 6px; font-size: 13.5px; color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.cc-top .state.held { color: var(--warn); }
.cc-top .state.bad { color: var(--bad); }
.cc-top .acc { position: absolute; top: 10px; left: 12px; }
.cc-top .quality { position: absolute; top: 10px; right: 12px; display: flex; gap: 2px; align-items: flex-end; height: 16px; cursor: pointer; }
.quality i { display: block; width: 4px; border-radius: 2px; background: var(--line-2); }
.quality i:nth-child(1) { height: 5px; } .quality i:nth-child(2) { height: 9px; } .quality i:nth-child(3) { height: 13px; } .quality i:nth-child(4) { height: 16px; }
.quality.q4 i, .quality.q3 i:nth-child(-n+3) { background: var(--ok); }
.quality.q2 i:nth-child(-n+2) { background: var(--warn); }
.quality.q1 i:nth-child(1) { background: var(--bad); }
.cc-flags { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; min-height: 22px; }
.cc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 8px 16px 6px; }
.ccb { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 4px; border-radius: 13px; border: 0; background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 11.5px; font-weight: 600; }
.ccb:hover { background: var(--panel-3); }
.ccb.on { background: var(--accent); color: #fff; }
.ccb.rec.on { background: var(--bad); }
.ccb:disabled { opacity: .4; cursor: not-allowed; }
.cc-end { display: flex; justify-content: center; padding: 10px 16px 18px; gap: 12px; }
.hangbtn { width: 62px; height: 62px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(229, 72, 77, .35); }
.hangbtn:hover { background: var(--bad-2); }
.hangbtn svg { width: 28px; height: 28px; transform: rotate(135deg); }
.cc-sub { padding: 0 16px 14px; }
.cc-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cc-pad .key { height: 44px; border-radius: 11px; }
.cc-pad .key b { font-size: 19px; }
.cc-dtmf { text-align: center; font: 16px var(--mono); min-height: 24px; letter-spacing: 2px; color: var(--text-2); }
.videobox { position: relative; background: #000; aspect-ratio: 16/10; }
.videobox video.remote { width: 100%; height: 100%; object-fit: contain; display: block; }
.videobox video.local { position: absolute; right: 8px; bottom: 8px; width: 30%; border-radius: 8px; border: 2px solid rgba(255, 255, 255, .5); background: #222; }
.dock-foot { margin-top: auto; padding: 10px 12px 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.statsbox { font: 12px/1.6 var(--mono); color: var(--text-2); background: var(--panel-2); border-radius: 10px; padding: 8px 10px; margin: 0 16px 12px; display: grid; grid-template-columns: auto 1fr; gap: 0 10px; }

/* ---------- incoming call ---------- */
#incoming { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 10px; width: min(440px, calc(100vw - 24px)); }
.incall { background: var(--panel); border: 1px solid var(--line-2); border-radius: 22px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35); padding: 18px; animation: slidein .25s ease-out; }
@keyframes slidein { from { transform: translateY(-16px); opacity: 0; } }
.incall .ic-head { display: flex; align-items: center; gap: 14px; }
.incall .ring { position: relative; }
.incall .ring::before, .incall .ring::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--ok); animation: ripple 1.6s infinite; }
.incall .ring::after { animation-delay: .8s; }
@keyframes ripple { from { transform: scale(.9); opacity: .9; } to { transform: scale(1.5); opacity: 0; } }
.incall .who { font-size: 18px; font-weight: 700; }
.incall .sub { color: var(--text-2); font-size: 13px; }
.incall .ic-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.incall .ic-acts.three { grid-template-columns: 1fr 1fr 1fr; }
.incall .ic-more { display: flex; gap: 6px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.bigbtn { height: 48px; border-radius: 24px; border: 0; font-weight: 700; color: #fff; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-size: 14px; }
.bigbtn.ok { background: var(--ok); } .bigbtn.ok:hover { background: var(--ok-2); }
.bigbtn.bad { background: var(--bad); } .bigbtn.bad:hover { background: var(--bad-2); }
.bigbtn.bad svg { transform: rotate(135deg); }
.bigbtn.alt { background: var(--accent); } .bigbtn.alt:hover { background: var(--accent-2); }

/* ---------- banners, toasts, dialogs, menus ---------- */
#banners { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--status) + 14px); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(620px, calc(100vw - 24px)); pointer-events: none; }
.banner { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-size: 13px; }
.banner.warn { border-color: rgba(232, 163, 23, .6); }
.banner.bad { border-color: rgba(229, 72, 77, .6); }
.banner .bt { flex: 1; min-width: 0; }
.banner b { display: block; margin-bottom: 1px; }
#toasts { position: fixed; right: 16px; bottom: calc(var(--status) + 14px); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 420px; padding: 11px 14px; border-radius: 12px; background: #1f2b33; color: #eef4f6; box-shadow: var(--shadow); font-size: 13px; animation: toastin .2s ease-out; }
html[data-theme="light"] .toast { background: #23323b; }
.toast.ok svg { color: #4ade80; } .toast.error svg { color: #ff8080; } .toast.warn svg { color: #fbbf24; } .toast.info svg { color: #67d4e6; }
.toast button { background: transparent; border: 0; color: #67d4e6; font-weight: 700; cursor: pointer; padding: 0 0 0 6px; }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } }
#overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(5, 12, 16, .55); backdrop-filter: blur(2px); }
#overlay:empty { display: none; }
.dialog { width: min(520px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: 0 24px 60px rgba(0, 0, 0, .4); animation: pop .16s ease-out; }
.dialog.wide { width: min(820px, 100%); }
.dialog.xwide { width: min(1100px, 100%); }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.dialog > header { display: flex; align-items: center; gap: 10px; padding: 16px 18px 6px; }
.dialog > header h2 { margin: 0; font-size: 17px; flex: 1; }
.dialog > .body { padding: 8px 18px 14px; overflow-y: auto; }
.dialog > footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dialog > footer .left { margin-right: auto; }
.dialog > footer .left:has(+ .left) { margin-right: 0; }
.menu { position: fixed; z-index: 120; min-width: 200px; max-width: 320px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); padding: 5px; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-align: left; font-size: 13px; }
.menu button:hover { background: var(--hover); }
.menu button.danger { color: var(--bad); }
.menu button:disabled { opacity: .45; cursor: default; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.menu .mh { padding: 6px 10px 4px; font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: 210px 1fr; gap: 20px; align-items: start; }
.subnav { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.subnav button { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; color: var(--text-2); font-weight: 600; text-align: left; }
.subnav button:hover { background: var(--hover); color: var(--text); }
.subnav button.on { background: var(--accent-soft); color: var(--accent); }
.acclist .item { border: 1px solid var(--line); margin-bottom: 8px; }
.sec { padding: 6px 0; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); }
.check .ci { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: none; }
.check.ok .ci { background: rgba(31, 174, 91, .15); color: var(--ok); }
.check.warn .ci { background: rgba(232, 163, 23, .15); color: var(--warn); }
.check.bad .ci { background: rgba(229, 72, 77, .14); color: var(--bad); }
.check .ct { flex: 1; min-width: 0; }
.check .ct b { display: block; font-size: 13.5px; }
.check .ct span { font-size: 12.5px; color: var(--text-3); }
.meter { height: 8px; border-radius: 4px; background: var(--panel-3); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--warn) 80%, var(--bad)); transition: width .08s; }
.strength { height: 5px; border-radius: 3px; background: var(--panel-3); overflow: hidden; margin-top: 6px; }
.strength i { display: block; height: 100%; transition: width .2s, background .2s; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--hover); }
.table-wrap { overflow-x: auto; }
.qrbox { display: flex; justify-content: center; padding: 10px; background: #fff; border-radius: 12px; }
.qrbox svg { width: 240px; height: 240px; }
.codebox { font: 600 20px var(--mono); letter-spacing: 2px; text-align: center; padding: 12px; border-radius: 12px; background: var(--panel-2); border: 1px dashed var(--line-2); user-select: all; }
.dropzone { border: 2px dashed var(--line-2); border-radius: 14px; padding: 26px; text-align: center; color: var(--text-2); cursor: pointer; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- messages ---------- */
.chat { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - var(--top) - var(--status)); height: calc(100dvh - var(--top) - var(--status)); }
.chat .threads { border-right: 1px solid var(--line); overflow-y: auto; padding: 14px 8px; background: var(--panel); }
.chat .conv { display: flex; flex-direction: column; min-width: 0; }
.conv-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.conv-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: min(560px, 78%); padding: 8px 12px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); white-space: pre-wrap; word-wrap: break-word; }
.bubble.out { align-self: flex-end; background: var(--accent); color: #fff; border-color: var(--accent); border-bottom-right-radius: 5px; }
.bubble.in { align-self: flex-start; border-bottom-left-radius: 5px; }
.bubble .bt { display: block; font-size: 10.5px; opacity: .7; margin-top: 3px; text-align: right; }
.bubble.failed { background: var(--bad); border-color: var(--bad); }
.conv-input { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel); align-items: flex-end; }
.conv-input textarea { min-height: 42px; max-height: 160px; height: 42px; }
.typing { font-size: 12px; color: var(--text-3); padding: 0 18px 6px; min-height: 18px; }

/* ---------- team ---------- */
.blfgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.blf { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 13px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; min-width: 0; }
.blf:hover { border-color: var(--line-2); }
.blf .lamp { width: 12px; height: 12px; border-radius: 50%; background: var(--line-2); flex: none; }
.blf.idle .lamp { background: var(--ok); }
.blf.busy .lamp { background: var(--bad); }
.blf.ringing .lamp { background: var(--warn); animation: pulse .6s infinite; }
.blf.calling .lamp { background: var(--warn); }
.blf.ringing { border-color: var(--warn); }

/* ---------- lock / gate screens ---------- */
.gate { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.gate .card { width: min(440px, 100%); text-align: center; }
.gate .brand { justify-content: center; font-size: 22px; margin-bottom: 8px; }
.gate .brand svg { width: 46px; height: 46px; }
.wizard { max-width: 760px; margin: 0 auto; }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.choice button { text-align: left; padding: 16px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--panel-2); cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.choice button:hover, .choice button.on { border-color: var(--accent); background: var(--accent-soft); }
.choice button b { font-size: 15px; }
.choice button span { font-size: 12.5px; color: var(--text-2); }
.choice button svg { color: var(--accent); width: 28px; height: 28px; }
.steps { display: flex; gap: 6px; margin-bottom: 14px; }
.steps i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.steps i.on { background: var(--accent); }
.trace { font: 12px/1.45 var(--mono); white-space: pre-wrap; word-break: break-all; background: var(--panel-2); border-radius: 10px; padding: 10px; max-height: 50vh; overflow: auto; }
.trace .tin { color: #1aa36b; } .trace .tout { color: #3b82f6; } .trace .terr { color: var(--bad); }
.helpdoc { line-height: 1.6; }
.helpdoc h2 { font-size: 17px; margin: 22px 0 8px; }
.helpdoc h3 { font-size: 14px; margin: 16px 0 6px; }
.helpdoc pre { font: 12px/1.5 var(--mono); background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; }
.helpdoc code { font: 12.5px var(--mono); background: var(--panel-3); padding: 1px 5px; border-radius: 5px; }
.helpdoc pre code { background: none; padding: 0; }
.helpdoc li { margin: 3px 0; }

#dock .dock-close { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { :root { --dock: 340px; } .phone-layout { grid-template-columns: minmax(280px, 360px) 1fr; } }
@media (max-width: 980px) {
  #app { grid-template-columns: var(--nav) 1fr; grid-template-areas: "top top" "nav main" "status status"; }
  #dock { position: fixed; z-index: 40; right: 0; top: var(--top); bottom: var(--status); box-shadow: var(--shadow); }
  .phone-layout { grid-template-columns: 1fr; max-width: 520px; margin: 0 auto; }
  .settings { grid-template-columns: 1fr; }
  .subnav { position: static; flex-direction: row; overflow-x: auto; }
  .subnav button { white-space: nowrap; }
}
@media (max-width: 720px) {
  :root { --top: 52px; --nav: 0px; --status: 0px; }
  #app { grid-template-columns: 1fr; grid-template-rows: var(--top) 1fr 64px; grid-template-areas: "top" "main" "nav"; }
  #nav { flex-direction: row; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); overflow: visible; }
  .navbtn { flex: 1; height: 54px; font-size: 10.5px; }
  .navbtn.desk { display: none; }
  .navsep { display: none; }
  #status { display: none; }
  #dock { position: fixed; inset: 0; width: auto; z-index: 70; border: 0; }
  #dock .dock-close { display: inline-flex; }
  .brand span, .brand small { display: none; }
  .topbtn .lbl { display: none; }
  .view { padding: 14px 14px 30px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; height: calc(100dvh - var(--top) - 64px); }
  .chat.open .threads { display: none; }
  .chat:not(.open) .conv { display: none; }
  .item .acts { opacity: 1; }
  #incoming { top: 10px; }
  #banners { bottom: 76px; }
  #toasts { bottom: 76px; left: 12px; right: 12px; align-items: stretch; }
  .key { height: 64px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print {
  body { overflow: visible; background: #fff; color: #000; }
  #app, #incoming, #banners, #toasts { display: none !important; }
  #overlay { position: static; background: none; backdrop-filter: none; padding: 0; }
  .dialog { box-shadow: none; border: 0; max-height: none; width: 100%; }
  .dialog > header button, .dialog > footer { display: none; }
  .noprint { display: none !important; }
}
