/* Credit Studio: three-panel layout, styled after a community-app look (purple accent, soft cards). */
:root {
  --bg: #f4f3fa; --card: #ffffff; --ink: #1c1b2e; --muted: #6b6a80; --line: #e7e5f1; --input: #faf9fe;
  --accent: #5b3fd6; --accent-2: #7c5cf0; --accent-soft: #efeafd; --accent-ink: #ffffff;
  --ok: #16794a; --ok-bg: #e2f4ea; --warn: #92600a; --warn-bg: #fdf0d3; --bad: #b3261e; --bad-bg: #fbe4e2; --info: #4d4a6b; --info-bg: #eceaf6;
  --know: linear-gradient(135deg, #38bdf8, #6366f1); --act: linear-gradient(135deg, #ffb347, #ff6b6b); --dec: linear-gradient(135deg, #a78bfa, #ec4899);
  --shadow: 0 1px 2px rgba(40, 30, 90, .05), 0 4px 14px rgba(40, 30, 90, .04);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --side-w: 252px; --right-w: 348px; --top-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #100f1c; --card: #1a1930; --ink: #ece9fb; --muted: #9c9ab6; --line: #2b2947; --input: #14132a;
    --accent: #8b72f5; --accent-2: #a18cff; --accent-soft: #29234f; --accent-ink: #120d2e;
    --ok: #62d394; --ok-bg: #153024; --warn: #f0b755; --warn-bg: #3a2c10; --bad: #ff8b82; --bad-bg: #3d1a18; --info: #b2afd0; --info-bg: #25233f; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #100f1c; --card: #1a1930; --ink: #ece9fb; --muted: #9c9ab6; --line: #2b2947; --input: #14132a;
  --accent: #8b72f5; --accent-2: #a18cff; --accent-soft: #29234f; --accent-ink: #120d2e;
  --ok: #62d394; --ok-bg: #153024; --warn: #f0b755; --warn-bg: #3a2c10; --bad: #ff8b82; --bad-bg: #3d1a18; --info: #b2afd0; --info-bg: #25233f; --shadow: none;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14.5px/1.5 "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .note { font-size: 12.5px; color: var(--muted); } .hint { color: var(--muted); font-size: 13px; margin: 2px 0 12px; }
.mono { font-family: var(--mono); }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 15px; height: 15px; } .ic.lg { width: 34px; height: 34px; color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ───────── layout ───────── */
.app { display: grid; height: 100vh; grid-template-columns: var(--side-w) minmax(0, 1fr) var(--right-w); grid-template-rows: var(--top-h) minmax(0, 1fr); grid-template-areas: "side top top" "side center right"; }
.side { grid-area: side; background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; padding: 16px 14px; gap: 6px; }
.top { grid-area: top; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--card); border-bottom: 1px solid var(--line); }
.center { grid-area: center; overflow-y: auto; padding: 24px; min-width: 0; }
.right { grid-area: right; overflow-y: auto; padding: 24px 24px 24px 0; min-width: 0; }
.col { max-width: 860px; margin: 0 auto; }
.stack > * + * { margin-top: 16px; } .stack-sm > * + * { margin-top: 8px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 14px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; display: grid; place-items: center; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 14px 8px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 8px 8px; border-radius: 12px; color: var(--ink); }
.nav-item:hover { background: var(--accent-soft); }
.nav-item.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.nav-item.active .nav-t { font-weight: 700; }
.nav-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--info-bg); color: var(--info); flex: none; }
.nav-ic.c-know { background: var(--know); color: #fff; } .nav-ic.c-act { background: var(--act); color: #fff; } .nav-ic.c-dec { background: var(--dec); color: #fff; }
.nav-t { font-weight: 600; font-size: 14px; line-height: 1.25; min-width: 0; }
.nav-t small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe { margin-top: auto; border-top: 1px solid var(--line); padding-top: 4px; }
.pipe-row { display: grid; grid-template-columns: 10px 1fr; column-gap: 9px; align-items: center; font-size: 12.5px; padding: 5px 8px; }
.pipe-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); grid-row: span 2; }
.pipe-row span { color: var(--muted); } .pipe-row b { font-weight: 600; grid-column: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-row.ok .dot { background: var(--ok); } .pipe-row.warn .dot { background: var(--warn); }

.top-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.top-title h1 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; }
.top-title .muted { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.only-mobile { display: none; }

.view { display: none; } .view.show { display: block; }
.rview { display: none; } .rview.show { display: block; } .rview > * + * { margin-top: 16px; }

/* ───────── cards & controls ───────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; box-shadow: var(--shadow); }
.card.pad0 { padding: 0; overflow: hidden; }
.card h2 { font-size: 16px; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin: 16px 0 6px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-h h3 { margin: 0; font-size: 12.5px; white-space: nowrap; }
.card-h .row { flex-wrap: nowrap; }
.see { font-size: 12.5px; font-weight: 600; color: var(--accent); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0 0; } .row.tight { margin: 0; gap: 6px; } .row.center-row { justify-content: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--card); border: 1px solid var(--line); color: var(--ink); padding: 8px 14px; border-radius: 999px; font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); color: var(--accent-ink); }
.btn.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.accent:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.btn.big { padding: 11px 26px; font-size: 15px; }
.btn.small { padding: 5px 11px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.block { width: 100%; } .btn.grow { flex: 1; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input, textarea, select { font: inherit; font-size: 13.5px; color: var(--ink); background: var(--input); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; max-width: 100%; }
input[type=checkbox] { accent-color: var(--accent); width: auto; }
input[type=number] { width: 100px; }
textarea { width: 100%; resize: vertical; min-height: 54px; }
textarea.mono { font: 12.5px/1.45 var(--mono); height: 220px; margin-top: 8px; }
.check { display: flex; gap: 7px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
details { margin-top: 12px; } summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; border: 1px dashed var(--line); border-radius: 12px; } .empty.small { padding: 18px 10px; font-size: 13px; } .empty.good { color: var(--ok); border-color: transparent; }
.msg-line { font-size: 12.5px; color: var(--muted); margin: 10px 0; } .msg-line.ok { color: var(--ok); font-weight: 600; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; }
.msgs { font-size: 13px; margin-top: 10px; }
.msgs div { padding: 6px 10px; border-radius: 8px; margin-top: 4px; }
.msgs .e { background: var(--bad-bg); color: var(--bad); } .msgs .w { background: var(--warn-bg); color: var(--warn); } .msgs .i { background: var(--info-bg); color: var(--info); } .msgs .g { background: var(--ok-bg); color: var(--ok); }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.pass { background: var(--ok-bg); color: var(--ok); } .chip.borderline { background: var(--warn-bg); color: var(--warn); } .chip.fail { background: var(--bad-bg); color: var(--bad); } .chip.na, .chip.info { background: var(--info-bg); color: var(--info); }
.chip.Approve { background: var(--ok-bg); color: var(--ok); } .chip.Manual { background: var(--warn-bg); color: var(--warn); } .chip.Reject { background: var(--bad-bg); color: var(--bad); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.tablewrap, .tblwrap { overflow-x: auto; }
ul.tight { margin: 4px 0 0; padding-left: 20px; } ul.tight li { margin: 3px 0; }
.badge-src { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--info-bg); color: var(--info); font-weight: 600; } .badge-src.policy { background: var(--ok-bg); color: var(--ok); }
.ruleinputs { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 10px; align-items: center; font-size: 13.5px; }
.cmp td, .cmp th { text-align: center; } .cmp td:first-child, .cmp th:first-child { text-align: left; }

/* ───────── Home ───────── */
.hero { height: 150px; border-radius: 16px; background: #14102e; overflow: hidden; }
.hero-art { width: 100%; height: 100%; display: block; }
.home-h { font-size: 22px !important; }
.lede { color: var(--muted); margin-top: 6px; max-width: 60ch; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: border-color .15s, transform .15s; }
.step:hover { border-color: var(--accent); transform: translateY(-1px); }
.step h3 { margin: 0; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 800; }
.step p { color: var(--muted); font-size: 13px; flex: 1; }
.step-n { width: 30px; height: 30px; border-radius: 9px; color: #fff; display: grid; place-items: center; font-weight: 800; }
.step-n.c-know { background: var(--know); } .step-n.c-act { background: var(--act); } .step-n.c-dec { background: var(--dec); }
.step-status { font-size: 12px; font-weight: 600; color: var(--muted); }
.step-status.ok { color: var(--ok); }
.flow { margin: 10px 0; padding-left: 20px; } .flow li { margin: 6px 0; }
.status-list, .recent { list-style: none; margin: 0; padding: 0; }
.status-list li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; align-items: center; }
.status-list li:last-child, .recent li:last-child { border-bottom: 0; }
.status-list .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; } .status-list .ok .dot { background: var(--ok); }
.status-list b { margin-left: auto; font-weight: 600; text-align: right; }
.recent li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.recent .av { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; flex: none; }
.recent .t { min-width: 0; flex: 1; } .recent .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .recent .t span { color: var(--muted); font-size: 12px; }

/* ───────── Knowledge (chat) ───────── */
#v-knowledge { height: 100%; } #v-knowledge.show { display: flex; }
.chat-wrap { display: flex; flex-direction: column; width: 100%; max-width: 820px; margin: 0 auto; min-height: 0; }
.thread { flex: 1; display: flex; flex-direction: column; gap: 18px; padding-bottom: 16px; }
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
.msg.you { justify-content: flex-end; }
.av { width: 34px; height: 34px; border-radius: 50%; color: #fff; display: grid; place-items: center; flex: none; }
.av.c-know { background: var(--know); }
.bubble { background: var(--card); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 12px 16px; box-shadow: var(--shadow); min-width: 0; }
.msg.you .bubble { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); border-radius: 16px 4px 16px 16px; max-width: 78%; white-space: pre-wrap; }
.msg.you .ctx { display: block; font-size: 11.5px; opacity: .8; margin-top: 4px; }
.msg.agent { width: 100%; } .msg.agent .bubble { flex: 1; }
.msg.agent .bubble.wide { padding: 0; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips button { font: inherit; font-size: 12.5px; background: var(--accent-soft); color: var(--accent); border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer; text-align: left; font-weight: 600; }
.chips button:hover { background: var(--accent); color: var(--accent-ink); }
.pending { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.pending .dotp { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
.composer { position: sticky; bottom: -24px; margin: 0 -4px; padding: 12px 4px 24px; background: linear-gradient(to top, var(--bg) 78%, transparent); }
.composer-row { display: flex; gap: 10px; align-items: flex-end; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 18px; box-shadow: var(--shadow); }
.composer-row:focus-within { border-color: var(--accent); }
.composer-row textarea { border: 0; background: transparent; resize: none; min-height: 0; max-height: 140px; padding: 8px 0; outline: none; }
.send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.send:disabled { opacity: .4; cursor: not-allowed; } .send:hover:not(:disabled) { background: var(--accent-2); }
.cust { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin: 0 0 10px; }
.cust .fgrid { margin-top: 10px; }

.answer-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.verdict { font-weight: 800; font-size: 13px; padding: 3px 12px; border-radius: 999px; }
.v-good { background: var(--ok-bg); color: var(--ok); } .v-bad { background: var(--bad-bg); color: var(--bad); } .v-warn { background: var(--warn-bg); color: var(--warn); } .v-neutral { background: var(--info-bg); color: var(--info); }
.conf { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-left: auto; }
.bars { display: inline-flex; gap: 3px; } .bars i { width: 6px; height: 12px; border-radius: 2px; background: var(--line); } .bars i.on { background: var(--accent); }
.answer-body { padding: 14px 16px; display: grid; gap: 14px; }
.answer-body .reason { white-space: pre-wrap; }
.label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.box { border-radius: 12px; padding: 10px 14px; background: var(--info-bg); display: grid; gap: 4px; font-size: 13.5px; }
.box.warn { background: var(--warn-bg); } .box.cust { background: var(--accent-soft); }
.box .hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cite { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; font-size: 13px; }
.cite .ref { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-weight: 700; font-size: 12.5px; }
.cite .ref .ok { color: var(--ok); font-weight: 600; } .cite .ref .no { color: var(--warn); font-weight: 600; }
.cite q { display: block; color: var(--muted); font-style: italic; margin-top: 2px; }
.cite .view { margin-left: auto; font: inherit; font-size: 12px; background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; }
.status.ok { color: var(--ok); font-weight: 700; } .status.v-bad { color: var(--bad); font-weight: 700; background: none; } .status.no { color: var(--warn); font-weight: 700; } .status.v-neutral { color: var(--muted); background: none; }
.answer-foot { display: flex; gap: 8px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); }
.answer-foot .sp { flex: 1; }
.local-note { font-size: 12.5px; color: var(--warn); background: var(--warn-bg); border-radius: 10px; padding: 8px 12px; }

.policy-name { font-weight: 800; font-size: 14.5px; }
.paste { display: none; margin-top: 8px; } .paste.open { display: block; } .paste textarea { height: 130px; }
.digest { white-space: pre-wrap; font-size: 13px; background: var(--info-bg); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.sections details { margin: 0; border-bottom: 1px solid var(--line); border-radius: 0; } .sections details:last-child { border-bottom: 0; }
.sections summary { display: flex; gap: 8px; align-items: center; padding: 9px 2px; font-size: 13px; font-weight: 600; }
.sections summary .n { width: 22px; height: 22px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11.5px; font-weight: 800; flex: none; }
.sections summary .w { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 11.5px; }
.sections pre { white-space: pre-wrap; font-family: inherit; font-size: 12.5px; line-height: 1.55; margin: 0 0 10px; color: var(--muted); }
.sections details.flash { background: var(--accent-soft); border-radius: 10px; }

/* ───────── Action ───────── */
.drop { border: 2px dashed var(--line); border-radius: 16px; padding: 24px; text-align: center; display: grid; gap: 8px; justify-items: center; background: var(--input); transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop textarea { display: none; height: 150px; font: 12.5px/1.4 var(--mono); }
.drop textarea.show { display: block; }
.staged { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 8px 12px; border-radius: 12px; background: var(--accent-soft); font-size: 13.5px; }
.staged b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .staged button { margin-left: auto; }
#status { font-size: 13px; color: var(--muted); } #status.error { color: var(--bad); }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.tab { border: 0; border-bottom: 2px solid transparent; background: none; padding: 13px 12px; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 5px; border-radius: 9px; font-size: 11px; line-height: 18px; text-align: center; background: var(--line); color: var(--ink); }
.badge.err { background: var(--bad); color: #fff; } .badge.warn { background: var(--warn); color: #fff; }
.stats { display: flex; gap: 18px; padding: 10px 20px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); flex-wrap: wrap; } .stats b { color: var(--ink); font-size: 14px; }
.panel { padding: 16px 20px 22px; }
.panel .card { box-shadow: none; margin-bottom: 14px; padding: 14px 16px; border-radius: 14px; }
.panel .card h3 { margin: 0 0 10px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.fgrid .wide { grid-column: 1 / -1; }
.f label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.f input, .f textarea, .f select { width: 100%; }
.f.low input, .f.low textarea { border-color: var(--warn); background: var(--warn-bg); }
.f.miss input, .f.miss textarea { border-color: var(--bad); border-style: dashed; }
.f.flash input, .f.flash textarea, td.flash input { box-shadow: 0 0 0 3px var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); display: inline-block; }
.dot.hi { background: var(--ok); } .dot.mid { background: var(--warn); } .dot.lo { background: var(--bad); } .dot.ed { background: var(--accent); }
.pgchip { margin-left: auto; font: inherit; font-size: 11px; border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; background: none; color: var(--muted); cursor: pointer; }
.pgchip:hover { color: var(--accent); border-color: var(--accent); }
table.t th { padding: 4px 6px; } table.t td { padding: 3px 4px; vertical-align: middle; }
table.t td.lbl { font-size: 12.5px; color: var(--muted); white-space: nowrap; padding-right: 8px; }
table.t td.low input { border-color: var(--warn); background: var(--warn-bg); } table.t td.miss input { border-color: var(--bad); border-style: dashed; }
table.t input { padding: 5px 7px; width: 100%; min-width: 92px; } table.t th input { font-weight: 700; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: 0 0 12px; flex-wrap: wrap; } .legend span { display: flex; align-items: center; gap: 5px; }
.warn-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.warn-item:hover { border-color: var(--accent); }
.sev { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 7px; text-transform: uppercase; flex: none; margin-top: 1px; }
.sev.error { background: var(--bad-bg); color: var(--bad); } .sev.warn { background: var(--warn-bg); color: var(--warn); } .sev.info { background: var(--accent-soft); color: var(--accent); }
.warn-item small { display: block; color: var(--muted); }
#pages { padding: 14px; background: var(--bg); max-height: 70vh; overflow: auto; }
.pg { position: relative; margin: 0 auto 14px; max-width: 760px; background: #fff; border-radius: 4px; box-shadow: 0 1px 4px rgba(0, 0, 0, .18); border: 2px solid transparent; transition: border-color .2s; }
.pg.hit { border-color: var(--accent); }
.pg canvas, .pg img { display: block; width: 100%; height: auto; }
.pg .num { position: absolute; top: 6px; right: 8px; font-size: 11px; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 10px; padding: 1px 7px; }
pre.rawtext { white-space: pre-wrap; margin: 0; padding: 14px; font: 12.5px/1.5 var(--mono); background: #fff; color: #111; border-radius: 4px; }
#json { margin: 0; padding: 12px; background: var(--input); border: 1px solid var(--line); border-radius: 12px; font: 11.5px/1.5 var(--mono); max-height: 46vh; overflow: auto; white-space: pre; color: var(--ink); }

/* ───────── Decision ───────── */
.inputs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.src-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: grid; gap: 2px; background: var(--input); min-width: 0; }
.src-box b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .src-box .muted { font-size: 12.5px; }
.src-k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.src-box.ok { border-color: var(--ok); }
.evalbar { margin: 4px 0; gap: 14px; }
.banner { border-radius: 16px; padding: 18px 22px; display: flex; gap: 18px; align-items: center; flex-wrap: wrap; border: 1px solid; }
.banner.Approve { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); } .banner.Manual { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); } .banner.Reject { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }
.banner .big { font-size: 28px; font-weight: 800; line-height: 1.1; } .banner .sub { color: var(--ink); font-size: 14px; }
.banner .meta { margin-left: auto; text-align: right; color: var(--ink); } .banner .meta b { font-size: 18px; }

/* report preview (right) and print */
.memo { font-size: 12.5px; line-height: 1.5; color: var(--ink); }
.memo h4 { margin: 14px 0 5px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.memo .m-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; border-bottom: 2px solid var(--accent); padding-bottom: 8px; }
.memo .m-head b { font-size: 15px; display: block; } .memo .m-head span { color: var(--muted); font-size: 11.5px; }
.memo .m-dec { margin: 10px 0; padding: 10px 12px; border-radius: 10px; font-weight: 800; font-size: 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.memo .m-dec small { font-size: 11.5px; font-weight: 600; }
.memo .m-dec.Approve { background: var(--ok-bg); color: var(--ok); } .memo .m-dec.Manual { background: var(--warn-bg); color: var(--warn); } .memo .m-dec.Reject { background: var(--bad-bg); color: var(--bad); }
.memo table { font-size: 11.5px; } .memo th, .memo td { padding: 4px 5px; }
.memo p { margin: 4px 0; } .memo ul { margin: 4px 0; padding-left: 18px; }
.memo .m-foot { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
#printRoot { display: none; }
#d-results[data-stale="1"]::before { content: "Inputs changed since this evaluation. Press Evaluate to refresh."; display: block; background: var(--warn-bg); color: var(--warn); border-radius: 12px; padding: 8px 14px; font-size: 13px; font-weight: 600; }
@media print {
  html.printing:root { --bg: #fff; --card: #fff; --ink: #000; --muted: #555; --line: #ccc; --input: #fff; --accent: #5b3fd6; --ok: #16794a; --ok-bg: #e2f4ea; --warn: #92600a; --warn-bg: #fdf0d3; --bad: #b3261e; --bad-bg: #fbe4e2; --info: #4d4a6b; --info-bg: #eceaf6; }
  html.printing body > *:not(#printRoot) { display: none !important; }
  html.printing, html.printing body { background: #fff !important; height: auto; }
  html.printing #printRoot { display: block !important; padding: 0; color: #000; }
  html.printing #printRoot .memo { font-size: 11.5px; color: #000; --ink: #000; --muted: #555; --line: #ccc; }
  html.printing #printRoot .chip, html.printing #printRoot .m-dec { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html.printing #printRoot tr { break-inside: avoid; }
}

/* history compare */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 10px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 600; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); z-index: 50; max-width: 92vw; }

/* ───────── responsive ───────── */
@media (max-width: 1180px) {
  .app { grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: var(--top-h) auto auto; grid-template-areas: "side top" "side center" "side right"; align-content: start; height: auto; min-height: 100vh; }
  .side { position: sticky; top: 0; height: 100vh; grid-row: 1 / span 3; }
  .center { overflow: visible; padding-bottom: 8px; } .right { overflow: visible; padding: 0 24px 24px; }
  .col { max-width: 900px; }
  #v-knowledge.show { height: auto; } .composer { bottom: 0; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "center" "right"; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-102%); transition: transform .2s; height: 100vh; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .side.open { transform: none; }
  .only-mobile { display: grid; }
  .top { padding: 0 16px; } .center { padding: 16px; } .right { padding: 0 16px 24px; }
  .steps, .inputs-grid { grid-template-columns: 1fr; }
  .top-title .muted { display: none; }
  .banner .meta { margin-left: 0; text-align: left; }
}

.modal { border: 1px solid var(--line); border-radius: 18px; background: var(--card); color: var(--ink); padding: 22px 24px; width: min(460px, 92vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal::backdrop { background: rgba(10, 8, 30, .5); }
.modal h2 { font-size: 17px; font-weight: 800; }
.modal .f input { width: 100%; }

.aibar { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--accent-soft); font-size: 13px; }
.aibar span { color: var(--ink); } .aibar.warn { background: var(--warn-bg); }
.ai-text { white-space: pre-wrap; background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; margin-top: 10px; }
.memo .ai-text { font-size: 11.5px; padding: 8px 10px; background: var(--info-bg); }
