:root {
  --bg: #0b0e14;
  --bg-1: #11151f;
  --bg-2: #161b27;
  --bg-3: #1d2433;
  --line: #232b3a;
  --line-soft: #1b2230;
  --txt: #e7ecf3;
  --txt-dim: #9aa6b8;
  --txt-mut: #6b7689;
  --brand: #ef4444;
  --brand-2: #b91c1c;
  --brand-soft: rgba(239, 68, 68, 0.16);
  --accent: #2dd4bf;
  --slate: #93a4bd;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --urgent: #fb923c;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a3344; border-radius: 8px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-track { background: transparent; }

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, #0d1018, #0b0e14);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 22px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; letter-spacing: 0.5px;
  color: #fff;
  background: var(--brand);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.3);
}
.brand-text { display: flex; flex-direction: column; }
.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; color: var(--txt-mut); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer;
  color: var(--txt-dim);
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg-2); color: var(--txt); }
.nav-item.active { background: var(--bg-3); color: #fff; }
.nav-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--txt-mut);
}
.nav-item.active .nav-dot { background: var(--brand); box-shadow: 0 0 8px var(--brand); }

.sys-card {
  margin-top: auto;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.sys-card-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--txt-mut); margin-bottom: 10px; }
.sys-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 12.5px; color: var(--txt-dim); }
.pill {
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-3); color: var(--txt-dim);
}
.pill.ok { background: rgba(52, 211, 153, 0.15); color: var(--good); }
.pill.bad { background: rgba(248, 113, 113, 0.15); color: var(--bad); }
.pill.info { background: var(--brand-soft); color: #ff9b9b; }

.sidebar-foot { font-size: 11px; color: var(--txt-mut); text-align: center; font-family: var(--mono); }

/* ---------- Main ---------- */
.main {
  overflow-y: auto;
  padding: 22px 26px 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.topbar-sub { margin: 4px 0 0; color: var(--txt-dim); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px; height: 40px;
  color: var(--txt-mut);
}
.search-box input {
  background: none; border: none; outline: none;
  color: var(--txt); font-size: 13px; width: 200px;
}
.search-box:focus-within { border-color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--bg-2); color: var(--txt);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg-3); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--brand);
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.28);
}
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: none; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12px; }

/* ---------- KPI cards ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}
.kpi {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent-bar, var(--brand));
  opacity: 0.8;
}
.kpi-label { font-size: 11.5px; color: var(--txt-mut); text-transform: uppercase; letter-spacing: 0.6px; }
.kpi-value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -0.5px; }
.kpi-sub { font-size: 11.5px; color: var(--txt-dim); margin-top: 2px; }

/* ---------- Pipeline funnel ---------- */
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.hint { font-size: 12px; color: var(--txt-mut); }

.pipeline {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.funnel { display: flex; gap: 10px; flex-wrap: wrap; }
.stage {
  flex: 1 1 0; min-width: 110px;
  background: var(--bg-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.08s;
}
.stage:hover { border-color: var(--brand); transform: translateY(-2px); }
.stage.active { border-color: var(--brand); background: var(--bg-3); }
.stage-name { font-size: 11.5px; color: var(--txt-dim); text-transform: capitalize; }
.stage-count { font-size: 24px; font-weight: 800; margin-top: 4px; }
.stage-bar { height: 4px; border-radius: 4px; margin-top: 8px; background: var(--bg-3); overflow: hidden; }
.stage-bar > i { display: block; height: 100%; border-radius: 4px; background: var(--brand); }

/* ---------- Workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: 360px 1fr 320px;
  gap: 16px;
  align-items: start;
}
.col { min-width: 0; }
.col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.col-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.count-chip {
  font-size: 12px; font-weight: 600; color: var(--txt-dim);
  background: var(--bg-2); padding: 2px 10px; border-radius: 999px;
}
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--good); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.select {
  background: var(--bg-1); color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 12.5px; cursor: pointer; outline: none;
}
.select:focus { border-color: var(--brand); }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--txt-dim); cursor: pointer; }
.chk input { accent-color: var(--brand); }

/* List */
.opp-list { display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 360px); overflow-y: auto; padding-right: 4px; }
.opp-card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  display: flex; gap: 12px;
  transition: border-color 0.15s, transform 0.08s, background 0.15s;
}
.opp-card:hover { border-color: #324063; transform: translateY(-1px); }
.opp-card.active { border-color: var(--brand); background: var(--bg-2); box-shadow: var(--shadow-sm); }
.opp-card.urgent { border-left: 3px solid var(--urgent); }
.opp-main { flex: 1; min-width: 0; }
.opp-title { font-weight: 600; font-size: 13.5px; line-height: 1.35; margin-bottom: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.opp-meta { font-size: 11.5px; color: var(--txt-mut); margin-bottom: 8px; }
.opp-badges { display: flex; flex-wrap: wrap; gap: 5px; }

/* Score ring */
.ring {
  --val: 0;
  --col: var(--brand);
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--col) calc(var(--val) * 1%), var(--bg-3) 0);
  position: relative;
}
.ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--bg-1); }
.opp-card.active .ring::before { background: var(--bg-2); }
.ring span { position: relative; font-size: 13px; font-weight: 700; font-family: var(--mono); }
.ring.lg { width: 72px; height: 72px; flex-basis: 72px; }
.ring.lg::before { inset: 6px; }
.ring.lg span { font-size: 20px; }

/* Badges */
.badge {
  font-size: 10.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
  background: var(--bg-3); color: var(--txt-dim);
  text-transform: capitalize; white-space: nowrap;
}
.badge.bid { background: rgba(52, 211, 153, 0.16); color: var(--good); }
.badge.review { background: rgba(251, 191, 36, 0.16); color: var(--warn); }
.badge.no_bid { background: rgba(248, 113, 113, 0.16); color: var(--bad); }
.badge.urgent { background: rgba(251, 146, 60, 0.18); color: var(--urgent); }
.badge.domain { background: rgba(147, 164, 189, 0.16); color: var(--slate); }
.badge.status { background: rgba(45, 212, 191, 0.14); color: var(--accent); }

/* ---------- Detail ---------- */
.detail-empty {
  background: var(--bg-1); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 60px 30px;
  text-align: center; color: var(--txt-mut);
}
.empty-glyph { font-size: 42px; opacity: 0.4; margin-bottom: 12px; }

.detail {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.detail-hero { padding: 20px; border-bottom: 1px solid var(--line); display: flex; gap: 18px; }
.detail-hero h3 { margin: 0 0 6px; font-size: 17px; line-height: 1.3; }
.detail-hero .opp-meta { font-size: 12.5px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--bg-1); }
.tab {
  background: none; border: none; cursor: pointer;
  color: var(--txt-dim); font-size: 13px; font-weight: 600;
  padding: 12px 14px; border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--txt); }
.tab.active { color: #fff; border-bottom-color: var(--brand); }

.tab-body { padding: 20px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--txt-mut); margin-bottom: 5px; }
.field p { margin: 0; line-height: 1.55; color: var(--txt); }
.field a { color: var(--accent); text-decoration: none; }
.field a:hover { text-decoration: underline; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11.5px; padding: 4px 10px; border-radius: 999px; background: var(--bg-3); color: var(--txt-dim); }

/* Confidence meter */
.meter { background: var(--bg-3); border-radius: 999px; height: 8px; overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-row .meter { flex: 1; }
.meter-val { font-family: var(--mono); font-size: 12px; color: var(--txt-dim); min-width: 38px; text-align: right; }

/* Score breakdown bars */
.factors { display: flex; flex-direction: column; gap: 12px; }
.factor { display: grid; grid-template-columns: 150px 1fr 36px; align-items: center; gap: 10px; }
.factor-name { font-size: 12.5px; color: var(--txt-dim); }
.factor-track { background: var(--bg-3); height: 8px; border-radius: 999px; overflow: hidden; }
.factor-track > i { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.factor-val { font-family: var(--mono); font-size: 12px; color: var(--txt); text-align: right; }

/* Agent trace timeline */
.trace { list-style: none; margin: 0; padding: 0; position: relative; }
.trace::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.trace li { position: relative; padding: 0 0 14px 26px; }
.trace li::before {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--bg-1);
}
.trace li.err::before { background: var(--bad); }
.trace-step { font-family: var(--mono); font-size: 12px; color: var(--txt); }
.trace-step b { color: var(--accent); }

/* Actions */
.actions { padding: 18px 20px; border-top: 1px solid var(--line); background: var(--bg-1); display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--txt-mut); margin-bottom: 5px; }
.actions input, .actions textarea, .actions select {
  width: 100%; background: var(--bg-2); color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 13px; outline: none; font-family: inherit;
}
.actions textarea { resize: vertical; min-height: 60px; }
.actions input:focus, .actions textarea:focus, .actions select:focus { border-color: var(--brand); }
.actions .full { grid-column: 1 / -1; }
.save-row { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; }
.saved-flag { font-size: 12px; color: var(--good); opacity: 0; transition: opacity 0.2s; }
.saved-flag.show { opacity: 1; }

/* ---------- Activity feed ---------- */
.activity-feed { display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 300px); overflow-y: auto; padding-right: 4px; }
.act {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
  transition: border-color 0.15s;
}
.act:hover { border-color: #324063; }
.act-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.act-agent { font-size: 11px; font-weight: 600; color: var(--accent); font-family: var(--mono); }
.act-time { margin-left: auto; font-size: 10.5px; color: var(--txt-mut); }
.act-title { font-size: 12.5px; line-height: 1.4; margin-bottom: 8px; color: var(--txt); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.act-foot { display: flex; align-items: center; gap: 6px; }
.act-conf { margin-left: auto; font-size: 10.5px; color: var(--txt-mut); font-family: var(--mono); }

.empty { color: var(--txt-mut); font-size: 13px; padding: 24px; text-align: center; }

/* ---------- Application tab ---------- */
.badge.app-auto { background: rgba(52, 211, 153, 0.16); color: var(--good); }
.badge.app-human { background: rgba(251, 146, 60, 0.18); color: var(--urgent); }
.badge.app-ineligible { background: rgba(147, 164, 189, 0.16); color: var(--slate); }
.badge.app-unknown { background: var(--bg-3); color: var(--txt-mut); }

.app-empty { text-align: center; padding: 18px 8px; }
.app-empty p { color: var(--txt-dim); line-height: 1.55; margin: 0 0 14px; }
.app-note { font-size: 11.5px; color: var(--txt-mut); margin-top: 14px !important; }

.app-class {
  border: 1px solid var(--line);
  border-left: 3px solid var(--txt-mut);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.app-class.app-auto { border-left-color: var(--good); }
.app-class.app-human { border-left-color: var(--urgent); }
.app-class.app-ineligible { border-left-color: var(--slate); }
.app-class-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.app-class-label { font-weight: 700; font-size: 14px; }
.app-effort {
  font-size: 11px; font-family: var(--mono); color: var(--txt-dim);
  background: var(--bg-3); padding: 2px 8px; border-radius: 999px;
}
.app-reason { margin: 8px 0 0; font-size: 12.5px; color: var(--txt-dim); line-height: 1.5; }

.checklist, .disq, .doc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.checklist li {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px;
  padding: 8px 10px; background: var(--bg-2);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm); font-size: 13px;
}
.checklist .check { color: var(--txt-mut); font-weight: 700; }
.checklist li.done .check { color: var(--good); }
.checklist li.done .check-label { color: var(--txt-dim); }
.check-cat { font-size: 10.5px; color: var(--txt-mut); text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }

.disq li {
  padding: 7px 10px 7px 26px; position: relative; font-size: 12.5px; color: var(--txt-dim);
  background: rgba(248, 113, 113, 0.08); border-radius: var(--radius-sm);
}
.disq li::before { content: "!"; position: absolute; left: 10px; color: var(--brand); font-weight: 700; }

.doc-list li {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 9px 12px; background: var(--bg-2);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
}
.doc-kind {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700;
  padding: 3px 7px; border-radius: 6px; background: var(--bg-3); color: var(--txt-mut);
}
.doc-src .doc-kind { background: rgba(45, 212, 191, 0.14); color: var(--accent); }
.doc-gen .doc-kind { background: var(--brand-soft); color: #ff9b9b; }
.doc-name { font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-name a { color: var(--accent); text-decoration: none; }
.doc-name a:hover { text-decoration: underline; }
.doc-meta { font-size: 10.5px; color: var(--txt-mut); font-family: var(--mono); white-space: nowrap; }

/* ---------- Favorites star ---------- */
.fav {
  background: none; border: none; cursor: pointer; align-self: flex-start;
  font-size: 18px; line-height: 1; color: var(--txt-mut); padding: 2px 4px;
  transition: color 0.15s, transform 0.1s;
}
.fav:hover { color: var(--warn); transform: scale(1.15); }
.fav.on { color: var(--warn); }
.opp-card { position: relative; }

/* ---------- Contact card ---------- */
.contact-card {
  background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px;
}
.contact-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.contact-avatar {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%;
  background: var(--brand-soft); border: 1.5px solid var(--brand);
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #ff9b9b; letter-spacing: 0.5px;
}
.contact-meta { display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.contact-name { font-weight: 600; color: var(--txt); }
.contact-title { font-size: 12px; color: var(--txt-dim); }
.contact-office { font-size: 11.5px; color: var(--txt-mut); }
.contact-actions { display: flex; flex-direction: column; gap: 8px; }
.contact-email-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 10px; background: var(--bg-3); border-radius: var(--radius-sm);
}
.contact-email-addr {
  flex: 1; font-size: 12px; color: var(--accent); font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.contact-email-btns { display: flex; gap: 6px; flex-shrink: 0; }
.contact-phone-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; background: var(--bg-3); border-radius: var(--radius-sm);
}
.contact-phone-link {
  flex: 1; font-size: 13px; font-weight: 600; color: var(--good);
  text-decoration: none; font-family: var(--mono); letter-spacing: 0.5px;
}
.contact-phone-link:hover { text-decoration: underline; }
.btn-gmail { background: #1a4a2e; border-color: #1e5e38; color: #6ee7b7; }
.btn-gmail:hover { background: #1e5e38; }
.copy-toast {
  font-size: 11px; color: var(--good); font-weight: 600; opacity: 0;
  transition: opacity 0.2s; pointer-events: none; white-space: nowrap;
}
.copy-toast.show { opacity: 1; }
.muted { color: var(--txt-mut); }
.doc-dl { color: var(--txt-mut); text-decoration: none; font-weight: 700; }
.doc-dl:hover { color: var(--accent); }

/* Search result contact mini-card */
.result-contact-card {
  margin-top: 8px; padding: 8px 10px;
  background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm); font-size: 12px;
}
.rc-name { font-weight: 600; color: var(--txt-dim); display: block; margin-bottom: 6px; }
.rc-title { font-weight: 400; color: var(--txt-mut); }
.rc-actions { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }

/* ---------- Trigger Search view ---------- */
.search-view { display: none; flex-direction: column; gap: 18px; }
.search-grid { display: grid; grid-template-columns: 380px 1fr; gap: 18px; }
.search-form, .search-console, .search-results {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.sf-field { margin-bottom: 14px; }
.sf-field > label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--txt-mut); margin-bottom: 6px; }
.sf-hint { text-transform: none; letter-spacing: 0; color: var(--txt-mut); font-weight: 400; }
.search-form textarea, .search-form input[type="text"], .search-form input[type="number"] {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--txt); padding: 9px 11px; font: inherit; font-size: 13px;
}
.search-form textarea:focus, .search-form input:focus { outline: none; border-color: var(--brand); }
.sf-toggles { display: flex; flex-wrap: wrap; gap: 14px; }
.sf-row { display: flex; gap: 14px; margin-top: 10px; }
.sf-inline { font-size: 12px; color: var(--txt-dim); display: flex; flex-direction: column; gap: 4px; }
.sf-inline input { width: 90px; }
.sf-actions { display: flex; gap: 10px; margin-top: 6px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--txt-dim); cursor: pointer; }

.console-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.console-head h2 { font-size: 14px; }
.run-status { font-size: 12px; color: var(--txt-dim); font-family: var(--mono); }
.console-log {
  height: 360px; overflow-y: auto; background: var(--bg-1);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 10px;
  font-family: var(--mono); font-size: 12px;
}
.log-row { display: grid; grid-template-columns: 64px 78px 1fr; gap: 8px; padding: 3px 4px; border-left: 2px solid transparent; }
.log-time { color: var(--txt-mut); }
.log-type { color: var(--txt-dim); text-transform: uppercase; font-size: 10px; }
.log-msg { color: var(--txt); }
.log-row.lvl-ok { border-left-color: var(--good); }
.log-row.lvl-ok .log-type { color: var(--good); }
.log-row.lvl-warn { border-left-color: var(--warn); }
.log-row.lvl-warn .log-type { color: var(--warn); }
.log-row.lvl-err { border-left-color: var(--brand); background: rgba(239,68,68,0.06); }
.log-row.lvl-err .log-type { color: var(--brand); }

.results-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; margin-top: 12px; }
.result-card { display: flex; gap: 12px; align-items: flex-start; background: var(--bg-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 12px; }
.result-score { font-family: var(--mono); font-weight: 700; font-size: 16px; color: var(--brand); min-width: 28px; }
.result-main { flex: 1; min-width: 0; }
.result-title { font-weight: 600; font-size: 13.5px; line-height: 1.4; }
.result-meta { font-size: 12px; color: var(--txt-dim); margin: 2px 0 6px; }
.result-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.result-contact { font-size: 11.5px; color: var(--txt-dim); margin-top: 6px; font-family: var(--mono); }
.result-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

/* ---------- Floating live run console ---------- */
.run-toast {
  position: fixed; right: 22px; bottom: 22px; width: 400px; max-width: calc(100vw - 44px);
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0,0,0,0.5); z-index: 90; overflow: hidden;
}
.run-toast[hidden] { display: none; }
.run-toast-head {
  display: flex; align-items: center; gap: 9px; padding: 11px 14px;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.run-toast-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); flex: none; animation: pulse 1.1s infinite; }
.run-toast.done .run-toast-dot { background: var(--good); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }
.run-toast-status { flex: 1; font-size: 12.5px; color: var(--txt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-toast-close { background: none; border: none; color: var(--txt-mut); font-size: 18px; line-height: 1; cursor: pointer; }
.run-toast-close:hover { color: var(--txt); }
.run-toast-log { max-height: 230px; overflow-y: auto; padding: 8px 10px; font-family: var(--mono); font-size: 11.5px; }
.rt-row { display: grid; grid-template-columns: 60px 1fr; gap: 8px; padding: 2px 2px; border-left: 2px solid transparent; }
.rt-time { color: var(--txt-mut); }
.rt-msg { color: var(--txt-dim); }
.rt-row.lvl-ok { border-left-color: var(--good); }
.rt-row.lvl-ok .rt-msg { color: var(--txt); }
.rt-row.lvl-warn { border-left-color: var(--warn); }
.rt-row.lvl-err { border-left-color: var(--brand); }
.rt-row.lvl-err .rt-msg { color: #ff9b9b; }

/* ---------- Auth overlay ---------- */
.auth-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-overlay[hidden] { display: none; }
.auth-modal {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--radius); width: 420px; max-width: 100%;
  box-shadow: 0 32px 90px rgba(0,0,0,0.6);
  overflow: hidden;
}
.auth-header {
  padding: 32px 36px 24px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.auth-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--brand); color: #fff;
  font-size: 18px; font-weight: 800; letter-spacing: 0.5px;
  display: grid; place-items: center; margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(239,68,68,0.35);
}
.auth-header h2 { margin: 0 0 6px; font-size: 22px; }
.auth-header p { margin: 0; font-size: 13px; color: var(--txt-dim); line-height: 1.5; }
.auth-form { padding: 28px 36px 32px; }
.auth-field { margin-bottom: 14px; }
.auth-field label {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--txt-mut); margin-bottom: 6px;
}
.auth-field input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--txt);
  padding: 11px 14px; font-size: 14px; font-family: inherit; outline: none;
  transition: border-color 0.15s;
}
.auth-field input:focus { border-color: var(--brand); }
.auth-hint { font-size: 10px; text-transform: none; letter-spacing: 0; color: var(--txt-mut); font-weight: 400; }
.auth-submit { width: 100%; height: 46px; font-size: 15px; margin-top: 4px; justify-content: center; }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; flex-wrap: wrap; gap: 6px; }
.auth-link {
  background: none; border: none; cursor: pointer;
  color: var(--accent); font-size: 13px; padding: 0;
  text-decoration: underline; text-underline-offset: 2px;
}
.auth-link:hover { color: var(--txt); }
.auth-error {
  background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-sm); color: var(--bad);
  padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
}

/* User bar at bottom of sidebar */
.user-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; margin-top: 8px;
  background: var(--bg-2); border-radius: var(--radius-sm);
  border: 1px solid var(--line-soft);
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--brand-soft); border: 1.5px solid var(--brand);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #ff9b9b;
}
.user-name {
  flex: 1; font-size: 12.5px; font-weight: 500; color: var(--txt-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Email verified banner */
.verified-banner {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(52,211,153,0.15); border: 1px solid var(--good);
  color: var(--good); padding: 10px 24px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; z-index: 300;
}
.verified-banner[hidden] { display: none; }

/* ---------- File viewer ---------- */
.viewer-overlay {
  position: fixed; inset: 0; background: rgba(5,8,14,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 32px; backdrop-filter: blur(4px);
}
.viewer-overlay[hidden] { display: none; }
.viewer-modal {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius);
  width: min(980px, 100%); height: min(88vh, 920px);
  display: flex; flex-direction: column;
  box-shadow: 0 32px 90px rgba(0,0,0,0.6);
  transition: width 0.2s, height 0.2s, border-radius 0.2s;
}
.viewer-overlay.viewer-fullscreen { padding: 0; }
.viewer-overlay.viewer-fullscreen .viewer-modal {
  width: 100%; height: 100%; border-radius: 0; border: none;
}
.viewer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  gap: 12px; flex-shrink: 0;
}
.viewer-title {
  font-weight: 600; font-size: 13.5px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0;
}
.viewer-actions { display: flex; gap: 6px; flex-shrink: 0; }
.viewer-body { flex: 1; overflow: auto; background: var(--bg-2); min-height: 0; }
.viewer-frame { width: 100%; height: 100%; border: none; background: #fff; display: block; }
.viewer-html { background: var(--bg-2); }
.viewer-doc { padding: 28px 34px; max-width: 800px; margin: 0 auto; line-height: 1.7; color: var(--txt); }
.viewer-doc h1, .viewer-doc h2, .viewer-doc h3, .viewer-doc h4 { margin: 18px 0 8px; color: var(--txt); }
.viewer-pre { background: var(--bg-1); padding: 14px; border-radius: var(--radius-sm); overflow: auto; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }
.viewer-doc code { background: var(--bg-1); padding: 1px 5px; border-radius: 5px; font-family: var(--mono); }
.viewer-doc a { color: var(--accent); }
.viewer-msg { padding: 40px; text-align: center; color: var(--txt-dim); }
.viewer-msg .btn { margin-top: 14px; }
.viewer-loading {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  height: 100%; color: var(--txt-dim); font-size: 13px;
}
.viewer-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- View toggles ---------- */
body[data-view="pipeline"] .col-activity,
body[data-view="pipeline"] .kpis { display: none; }
body[data-view="activity"] .pipeline,
body[data-view="activity"] .col-list,
body[data-view="activity"] .col-detail { display: none; }
body[data-view="activity"] .workspace { grid-template-columns: 1fr; }
body[data-view="activity"] .activity-feed { max-height: none; }
body[data-view="search"] .kpis,
body[data-view="search"] .pipeline,
body[data-view="search"] .workspace { display: none; }
body[data-view="search"] .search-view { display: flex; }

/* ---------- Responsive ---------- */
@media (max-width: 1400px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .workspace { grid-template-columns: 320px 1fr; }
  .col-activity { grid-column: 1 / -1; }
  .activity-feed { max-height: 360px; flex-direction: row; flex-wrap: wrap; }
  .act { flex: 1 1 280px; }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
