*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d; --surface: #161616; --surface2: #1f1f1f;
  --border: #2a2a2a; --text: #f0f0f0; --muted: #666;
  --accent: #833ab4; --gold: #fcb045; --green: #2ecc71; --red: #e74c3c;
}

body { background:var(--bg); color:var(--text); font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; display:flex; height:100vh; overflow:hidden; }

/* ── Sidebar ── */
.sidebar { width:210px; flex-shrink:0; background:var(--surface); border-right:1px solid var(--border); display:flex; flex-direction:column; padding:18px 13px; gap:16px; }

.logo { display:flex; align-items:center; gap:9px; font-size:18px; font-weight:800; background:linear-gradient(135deg,#833ab4,#fd1d1d,#fcb045); -webkit-background-clip:text; -webkit-text-fill-color:transparent; }
.logo-icon { font-size:20px; }

.stats-block { display:flex; gap:7px; }
.stat { flex:1; background:var(--surface2); border:1px solid var(--border); border-radius:9px; padding:10px 7px; text-align:center; }
.stat-value { font-size:20px; font-weight:800; color:var(--gold); }
.stat-label { font-size:9px; color:var(--muted); margin-top:2px; }

.spam-bar { background:var(--surface2); border:1px solid var(--border); border-radius:8px; padding:9px 11px; }
.spam-label { font-size:11px; color:var(--muted); margin-bottom:6px; }
.spam-track { background:#2a2a2a; border-radius:3px; height:4px; overflow:hidden; }
.spam-fill { height:100%; background:linear-gradient(90deg,var(--green),var(--gold)); border-radius:3px; transition:width .4s; }

.nav { display:flex; flex-direction:column; gap:3px; }
.nav-btn { width:100%; text-align:left; padding:9px 11px; border:none; border-radius:7px; background:none; color:var(--muted); font-size:13px; font-weight:600; cursor:pointer; transition:all .12s; position:relative; }
.nav-btn:hover { background:var(--surface2); color:var(--text); }
.nav-btn.active { background:var(--surface2); color:var(--text); }

.unread-badge, .queue-badge { background:var(--red); color:#fff; font-size:10px; font-weight:800; padding:1px 6px; border-radius:20px; margin-left:5px; }
.queue-badge { background:var(--accent); }

.sidebar-actions { margin-top:auto; }
.action-btn { display:block; text-align:center; text-decoration:none; background:var(--surface2); border:1px solid var(--border); border-radius:7px; color:var(--muted); font-size:12px; padding:8px; cursor:pointer; transition:all .12s; }
.action-btn:hover { color:var(--text); border-color:#444; }

/* ── Main ── */
.main { flex:1; display:flex; flex-direction:column; overflow:hidden; }
.view { display:none; flex:1; overflow:hidden; }
.view.active { display:flex; flex-direction:column; }

/* ── Split view (threads) ── */
.split-view { flex-direction:row !important; }

.thread-list { width:280px; flex-shrink:0; border-right:1px solid var(--border); display:flex; flex-direction:column; overflow:hidden; }
.thread-list-header { padding:14px 16px; border-bottom:1px solid var(--border); font-size:13px; font-weight:700; display:flex; align-items:center; justify-content:space-between; flex-shrink:0; }
.icon-btn { background:none; border:none; color:var(--muted); cursor:pointer; font-size:16px; padding:2px 6px; border-radius:4px; }
.icon-btn:hover { color:var(--text); background:var(--surface2); }

#threadItems { flex:1; overflow-y:auto; }

.thread-item { padding:13px 16px; border-bottom:1px solid var(--border); cursor:pointer; transition:background .1s; position:relative; }
.thread-item:hover { background:var(--surface2); }
.thread-item.active { background:var(--surface2); border-left:3px solid var(--accent); }
.thread-item.has-unread { background:rgba(131,58,180,.07); }

.ti-top { display:flex; align-items:center; justify-content:space-between; margin-bottom:4px; }
.ti-user { font-size:13px; font-weight:700; }
.ti-time { font-size:10px; color:var(--muted); }
.ti-preview { font-size:11px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:220px; }
.ti-badges { display:flex; align-items:center; gap:5px; margin-top:5px; }
.stage-pill { font-size:9px; font-weight:700; padding:2px 7px; border-radius:20px; text-transform:uppercase; letter-spacing:.4px; }
.stage-0 { background:#1a1a1a; color:var(--muted); border:1px solid #2a2a2a; }
.stage-1 { background:rgba(252,176,69,.15); color:var(--gold); }
.stage-2 { background:rgba(131,58,180,.2); color:#b47fe0; }
.stage-3 { background:rgba(46,204,113,.15); color:var(--green); }
.stage-4 { background:rgba(46,204,113,.25); color:var(--green); }
.stage-5 { background:rgba(46,204,113,.4); color:#fff; }
.new-dot { width:7px; height:7px; border-radius:50%; background:var(--red); }

/* ── Thread detail ── */
.thread-detail { flex:1; display:flex; flex-direction:column; overflow:hidden; }
.thread-empty { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; color:var(--muted); text-align:center; padding:40px; }
.empty-sub { font-size:12px; margin-top:6px; color:#444; }

.thread-header { padding:14px 18px; border-bottom:1px solid var(--border); flex-shrink:0; display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.th-user { font-size:15px; font-weight:800; margin-bottom:3px; }
.th-post { font-size:11px; color:var(--accent); text-decoration:none; }
.th-post:hover { text-decoration:underline; }
.th-right { display:flex; align-items:center; gap:8px; }
.funnel-track { display:flex; gap:3px; align-items:center; }
.funnel-step { width:22px; height:4px; border-radius:2px; background:#2a2a2a; }
.funnel-step.filled { background:var(--accent); }

.messages-area { flex:1; overflow-y:auto; padding:16px 18px; display:flex; flex-direction:column; gap:10px; }

.msg-row { display:flex; }
.msg-row.us { justify-content:flex-end; }
.msg-row.them { justify-content:flex-start; }

.msg-bubble { max-width:72%; padding:10px 13px; border-radius:14px; font-size:13px; line-height:1.5; }
.msg-row.us .msg-bubble { background:linear-gradient(135deg,#4a1a70,#833ab4); color:#fff; border-bottom-right-radius:4px; }
.msg-row.them .msg-bubble { background:var(--surface2); border:1px solid var(--border); border-bottom-left-radius:4px; }
.msg-meta { font-size:10px; color:var(--muted); margin-top:4px; text-align:right; }
.msg-row.them .msg-meta { text-align:left; }
.msg-new-tag { font-size:9px; font-weight:800; color:var(--red); margin-left:5px; }

/* ── Reply box ── */
.reply-area { border-top:1px solid var(--border); padding:14px 18px; flex-shrink:0; }
.reply-controls { display:flex; gap:8px; margin-bottom:10px; }
.reply-type-btn { padding:5px 12px; font-size:11px; font-weight:700; border:1px solid var(--border); border-radius:20px; background:var(--surface2); color:var(--muted); cursor:pointer; transition:all .12s; }
.reply-type-btn.active { background:var(--accent); border-color:var(--accent); color:#fff; }

.ai-draft-ta {
  width:100%; background:var(--surface2); border:1px solid var(--border); border-radius:10px;
  padding:11px 13px; font-size:13px; color:var(--text); line-height:1.5; min-height:80px;
  resize:vertical; outline:none; font-family:inherit; margin-bottom:6px;
  display:block; transition:border-color .15s;
}
.ai-draft-ta:focus { border-color:var(--accent); }
.ai-draft-ta:disabled { opacity:.55; cursor:default; }
.ai-draft-ta.alert { border-color:var(--red); color:var(--red); }
.ai-draft-ta::placeholder { color:#444; }

.ai-status { font-size:11px; margin-bottom:8px; min-height:0; }
.ai-status-sending { color:var(--gold); padding:7px 10px; background:rgba(252,176,69,.07); border:1px solid rgba(252,176,69,.2); border-radius:7px; }
.ai-status-warn { color:var(--red); padding:7px 10px; background:rgba(231,76,60,.07); border:1px solid rgba(231,76,60,.2); border-radius:7px; }

.reply-btns { display:flex; gap:7px; }
.reply-btn { padding:9px 16px; border-radius:8px; border:1px solid var(--border); background:var(--surface2); color:var(--muted); font-size:12px; font-weight:700; cursor:pointer; transition:all .12s; }
.reply-btn.generate { flex:1; background:linear-gradient(135deg,#833ab4,#fd1d1d); border:none; color:#fff; }
.reply-btn.approve { flex:1; background:linear-gradient(135deg,#1a472a,#27ae60); border-color:#27ae60; color:#fff; font-weight:700; }
.reply-btn.approve:hover { background:linear-gradient(135deg,#27ae60,#2ecc71); }
.reply-btn.approve:disabled { opacity:.55; cursor:not-allowed; }
.reply-btn.send { background:var(--surface2); border-color:#444; color:var(--muted); }
.reply-btn.send:hover { color:var(--text); border-color:#666; }
.reply-btn:not(.generate):not(.approve):not(.send):hover { color:var(--text); border-color:#444; }

/* ── Topbar ── */
.topbar { padding:16px 20px 12px; border-bottom:1px solid var(--border); display:flex; align-items:flex-start; justify-content:space-between; flex-shrink:0; gap:12px; }
.topbar h1 { font-size:16px; font-weight:700; margin-bottom:7px; }
.topbar-sub { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.topbar-filters { display:flex; gap:5px; align-self:flex-end; }
.search-input { background:var(--surface2); border:1px solid var(--border); border-radius:7px; padding:6px 10px; color:var(--text); font-size:12px; outline:none; width:150px; }
.search-input:focus { border-color:var(--accent); }
.filter-buttons, .topbar-filters { display:flex; gap:5px; }
.filter-btn { background:var(--surface2); border:1px solid var(--border); border-radius:20px; color:var(--muted); font-size:11px; padding:4px 10px; cursor:pointer; transition:all .12s; }
.filter-btn:hover { color:var(--text); border-color:#444; }
.filter-btn.active { background:var(--accent); border-color:var(--accent); color:white; }
.count-badge { font-size:12px; color:var(--muted); white-space:nowrap; }

/* ── Lead grid ── */
.lead-grid { flex:1; overflow-y:auto; padding:16px 20px; display:grid; grid-template-columns:repeat(auto-fill,minmax(175px,1fr)); gap:11px; align-content:start; }

.lead-card { background:var(--surface); border:1px solid var(--border); border-radius:10px; overflow:hidden; cursor:pointer; transition:border-color .15s,transform .15s; position:relative; }
.lead-card:hover { border-color:var(--accent); transform:translateY(-2px); }
.lead-thumb { width:100%; aspect-ratio:1; background:var(--surface2); position:relative; overflow:hidden; }
.lead-thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.lead-thumb-placeholder { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-size:26px; color:#2a2a2a; }
.type-badge { position:absolute; top:6px; right:6px; background:rgba(0,0,0,.7); color:#fff; font-size:9px; font-weight:700; padding:2px 5px; border-radius:20px; text-transform:uppercase; }
.lead-info { padding:8px 10px 5px; }
.lead-username { font-size:12px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.lead-username.no-user { color:var(--muted); font-weight:400; font-style:italic; }
.lead-date { font-size:10px; color:var(--muted); margin-top:2px; }
.lead-actions { display:flex; gap:4px; padding:0 10px 8px; }
.lead-btn { flex:1; padding:5px; border:1px solid var(--border); border-radius:5px; background:var(--surface2); color:var(--muted); font-size:10px; cursor:pointer; text-align:center; text-decoration:none; display:block; transition:all .1s; }
.lead-btn:hover { color:var(--text); border-color:#444; }
.lead-btn.del:hover { color:var(--red); border-color:var(--red); }
.lead-notes-dot { position:absolute; top:6px; left:6px; background:var(--gold); width:7px; height:7px; border-radius:50%; }

/* ── Queue ── */
.queue-list { flex:1; overflow-y:auto; padding:16px 20px; display:flex; flex-direction:column; gap:11px; }
.queue-item { background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:13px 15px; }
.queue-item.alert { border-color:rgba(231,76,60,.5); }
.queue-item.sent { opacity:.5; }
.qi-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:9px; }
.qi-meta { display:flex; align-items:center; gap:7px; }
.qi-type { font-size:10px; font-weight:700; padding:2px 7px; border-radius:20px; text-transform:uppercase; }
.qi-type.comment,.qi-type.first_comment,.qi-type.reply { background:rgba(131,58,180,.2); color:#b47fe0; }
.qi-type.dm { background:rgba(252,176,69,.15); color:var(--gold); }
.qi-type.negative { background:rgba(231,76,60,.15); color:var(--red); }
.qi-user { font-size:13px; font-weight:700; }
.qi-date { font-size:10px; color:var(--muted); }
.qi-alert-tag { font-size:10px; font-weight:800; color:var(--red); background:rgba(231,76,60,.1); border:1px solid rgba(231,76,60,.3); padding:2px 8px; border-radius:20px; }
.qi-section { margin-bottom:9px; }
.qi-label { font-size:10px; color:var(--muted); font-weight:700; text-transform:uppercase; margin-bottom:3px; }
.qi-text { font-size:12px; color:#aaa; line-height:1.5; }
.qi-reply { font-size:13px; color:var(--text); line-height:1.6; white-space:pre-wrap; }
.qi-reply.alert { color:var(--red); }
.qi-actions { display:flex; gap:6px; margin-top:11px; }
.qi-btn { padding:6px 12px; border-radius:7px; border:1px solid var(--border); background:var(--surface2); color:var(--muted); font-size:11px; font-weight:700; cursor:pointer; transition:all .12s; }
.qi-btn.send { background:var(--green); border-color:var(--green); color:#000; }
.qi-btn.send:hover { opacity:.85; }
.qi-btn:not(.send):hover { color:var(--text); border-color:#444; }
.qi-btn.del:hover { color:var(--red); border-color:var(--red); }

/* ── Modal ── */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.7); display:none; align-items:center; justify-content:center; z-index:1000; backdrop-filter:blur(4px); }
.modal-overlay.open { display:flex; }
.modal { background:var(--surface); border:1px solid var(--border); border-radius:14px; width:420px; max-width:90vw; }
.modal-header { padding:14px 17px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; font-weight:700; font-size:14px; }
.modal-close { background:none; border:none; color:var(--muted); cursor:pointer; font-size:17px; }
.modal-body { padding:17px; display:flex; flex-direction:column; gap:11px; }
.modal-link { color:var(--accent); text-decoration:none; font-size:12px; word-break:break-all; }
.modal-link:hover { text-decoration:underline; }
.modal-meta { font-size:11px; color:var(--muted); line-height:1.6; }
.modal-label { font-size:11px; font-weight:700; color:var(--muted); text-transform:uppercase; }
.modal-notes { background:var(--surface2); border:1px solid var(--border); border-radius:7px; color:var(--text); font-size:12px; padding:9px 11px; resize:vertical; min-height:70px; outline:none; font-family:inherit; }
.modal-notes:focus { border-color:var(--accent); }
.modal-save { background:linear-gradient(135deg,#833ab4,#fd1d1d); color:white; border:none; border-radius:7px; padding:10px; font-size:13px; font-weight:700; cursor:pointer; }
.modal-save:hover { opacity:.88; }

/* ── Users view ── */
.user-stat-bar { display:flex; gap:7px; flex-wrap:wrap; margin-top:5px; }
.stat-chip { font-size:11px; padding:2px 8px; border-radius:20px; background:var(--surface2); border:1px solid var(--border); color:var(--muted); }
.stat-chip.warn { background:rgba(252,176,69,.1); border-color:rgba(252,176,69,.3); color:var(--gold); }

.spam-status-bar { padding:8px 20px; background:rgba(0,0,0,.3); border-bottom:1px solid var(--border); font-size:12px; color:#aaa; flex-shrink:0; }
.incomplete-bar { display:flex; gap:10px; align-items:flex-start; padding:10px 20px; background:rgba(252,176,69,.07); border-bottom:1px solid rgba(252,176,69,.2); font-size:12px; color:#ccc; flex-shrink:0; }
.warn-link { color:var(--accent); text-decoration:none; }
.warn-link:hover { text-decoration:underline; }

.user-list { flex:1; overflow-y:auto; padding:14px 20px; display:flex; flex-direction:column; gap:10px; }

.user-card { background:var(--surface); border:1px solid var(--border); border-radius:12px; overflow:hidden; transition:border-color .15s; }
.user-card:hover { border-color:#3a3a3a; }
.user-card.has-unread { border-color:rgba(231,76,60,.5); background:rgba(231,76,60,.04); }
.user-card:has(.start-blocked) { opacity:.5; }
.lead-btn.start-ok { background:linear-gradient(135deg,#1a1a2e,#833ab4); color:#fff; border-color:transparent; }
.lead-btn.start-blocked { background:var(--surface2); color:#444; cursor:not-allowed; }

.user-card-main { display:flex; align-items:flex-start; gap:14px; padding:14px 15px 10px; }
.user-card-left { flex:1; min-width:0; }
.user-card-name { font-size:15px; font-weight:800; margin-bottom:4px; }
.user-card-meta { display:flex; gap:8px; flex-wrap:wrap; font-size:11px; color:var(--muted); margin-bottom:5px; align-items:center; }
.uc-camp { font-weight:700; font-size:11px; }
.uc-camp.missing { color:#555; font-style:italic; }
.u-type { background:var(--surface2); border:1px solid var(--border); border-radius:20px; padding:1px 6px; font-size:10px; text-transform:uppercase; }
.user-reasons { font-size:11px; color:#777; }
.u-badge { font-size:10px; font-weight:700; padding:2px 8px; border-radius:20px; }
.u-badge.urgent { background:rgba(231,76,60,.15); color:var(--red); }
.u-badge.muted  { background:var(--surface2); color:var(--muted); border:1px solid var(--border); }
.u-badge.warn   { background:rgba(252,176,69,.1); color:var(--gold); }

.user-score-col { display:flex; flex-direction:column; align-items:center; gap:3px; flex-shrink:0; width:64px; }
.score-num { font-size:22px; font-weight:900; line-height:1; }
.score-lbl { font-size:10px; color:var(--muted); }
.score-bar { width:100%; height:3px; background:#2a2a2a; border-radius:2px; overflow:hidden; }
.score-fill { height:100%; border-radius:2px; transition:width .4s; }

.user-card-actions { display:flex; gap:6px; padding:0 15px 12px; }

/* ── Rules view ── */
.rules-container { flex:1; overflow-y:auto; padding:16px 20px; display:flex; flex-direction:column; gap:20px; }
.rules-section { background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:16px; }
.rules-section-title { font-size:13px; font-weight:800; margin-bottom:4px; }
.rules-section-sub { font-size:11px; color:var(--muted); margin-bottom:14px; line-height:1.5; }

.asp-table { display:flex; flex-direction:column; gap:6px; margin-bottom:14px; }
.asp-row { display:flex; align-items:center; gap:8px; font-size:12px; padding:7px 10px; background:var(--surface2); border-radius:7px; }
.asp-label { flex:1; color:#aaa; }
.asp-cur { font-weight:700; min-width:38px; text-align:right; }
.asp-cur.over { color:var(--red); }
.asp-arrow { color:#444; }
.asp-rec { color:var(--muted); font-size:11px; min-width:100px; }
.asp-action { min-width:50px; text-align:right; }
.asp-apply { font-size:10px; font-weight:700; padding:3px 9px; border-radius:5px; border:1px solid var(--accent); background:transparent; color:var(--accent); cursor:pointer; }
.asp-apply:hover { background:var(--accent); color:#fff; }
.asp-ok { color:var(--green); font-size:14px; }
.asp-tips { display:flex; flex-direction:column; gap:6px; }
.asp-tip { font-size:11px; color:#666; line-height:1.5; padding:7px 10px; background:rgba(131,58,180,.05); border-left:2px solid #833ab440; border-radius:0 5px 5px 0; }

.rule-item { display:flex; align-items:flex-start; gap:10px; padding:10px 12px; border-radius:8px; border:1px solid var(--border); margin-bottom:6px; background:var(--surface2); transition:opacity .15s; }
.rule-item.inactive { opacity:.4; }
.rule-num { width:20px; text-align:right; font-size:11px; color:#555; font-weight:700; padding-top:2px; flex-shrink:0; }
.rule-toggle-wrap { position:relative; display:inline-block; width:28px; height:16px; flex-shrink:0; margin-top:2px; }
.rule-check { opacity:0; width:0; height:0; }
.rule-toggle-track { position:absolute; inset:0; background:#333; border-radius:16px; cursor:pointer; transition:background .2s; }
.rule-check:checked + .rule-toggle-track { background:var(--accent); }
.rule-toggle-track::after { content:''; position:absolute; top:2px; left:2px; width:12px; height:12px; background:#fff; border-radius:50%; transition:transform .2s; }
.rule-check:checked + .rule-toggle-track::after { transform:translateX(12px); }
.rule-body { flex:1; min-width:0; }
.rule-text { font-size:12px; color:#ccc; line-height:1.6; }
.rule-edit-ta { width:100%; background:var(--surface); border:1px solid var(--accent); border-radius:5px; color:var(--text); font-size:12px; padding:5px 8px; resize:vertical; min-height:50px; font-family:inherit; outline:none; }
.rule-btns { display:flex; gap:2px; flex-shrink:0; }
.rules-add-btn { width:100%; padding:8px; margin-top:6px; border:1px dashed #333; border-radius:7px; background:transparent; color:var(--muted); font-size:12px; font-weight:700; cursor:pointer; transition:all .15s; }
.rules-add-btn:hover { border-color:var(--accent); color:var(--accent); }

/* ── Campaign cards ── */
.campaign-list { flex:1; overflow-y:auto; padding:16px 20px; display:flex; flex-direction:column; gap:11px; }
.campaign-card { background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:15px; display:flex; gap:14px; align-items:flex-start; }
.campaign-icon { width:44px; height:44px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:22px; flex-shrink:0; }
.campaign-body { flex:1; min-width:0; }
.campaign-name { font-size:15px; font-weight:800; margin-bottom:4px; }
.campaign-desc { font-size:12px; color:var(--muted); margin-bottom:8px; }
.campaign-section { font-size:11px; color:#888; line-height:1.5; margin-bottom:6px; }
.campaign-label { font-weight:700; color:var(--muted); text-transform:uppercase; font-size:10px; }
.campaign-meta { font-size:10px; color:#555; margin-top:6px; }
.campaign-actions { display:flex; flex-direction:column; gap:5px; flex-shrink:0; }

/* Lead campaign indicators */
.lead-campaign-dot { position:absolute; top:6px; left:6px; width:8px; height:8px; border-radius:50%; border:1.5px solid rgba(0,0,0,.4); }
.lead-camp-tag { font-size:10px; margin-top:2px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ── Bulk assign modal ── */
.bulk-radio-row { display:flex; align-items:center; gap:8px; font-size:12px; color:#aaa; cursor:pointer; padding:6px 10px; border-radius:6px; border:1px solid var(--border); background:var(--surface2); }
.bulk-radio-row input { accent-color:var(--accent); }
.bulk-preview { font-size:12px; color:var(--gold); padding:8px 0 4px; font-weight:700; }

/* ── Empty states ── */
.empty-state { text-align:center; padding:60px 20px; color:var(--muted); grid-column:1/-1; }
.empty-icon { font-size:40px; margin-bottom:12px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width:5px; } ::-webkit-scrollbar-track { background:transparent; } ::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }

/* ── Algoritma View ── */
.algo-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; padding:20px; align-content:start; }
.algo-card { background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:16px; }
.algo-card-wide { grid-column:1/-1; }
.algo-card-title { font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); margin-bottom:12px; }
.algo-loading { font-size:12px; color:var(--muted); padding:8px 0; }

/* Score params */
.algo-param-row { display:flex; align-items:center; gap:8px; margin-bottom:7px; }
.algo-param-label { font-size:11px; color:#bbb; width:110px; flex-shrink:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.algo-bar-wrap { flex:1; height:6px; background:var(--surface2); border-radius:3px; overflow:hidden; }
.algo-bar { height:100%; background:var(--accent); border-radius:3px; transition:width .4s; }
.algo-param-val { font-size:10px; color:var(--muted); width:60px; text-align:right; flex-shrink:0; }

.algo-score-line { margin-top:10px; padding-top:10px; border-top:1px solid var(--border); font-size:13px; color:#ccc; }
.algo-decision-inline { font-weight:700; }
.algo-decision-inline.ready { color:var(--green); }
.algo-decision-inline.wait { color:var(--gold); }

.algo-decision { padding:10px 14px; border-radius:8px; font-size:13px; font-weight:700; }
.algo-decision.veto { background:rgba(231,76,60,.1); border:1px solid rgba(231,76,60,.3); color:var(--red); }

.algo-meta { font-size:11px; color:var(--muted); margin-top:8px; }
.algo-small-btn { margin-top:10px; font-size:11px; padding:4px 10px; background:var(--surface2); border:1px solid var(--border); border-radius:5px; color:#aaa; cursor:pointer; }
.algo-small-btn:hover { border-color:var(--accent); color:var(--text); }

/* Ratio rows */
.algo-ratio-row { display:flex; align-items:center; justify-content:space-between; padding:6px 0; border-bottom:1px solid var(--border); font-size:12px; color:#ccc; }
.algo-ratio-row:last-of-type { border-bottom:none; }
.algo-ratio-val { font-weight:700; }
.algo-ratio-val.ok { color:var(--green); }
.algo-ratio-val.warn { color:var(--red); }
.algo-ratio-val.muted { color:var(--muted); font-weight:normal; }
.algo-ratio-target { font-size:10px; font-weight:normal; color:var(--muted); }

/* Warmup */
.algo-warmup-ok { font-size:13px; font-weight:700; color:var(--green); margin-bottom:12px; }
.algo-warmup-active { font-size:13px; font-weight:700; color:var(--gold); margin-bottom:12px; }
.algo-warmup-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.algo-wlabel { font-size:10px; color:var(--muted); display:block; }
.algo-wval { font-size:13px; font-weight:700; color:#ddd; }

/* Anomaly rows */
.anomaly-row { display:grid; grid-template-columns:80px 1fr 1fr auto; gap:8px; align-items:center; padding:6px 0; border-bottom:1px solid var(--border); font-size:11px; }
.anomaly-row:last-child { border-bottom:none; }
.anomaly-time { color:var(--muted); }
.anomaly-key { font-weight:700; color:#ccc; }
.anomaly-val { color:#bbb; }
.anomaly-action { font-size:10px; padding:2px 6px; border-radius:4px; }
.anomaly-info .anomaly-action { background:rgba(131,58,180,.15); color:#b39ddb; }
.anomaly-warn .anomaly-action { background:rgba(252,176,69,.1); color:var(--gold); }
.anomaly-crit .anomaly-action { background:rgba(231,76,60,.1); color:var(--red); }

/* ── Mobile chrome (always defined, shown only on mobile) ── */
.mobile-topbar {
  display:none;
  position:fixed; top:0; left:0; right:0;
  height:52px; background:var(--surface);
  border-bottom:1px solid var(--border);
  align-items:center; justify-content:space-between;
  padding:0 16px; z-index:98;
}
.hamburger {
  background:none; border:none; color:var(--text);
  font-size:22px; cursor:pointer;
  width:40px; height:40px;
  display:flex; align-items:center; justify-content:center;
  border-radius:7px;
}
.hamburger:active { background:var(--surface2); }
.mobile-logo {
  font-size:16px; font-weight:800;
  background:linear-gradient(135deg,#833ab4,#fd1d1d,#fcb045);
  -webkit-background-clip:text; -webkit-text-fill-color:transparent;
}
.sidebar-overlay {
  display:none; position:fixed; inset:0;
  background:rgba(0,0,0,.65); z-index:99;
}
.sidebar-overlay.active { display:block; }
.mobile-back-btn {
  display:none; align-items:center; gap:6px;
  background:none; border:none; color:var(--accent);
  font-size:13px; font-weight:700; cursor:pointer;
  padding:0 0 10px; width:100%;
}

/* ── Mobile breakpoint ── */
@media (max-width:768px) {
  /* Keep body as fixed viewport — just add topbar padding */
  body { padding-top:52px; }
  .mobile-topbar { display:flex; }

  /* Sidebar: off-canvas drawer (removed from flex flow via fixed positioning) */
  .sidebar {
    position:fixed;
    top:0; left:0; bottom:0;
    width:260px;
    transform:translateX(-260px);
    transition:transform .25s cubic-bezier(.4,0,.2,1);
    z-index:100;
    overflow-y:auto;
  }
  .sidebar.open { transform:translateX(0); }

  /* Main: fills full width automatically (sidebar out of flow) */
  .main { min-width:0; }

  /* Thread split view: stack vertically */
  .split-view { flex-direction:column !important; }
  .thread-list {
    width:100% !important; border-right:none;
    border-bottom:1px solid var(--border);
    max-height:40vh; flex-shrink:0;
  }
  .thread-detail { flex:1; overflow-y:auto; }

  /* Mobile thread navigation */
  .split-view.mobile-detail-open .thread-list { display:none; }
  .split-view.mobile-detail-open .thread-detail { flex:1; }
  .mobile-back-btn { display:flex; }

  /* Touch targets */
  .nav-btn { padding:12px 11px; font-size:14px; min-height:44px; }
  .thread-item { padding:15px 16px; }
  .action-btn { padding:11px 14px; min-height:44px; }

  /* Lead grid: single column */
  .lead-grid { grid-template-columns:1fr !important; }

  /* Topbar wraps on small screens */
  .topbar { flex-wrap:wrap; padding:12px 14px 10px; gap:8px; }
  .topbar h1 { font-size:18px; }
  .topbar-sub { flex-wrap:wrap; gap:6px; }
  .search-input { width:100%; min-width:0; }
  .filter-buttons { flex-wrap:wrap; }

  /* Algo grid: single column */
  .algo-grid { grid-template-columns:1fr !important; padding:12px; }

  /* Modals */
  .modal { max-width:96vw !important; max-height:88vh; overflow-y:auto; }

  /* Sidebar config inputs */
  .config-row { gap:4px; }
}
