/* Lantern Intel - workspace (app.html) */
body.app { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.app-top { position: sticky; top: 0; z-index: 40; background: rgba(255, 255, 255, .94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.app-top .bar { display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 58px; max-width: 1480px; margin: 0 auto; }
.tabs { display: flex; gap: 2px; margin-left: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab-btn { border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; position: relative; }
.tab-btn:hover { color: var(--ink); background: var(--surface-2); }
.tab-btn[aria-selected="true"] { color: var(--ink); background: var(--accent-soft); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 8px 8px 0 0; }
.count { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; margin-left: 4px; }
.session { font-size: 13px; color: var(--muted); padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.spacer { flex: 1; }
.app-main { flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 22px 16px 30px; }
.tab { display: none; }
.tab.active { display: block; }
.app-foot { border-top: 1px solid var(--line); background: var(--surface); padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12.5px; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 26px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h3 { font-size: 16px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.foot-note { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
label { font-size: 12.5px; color: var(--muted); font-weight: 500; display: grid; gap: 4px; }
input[type=text], input[type=search], select, textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 8px 10px; min-width: 0; width: 100%;
}
textarea { resize: vertical; min-height: 70px; }
label.chk { display: flex; align-items: center; gap: 6px; flex-direction: row; color: var(--ink-2); font-size: 13px; padding-top: 18px; white-space: nowrap; }
label.chk input { width: auto; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; align-items: end; }
.filters label { min-width: 130px; }
.filters .grow { flex: 1; min-width: 200px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip i, .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* Tables */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th[data-sort] { cursor: pointer; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.flag td { background: #fff6f6; }
.tbl tr.new td { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: #fff0cf; } to { background: transparent; } }
.addr-link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink); font: inherit; text-align: left; }
.addr-link:hover { color: var(--accent-strong); text-decoration: underline; }
.addr-link .sub { display: block; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.risk { font-family: var(--mono); font-weight: 600; font-size: 12px; padding: 2px 7px; border-radius: 6px; display: inline-block; }
.risk.lo { background: #e6f6ec; color: #14803b; }
.risk.md { background: var(--accent-soft); color: var(--accent-ink); }
.risk.hi { background: var(--bad-soft); color: var(--bad); }
.live { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 rgba(22, 163, 74, .5); animation: pulse 1.6s infinite; }
.pulse.off { background: var(--muted); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }

/* Search */
.search-hero { max-width: 760px; margin: 18px auto 10px; text-align: center; }
.search-hero h1 { font-size: clamp(24px, 3.4vw, 34px); margin-bottom: 18px; }
.search-box { position: relative; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 14px; padding: 6px 14px; box-shadow: var(--shadow); text-align: left; }
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { color: var(--muted); flex: none; }
.search-box input { border: 0; outline: 0; font-size: 16px; padding: 12px 0; background: transparent; }
.search-box input:focus-visible { outline: none; }
kbd { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; color: var(--muted); background: var(--surface-2); }
#sugg { position: absolute; left: -1px; right: -1px; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 14px 40px rgba(15, 27, 51, .16); list-style: none; margin: 0; padding: 6px; z-index: 30; max-height: 400px; overflow-y: auto; }
#sugg .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 8px 10px 4px; font-weight: 600; }
#sugg li[role=option] { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
#sugg li[aria-selected="true"], #sugg li[role=option]:hover { background: var(--accent-soft); }
#sugg mark { background: #ffe19a; color: inherit; border-radius: 2px; }
#sugg .meta { margin-left: auto; color: var(--muted); font-size: 12px; }
.search-hero .chips { justify-content: center; }
.recent { max-width: 760px; margin: 0 auto 6px; color: var(--muted); font-size: 13px; text-align: center; }
.recent button { background: none; border: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; font: inherit; margin: 0 6px; }
.res { max-width: 980px; margin: 18px auto 0; display: grid; gap: 14px; }
.res-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.res-head h2 { font-size: 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kv div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.kv small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.kv b { font-size: 16px; }
.addr-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.addr-row:last-child { border-bottom: 0; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 999px; }
.factors { margin: 8px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; }

/* Tracer */
.tr-toolbar { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: end; margin-bottom: 12px; }
.tr-start { display: flex; gap: 8px; flex: 1 1 280px; max-width: 420px; }
.tr-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.tr-filters select { padding: 6px 8px; font-size: 13px; }
.tr-tools { display: flex; gap: 6px; margin-left: auto; }
.tr-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; }
.tr-canvas-wrap { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); height: calc(100vh - 230px); min-height: 480px; overflow: hidden; background-image: radial-gradient(circle, #dfe3ec 1px, transparent 1px); background-size: 24px 24px; }
#tr-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#tr-canvas.grabbing { cursor: grabbing; }
.tr-hint { position: absolute; left: 12px; bottom: 10px; font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, .9); padding: 3px 8px; border-radius: 6px; border: 1px solid var(--line); pointer-events: none; }
.tr-legend { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; background: rgba(255, 255, 255, .92); border: 1px solid var(--line); padding: 8px 10px; border-radius: 8px; pointer-events: none; }
.tr-legend span { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tr-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; height: calc(100vh - 230px); min-height: 480px; overflow-y: auto; }
.tr-panel h3 { font-size: 18px; display: flex; align-items: center; gap: 8px; word-break: break-word; }
.tr-panel h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }
.tr-panel .addr { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; }
.score { display: flex; align-items: center; gap: 12px; }
.score .num { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1; min-width: 52px; }
.score .meter { flex: 1; }
.score small { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-grid div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.stat-grid small { display: block; font-size: 11px; color: var(--muted); }
.stat-grid b { font-size: 14px; font-variant-numeric: tabular-nums; }
.xfer { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 8px 2px; cursor: pointer; text-align: left; font-size: 13px; color: var(--ink); }
.xfer:hover { background: var(--surface-2); }
.xfer .nm { display: flex; align-items: center; gap: 6px; min-width: 0; }
.xfer .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xfer .amt { text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.xfer .amt small { display: block; color: var(--muted); font-size: 11px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.bar-row { display: grid; grid-template-columns: 100px 1fr 60px; gap: 8px; align-items: center; font-size: 12.5px; margin-bottom: 6px; }
.bar-row .meter { height: 10px; }
.bar-row span:last-child { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 14px; }

/* Alerts */
.rule-form { display: grid; gap: 10px; margin-bottom: 14px; }
.rules, .feed, .case-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rule { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.rule .t { flex: 1; min-width: 0; }
.rule .t b { display: block; font-size: 14px; }
.rule .t span { color: var(--muted); font-size: 12.5px; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; width: 100%; height: 100%; }
.switch i { position: absolute; inset: 0; background: var(--line-2); border-radius: 999px; transition: background .15s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.alert-item { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.alert-item.hi { border-left-color: var(--bad); }
.alert-item .top { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.alert-item .top b { color: var(--ink); font-size: 13px; }

/* Cases */
.cases-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }
.case-item { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; font: inherit; }
.case-item:hover { border-color: var(--accent); }
.case-item.sel { border-color: var(--accent); background: var(--accent-soft); }
.case-item b { display: block; font-size: 14px; }
.case-item small { color: var(--muted); font-size: 12px; }
.status { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.status.open { background: #e8efff; color: #2354c7; }
.status.review { background: var(--accent-soft); color: var(--accent-ink); }
.status.signed { background: #e6f6ec; color: #14803b; }
.stepper { display: flex; gap: 6px; margin: 14px 0; flex-wrap: wrap; }
.stepper span { flex: 1; min-width: 90px; text-align: center; padding: 7px 8px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stepper span.done { background: var(--ink); color: #fff; }
.evidence { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; font-size: 13.5px; }
.evidence small { color: var(--muted); display: block; }
.note { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.note small { display: block; color: var(--muted); margin-bottom: 2px; font-size: 11.5px; }
.sec-t { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; }

/* Modal + toast */
.modal-back { position: fixed; inset: 0; background: rgba(15, 27, 51, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal-back[hidden] { display: none; }
.modal { background: var(--surface); border-radius: 16px; padding: 24px; width: min(460px, 100%); box-shadow: 0 30px 80px rgba(0, 0, 0, .3); max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 20px; margin-bottom: 6px; }
.modal p { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.modal .grid { display: grid; gap: 10px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 30px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 120; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .tr-main { grid-template-columns: 1fr; }
  .tr-canvas-wrap { height: 62vh; min-height: 380px; }
  .tr-panel { height: auto; min-height: 0; max-height: none; }
  .two-col, .cases-grid { grid-template-columns: 1fr; }
  .tr-tools { margin-left: 0; }
}
@media (max-width: 520px) {
  .brand-name { display: none; }
  .app-main { padding: 14px 12px 24px; }
  .tr-legend { display: none; }
  .tr-hint { right: 12px; }
}
