:root {
  --bg: #f0f2f5; --sidebar: #0f1923; --card: #fff; --border: #e2e8f0; --light: #f8fafc;
  --accent: #0ea5e9; --accent-dark: #0284c7; --green: #10b981; --amber: #f59e0b; --violet: #8b5cf6;
  --red: #ef4444; --text: #0f172a; --muted: #64748b;
  --mono: 'JetBrains Mono', monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Outfit', sans-serif; background: var(--bg); color: var(--text); height: 100vh; display: flex; flex-direction: column; overflow: hidden; font-size: 13px; }
button, select, input, textarea { font-family: inherit; font-size: inherit; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 11px; }

/* top bar */
.topbar { background: var(--sidebar); height: 52px; display: flex; align-items: center; padding: 0 20px; gap: 16px; flex-shrink: 0; }
.logo { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: -0.5px; }
.logo span { color: var(--accent); }
.pilot-badge { font-size: 11px; font-weight: 600; color: rgba(255,255,255,.6); background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); padding: 4px 12px; border-radius: 20px; white-space: nowrap;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; }  /* gives way so the tabs and Sign out fit */
.nav-tabs { display: flex; gap: 2px; flex: 1; }
.nav-tab { background: none; border: 0; color: rgba(255,255,255,.5); padding: 7px 12px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; }
.nav-tab:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-tab[hidden] { display: none; }
.nav-tab.active { color: #fff; background: rgba(14,165,233,.2); }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.count { font-size: 9px; font-weight: 700; background: var(--red); color: #fff; border-radius: 8px; padding: 1px 6px; }
.user-menu { display: flex; gap: 8px; align-items: center; color: #fff; font-size: 12px; white-space: nowrap; }
.user-menu .who { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.user-menu .who span { color: rgba(255,255,255,.5); font-size: 10px; }
.user-menu button { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); color: rgba(255,255,255,.8); border-radius: 6px; padding: 4px 9px; cursor: pointer; font-size: 11px; }
.user-menu button:hover { color: #fff; border-color: var(--accent); }

.view { display: none; flex: 1; overflow: hidden; }
.view.active { display: flex; }

/* buttons & chips */
.btn { border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 12px; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 11px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); color: #fff; }
.btn.accept { background: var(--green); border-color: var(--green); color: #fff; }
.btn.reject { color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
.chip { display: inline-block; font-family: var(--mono); font-size: 10px; background: #e0f2fe; color: #0369a1; border-radius: 4px; padding: 1px 6px; cursor: pointer; border: 0; margin: 1px 2px; vertical-align: 1px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { background: var(--accent); color: #fff; }
.chip.bad { background: #fee2e2; color: #991b1b; }
.case { display: inline-block; font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 3px; letter-spacing: .4px; text-transform: uppercase; }
.case-UNPERMITTED_UNASSESSED { background: #fee2e2; color: #991b1b; }
.case-PERMITTED_UNASSESSED { background: #e0f2fe; color: #0369a1; }
.case-UNPERMITTED_ASSESSED, .case-SQFT_INCREASE_NO_PERMIT { background: #fef3c7; color: #92400e; }
.case-REMOVED_STILL_ASSESSED { background: #ede9fe; color: #5b21b6; }
.case-PERMIT_NOT_REFLECTED { background: #f1f5f9; color: #475569; }
.case-VERIFIED { background: #d1fae5; color: #065f46; }

/* review list */
.rq-list { width: 340px; background: var(--card); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.rq-filters { display: flex; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.rq-filters select { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; background: var(--light); }
.rq-items { flex: 1; overflow-y: auto; }
.rq-item { padding: 12px 16px; border-bottom: 1px solid var(--border); border-left: 3px solid transparent; cursor: pointer; }
.rq-item:hover { background: var(--light); }
.rq-item.selected { background: #eff8ff; border-left-color: var(--accent); }
.rq-top { display: flex; align-items: center; gap: 6px; }
.rq-status { margin-left: auto; font-size: 10px; color: var(--muted); }
.rq-title { font-size: 12px; font-weight: 600; margin-top: 6px; line-height: 1.35; }
.rq-meta { display: flex; justify-content: space-between; margin-top: 5px; font-size: 10px; color: var(--muted); }
.empty { color: var(--muted); padding: 40px; text-align: center; }

/* main */
.rq-main { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 18px 22px; gap: 16px; }
.map-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.map-head { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 8px; }
.legend { text-transform: none; letter-spacing: 0; font-weight: 500; display: flex; gap: 10px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.nbhd-map { width: 100%; height: 320px; display: block; }
.nbhd-map path { stroke: #94a3b8; stroke-width: .6; cursor: pointer; vector-effect: non-scaling-stroke; }
.nbhd-map path:hover { stroke: var(--accent); stroke-width: 1.5; }
.nbhd-map path.selected { stroke: var(--text); stroke-width: 2.2; }

.rq-detail { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.d-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.d-title { font-size: 18px; font-weight: 800; line-height: 1.25; margin-top: 6px; }
.d-sub { color: var(--muted); margin-top: 3px; }
.d-score { margin-left: auto; text-align: right; }
.d-score b { font-size: 24px; font-weight: 800; display: block; }
.d-score span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.d-summary { line-height: 1.6; background: var(--light); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.d-grid { display: grid; grid-template-columns: 300px 1fr; gap: 16px; margin-bottom: 14px; }
.overlay { background: #eef3f7; border-radius: 10px; border: 1px solid var(--border); }
.overlay svg { width: 100%; height: 280px; display: block; }
.overlay-legend { font-size: 10px; color: var(--muted); padding: 6px 10px; display: flex; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--border); }
.overlay-legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 4px; }
.section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 14px 0 8px; }
table.ev { width: 100%; border-collapse: collapse; font-size: 12px; }
table.ev td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.ev td.s { width: 22px; text-align: center; font-weight: 700; }
.s-yes { color: var(--green); } .s-no { color: var(--red); } .s-na { color: #cbd5e1; }
.proposed { border: 1px solid #fcd34d; background: #fffbeb; border-radius: 10px; padding: 10px 12px; line-height: 1.6; }
.decision { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.decision input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--light); }
.hint { font-size: 10px; color: var(--muted); margin-top: 6px; }
.audit { list-style: none; font-size: 11px; color: var(--muted); }
.audit li { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.audit b { color: var(--text); font-weight: 600; }
.error { color: var(--red); font-size: 12px; margin-top: 6px; }

/* chat */
.chat { flex: 1; display: flex; flex-direction: column; max-width: 960px; margin: 0 auto; width: 100%; background: var(--light); border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--border); }
.messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; max-width: 86%; }
.msg.user { align-self: flex-end; }
.bubble { padding: 11px 15px; border-radius: 12px; line-height: 1.65; font-size: 13px; }
.msg.ai .bubble { background: var(--card); border: 1px solid var(--border); border-top-left-radius: 3px; }
.msg.user .bubble { background: var(--accent); color: #fff; border-top-right-radius: 3px; }
.bubble ul { padding-left: 18px; margin: 4px 0; }
.status { display: inline-flex; gap: 6px; align-items: center; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 10px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.status.grounded { background: #d1fae5; color: #065f46; }
.status.unverified, .status.error { background: #fee2e2; color: #991b1b; }
.status.refused { background: #f1f5f9; color: #475569; }
details.trace { margin-top: 8px; font-size: 11px; color: var(--muted); }
details.trace summary { cursor: pointer; }
details.trace code { font-family: var(--mono); font-size: 10px; }
.violations { margin-top: 6px; font-size: 11px; color: #991b1b; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px 12px; }
.suggestions button { font-size: 11px; padding: 6px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; cursor: pointer; color: var(--muted); }
.suggestions button:hover { border-color: var(--accent); color: var(--accent); }
.chat-input { display: flex; gap: 10px; padding: 12px 20px; background: var(--card); border-top: 1px solid var(--border); }
.chat-input textarea { flex: 1; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px; resize: none; background: var(--light); outline: none; }
.chat-input textarea:focus { border-color: var(--accent); }
.typing { color: var(--muted); font-style: italic; }

/* data page */
.data-page { flex: 1; overflow-y: auto; padding: 24px 28px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.kpi .l { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 800; margin-top: 6px; }
.kpi .s { font-size: 11px; color: var(--muted); margin-top: 3px; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.panel h3 { font-size: 13px; margin-bottom: 10px; }
.panel table { width: 100%; border-collapse: collapse; font-size: 12px; }
.panel td, .panel th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.panel th { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.panel p, .panel li { line-height: 1.6; }
.panel ul { padding-left: 18px; }

/* drawer */
.drawer { position: fixed; top: 52px; right: 0; bottom: 0; width: 440px; background: var(--card); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0,0,0,.08); transform: translateX(100%); transition: transform .2s; display: flex; flex-direction: column; z-index: 10; }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.drawer-body table { width: 100%; border-collapse: collapse; font-size: 12px; }
.drawer-body td { padding: 5px 6px; border-bottom: 1px solid var(--border); vertical-align: top; word-break: break-word; }
.drawer-body td:first-child { color: var(--muted); width: 40%; }

/* orthophoto pair */
.img-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.img-fig { margin: 0; }
.img-wrap { position: relative; width: 100%; background: #e2e8f0; border-radius: 8px; overflow: hidden; }
.img-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; display: block; }
.img-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.img-fig figcaption { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.img-fig select { border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; background: var(--light); }
.imagery-panel .overlay-legend { border-top: 0; padding: 6px 0 0; }

/* chain of title */
.title-box summary { cursor: pointer; }
.chain-head { font-size: 12px; margin: 4px 0 8px; }
.chain { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.chain-row { display: grid; grid-template-columns: 90px 170px 1fr 220px 110px auto; gap: 10px; align-items: center;
  padding: 7px 10px; border-bottom: 1px solid var(--border); font-size: 12px; }
.chain-row:last-child { border-bottom: 0; }
.chain-row.break { background: #fef2f2; }
.chain-row.gap_explained { background: #fffbeb; }
.pill { display: inline-block; font-size: 10px; font-weight: 700; border: 1px solid; border-radius: 10px; padding: 1px 8px; text-transform: uppercase; letter-spacing: .3px; }
.risk { display: inline-block; width: 50px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; vertical-align: middle; margin-right: 4px; }
.risk i { display: block; height: 100%; }
.sig { display: inline-block; font-size: 10px; background: #fef3c7; color: #92400e; border-radius: 3px; padding: 1px 6px; margin: 1px; }
.intake { display: grid; grid-template-columns: 2fr 2fr 2fr 1.4fr 0.9fr 1.1fr auto; gap: 8px; }
.intake input, .intake select, #title-page h3 select { border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; background: var(--light); font-size: 12px; }
#title-page h3 select { margin-left: 8px; font-weight: 500; }
.intake-card { border: 2px solid; border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
table.rec th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--border); }

/* COGO */
.legal-input { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-family: var(--mono); font-size: 11px; background: var(--light); margin: 6px 0; }
.legal-grid { display: grid; grid-template-columns: 300px 1fr; gap: 14px; margin-top: 10px; }
.legal-svg { width: 100%; background: #eef3f7; border-radius: 8px; border: 1px solid var(--border); }
.findings { padding-left: 18px; margin-bottom: 8px; line-height: 1.6; }

/* appeals */
.appeals-grid { display: grid; grid-template-columns: 420px 1fr; gap: 16px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #eff8ff; }
.packet-head { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0; }
.packet-head > div { background: var(--light); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.packet-head .l { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.packet-head b { font-size: 18px; }
.concl { font-size: 11px; font-weight: 700; }
.concl.ok { color: var(--green); } .concl.bad { color: var(--red); } .concl.mid { color: #b45309; }
.drivers { list-style: none; font-size: 12px; line-height: 1.8; }

/* fairness */
.fair-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart { width: 100%; height: auto; display: block; }
.tier { display: grid; grid-template-columns: 140px 1fr 50px 220px; gap: 8px; align-items: center; font-size: 12px; padding: 4px 0; }
.tier .bar { height: 10px; background: var(--light); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.tier .bar i { display: block; height: 100%; background: var(--accent); }
.ok-t { color: var(--green); font-weight: 700; } .bad-t { color: var(--red); font-weight: 700; }
.chain-search { display: flex; gap: 8px; margin-bottom: 8px; }
.chain-search input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--light); }

/* map zoom */
.map-wrap { position: relative; border-radius: 8px; overflow: hidden; background: #f8fafc; }
.nbhd-map { cursor: grab; touch-action: none; }
.nbhd-map.panning { cursor: grabbing; }
.map-zoom { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 4px; }
.map-zoom button { width: 30px; height: 30px; border: 1px solid var(--border); background: #fff; border-radius: 8px; font-size: 16px;
  line-height: 1; cursor: pointer; color: var(--muted); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.map-zoom button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.map-zoom button:disabled { opacity: .4; cursor: default; background: #fff; color: var(--muted); border-color: var(--border); }
.map-hint { position: absolute; left: 8px; bottom: 6px; font-size: 10px; color: var(--muted); background: rgba(255,255,255,.85); padding: 2px 6px; border-radius: 4px; }

/* title chain diagram */
.chain-graph { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: 6px 0; margin-bottom: 8px; }
.chain-graph svg { display: block; }
.cg-edge, .cg-node { cursor: pointer; }
.cg-edge:hover line:first-child { stroke-width: 3.2; }
.cg-node:hover rect { filter: drop-shadow(0 2px 4px rgba(14,165,233,.35)); }
.chain-legend { border-top: 0; padding: 0 0 8px; }
.chain-table summary { cursor: pointer; font-size: 11px; margin: 4px 0 6px; }

/* sign-in */
.auth-screen { position: fixed; inset: 0; background: var(--sidebar); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.auth-screen[hidden] { display: none; }
.auth-card { background: var(--card); border-radius: 14px; padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.auth-logo { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.auth-logo span { color: var(--accent); }
.auth-org { color: var(--muted); margin: 4px 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form[hidden] { display: none; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 12px; }
.auth-form input { border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; background: var(--light); font-weight: 400; }
.auth-form p { line-height: 1.5; }
.auth-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* administration */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; align-items: end; }
.admin-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); }
.admin-grid input, .admin-grid select, .panel td select { border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; background: var(--light); color: var(--text); }
.notice { background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 8px; padding: 10px 12px; margin-top: 10px; line-height: 1.6; }
.notice code { font-family: var(--mono); font-size: 13px; background: #fff; padding: 2px 6px; border-radius: 4px; user-select: all; }
.status { font-size: 10px; font-weight: 700; border-radius: 10px; padding: 1px 8px; text-transform: uppercase; letter-spacing: .3px; display: inline-block; margin: 1px 0; }
.status.active { background: #dcfce7; color: #166534; } .status.inactive { background: #f1f5f9; color: #475569; }
.status.locked { background: #fee2e2; color: #991b1b; } .status.pending { background: #fef3c7; color: #92400e; }
.matrix td, .matrix th { text-align: center !important; }
.matrix td:first-child, .matrix th:first-child { text-align: left !important; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; }
.scroll-x { overflow-x: auto; }

/* sales validation */
.status.qualified { background: #dcfce7; color: #166534; } .status.review { background: #fef3c7; color: #92400e; }
.status.disqualified { background: #fee2e2; color: #991b1b; }
.sig.hard { background: #fee2e2; color: #991b1b; } .sig.soft { background: #fef3c7; color: #92400e; }
.reason-bar { display: grid; grid-template-columns: minmax(0, 1fr) 120px 48px; gap: 8px; align-items: center; font-size: 12px; padding: 3px 4px; cursor: pointer; border-radius: 6px; }
.reason-bar > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reason-bar:hover { background: #eff8ff; }
.reason-bar b { text-align: right; }
.reason-bar .bar { height: 10px; background: var(--light); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.reason-bar .bar i { display: block; height: 100%; }
.reason-bar .bar i.hard { background: var(--red); } .reason-bar .bar i.soft { background: var(--amber); }
.sales-grid { grid-template-columns: 460px 1fr; align-items: start; }
.sales-top { align-items: start; }
.sales-filters { display: flex; gap: 6px; margin-bottom: 8px; }
.sales-filters select, .sale-decision select { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; background: var(--light); font-size: 12px; }
#sv-list { max-height: 640px; overflow-y: auto; }
tr.sel td { background: #eff8ff; }
.sale-decision { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sale-decision input { flex: 2; min-width: 200px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--light); }
@media (max-width: 1100px) { .sales-grid, .fair-grid { grid-template-columns: 1fr; } }
#sv-list td.mono, #sv-list .status, #sale-detail td.mono { white-space: nowrap; }

/* sales review agent */
.agent-panel { margin-bottom: 16px; border-left: 3px solid var(--violet); }
.agent-panel h3 { margin-bottom: 10px; }
.agent-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.agent-stats > div { background: var(--light); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.agent-stats b { display: block; font-size: 20px; }
.agent-stats span { font-size: 11px; color: var(--muted); }
.agent-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.agent-actions select { border: 1px solid var(--border); border-radius: 8px; padding: 7px 8px; background: var(--light); font-size: 12px; }
.agent-progress { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 12px; flex-wrap: wrap; }
.agent-progress .bar { flex: 1; min-width: 120px; height: 8px; background: var(--light); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.agent-progress .bar i { display: block; height: 100%; background: var(--violet); transition: width .4s; }
.agent-badge { display: inline-block; font-size: 10px; font-weight: 700; border-radius: 10px; padding: 1px 8px; background: #ede9fe; color: #5b21b6; white-space: nowrap; }
.agent-badge.qualified { background: #dcfce7; color: #166534; } .agent-badge.disqualified { background: #fee2e2; color: #991b1b; }
.agent-card { border: 1px solid var(--border); border-left: 3px solid var(--violet); border-radius: 10px; padding: 12px 14px; background: #faf8ff; }
.agent-card.empty { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--light); }
.agent-verdict { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; }
.agent-outcome { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted); }
.agent-note { margin: 8px 0; font-size: 13px; }
.agent-card .l { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-top: 6px; }
.agent-findings { margin: 4px 0 8px 18px; font-size: 12px; }
.agent-findings li { margin: 3px 0; overflow-wrap: anywhere; }
.agent-card details { font-size: 12px; margin: 6px 0; }
.agent-card summary { cursor: pointer; color: var(--accent-dark); }
.agent-steps { margin: 6px 0 0 18px; } .agent-steps li { margin: 2px 0; overflow-wrap: anywhere; }
.agent-card .sale-decision { margin-top: 8px; }
@media (max-width: 760px) { .agent-stats { grid-template-columns: minmax(0, 1fr); gap: 8px; } .agent-stats b { font-size: 17px; } }

/* appeal cases */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 16px; background: var(--card); }
.seg button { border: 0; background: none; padding: 8px 16px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--sidebar); color: #fff; }
.status.cs-filed { background: #e0f2fe; color: #075985; } .status.cs-in_review { background: #ede9fe; color: #5b21b6; }
.status.cs-recommended { background: #fef3c7; color: #92400e; } .status.cs-hearing_scheduled { background: #ffedd5; color: #9a3412; }
.status.cs-decided { background: #dcfce7; color: #166534; } .status.cs-withdrawn { background: #f1f5f9; color: #475569; }
.status.cs-overdue { background: #fee2e2; color: #991b1b; }
.case-actions { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
#cs-list { max-height: 640px; overflow-y: auto; }
#cs-list td.mono, #cs-list .status { white-space: nowrap; }
.case-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.case-form label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
.case-form .wide { grid-column: 1 / -1; }
.case-form input, .case-form select, .case-form textarea, .workflow input, .workflow select, .ev-form input, .ev-form select {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; background: var(--light); font: inherit; font-size: 12px; color: var(--text); min-width: 0; }
.hit { background: none; cursor: pointer; margin: 4px 4px 0 0; border-color: var(--accent); color: var(--accent-dark); text-transform: none; }
.workflow { display: flex; flex-direction: column; gap: 8px; }
.wf { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wf > b { width: 84px; font-size: 12px; }
.wf .grow { flex: 1; min-width: 180px; }
.evidence-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.ev-form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.ev-form input[name=description] { flex: 1; min-width: 160px; }
.review-card { border: 1px solid #c4b5fd; background: #faf8ff; border-radius: 10px; padding: 12px 14px; margin: 8px 0 12px; }
.review-card p { line-height: 1.55; margin: 6px 0; }
.review-card .section-title { margin-top: 10px; }
.rc-head { font-size: 12px; }
@media (max-width: 800px) { .case-form { grid-template-columns: 1fr; } }


/* tablets and small laptops: tabs move to their own swipeable row */
@media (max-width: 1180px) {
  .topbar { height: auto; flex-wrap: wrap; row-gap: 6px; padding: 8px 16px 6px; }
  .pilot-badge { display: none; }
  .user-menu { margin-left: auto; }
  .nav-tabs { order: 3; flex: 0 0 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tab { white-space: nowrap; flex-shrink: 0; }
}

/* phones (iPhone and similar): one scrolling page, stacked panels */
@media (max-width: 760px) {
  body { height: auto; min-height: 100dvh; overflow: visible; display: block; -webkit-text-size-adjust: 100%; }
  input, select, textarea { font-size: 16px !important; }  /* below 16px, iOS Safari zooms in on focus */

  .topbar { height: auto; flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px calc(6px) 12px; padding-top: max(8px, env(safe-area-inset-top));
    position: sticky; top: 0; z-index: 20; }
  .pilot-badge { display: none; }
  .user-menu { margin-left: auto; gap: 6px; }
  .user-menu .who span { display: none; }
  .nav-tabs { order: 3; flex: 0 0 100%; margin: 0 -12px; padding: 0 8px 2px; min-width: 0; overflow-x: auto; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }  /* hints: swipe for more */
  .nav-tab { padding: 8px 10px; font-size: 13px; white-space: nowrap; flex-shrink: 0; }
  .nav-tabs::-webkit-scrollbar { display: none; }

  .view.active { display: block; }
  .view { overflow: visible; }
  .data-page { padding: 14px 12px calc(24px + env(safe-area-inset-bottom)); overflow: visible; }
  .panel { padding: 14px 12px; border-radius: 10px; }

  /* review queue: list above, map and detail below */
  #view-review.active { display: flex; flex-direction: column; }
  .rq-list { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); max-height: 42vh; }
  .rq-main { overflow: visible; padding: 12px; }
  .nbhd-map { height: 240px; }
  .map-head { flex-direction: column; gap: 6px; }
  .legend { gap: 4px 10px; }
  .rq-detail { padding: 14px 12px; }
  .d-head { flex-direction: column; gap: 8px; }
  .d-score { margin-left: 0; text-align: left; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
  .decision { flex-wrap: wrap; }
  .decision input { flex-basis: 100%; }

  /* grids collapse */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .v { font-size: 20px; }
  .packet-head { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .appeals-grid, .sales-grid, .fair-grid, .img-pair, .intake, .d-grid, .legal-grid { grid-template-columns: minmax(0, 1fr); }
  .panel, .rq-detail, .kpi, .packet-head > div { min-width: 0; }  /* let grid cells shrink to the screen */
  .tier { grid-template-columns: 110px 1fr 50px; }
  .tier > span:last-child { grid-column: 1 / -1; }
  .reason-bar { grid-template-columns: minmax(0, 1fr) 70px 42px; }
  .chain-row { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .chain-row > * { grid-column: 1 / -1; }
  #sv-list, #cs-list { max-height: 50vh; }
  #sv-list .status, #cs-list .status { white-space: normal; }
  .sales-filters { flex-wrap: wrap; }
  .sales-filters select { flex: 1 1 40%; }
  .chip { max-width: 100%; }

  /* wide tables scroll sideways inside their panel instead of widening the page */
  .panel table, .rq-detail table.rec, .scroll-x > table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .panel table > tbody, .rq-detail table.rec > tbody { display: table; width: 100%; }  /* full width when it fits */
  table.rec td, table.rec th { min-width: 72px; }
  table.ev td, .panel td, .d-sub, .hint, .proposed { overflow-wrap: break-word; }
  .mono { overflow-wrap: anywhere; }  /* long URLs and record ids */
  /* finding evidence: one block per row (mark, label, value, source) instead of four squeezed columns */
  .d-grid table.ev, .d-grid table.ev tbody { display: block; }
  .d-grid table.ev tr { display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: 6px; padding: 6px 0;
    border-bottom: 1px solid var(--border); }
  .d-grid table.ev td { border: 0; padding: 1px 0; }
  .d-grid table.ev td:nth-child(n+3) { grid-column: 2; }
  .d-grid table.ev td:nth-child(2) { font-weight: 600; }

  .wf > b { width: 100%; }
  .wf .grow, .sale-decision input { min-width: 0; flex-basis: 100%; }
  .evidence-row { flex-direction: column; align-items: flex-start; }
  .seg { display: flex; }
  .seg button { flex: 1; padding: 8px 10px; }

  .drawer { width: 100vw; top: 0; z-index: 30; padding-top: env(safe-area-inset-top); }
  .chat { border: 0; min-height: calc(100dvh - 100px); }
  .messages { padding: 12px; }
  .msg { max-width: 94%; }
  .chat-input { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); position: sticky; bottom: 0; }
  .suggestions { padding: 0 12px 10px; }
  #rq-detail, #packet, #case-detail, #sale-detail { scroll-margin-top: 112px; }  /* clear the sticky top bar */
}
