:root {
  --navy: #0c3359; --navy-2: #12406d; --teal: #1fb89a; --teal-d: #179b81; --sky: #d7eaf7; --sky-2: #e8f3fb;
  --bg: #f1f1f1; --panel: #ffffff; --line: #dfe3e8; --text: #2b2f33; --muted: #6b7480; --link: #1d5e95;
  --warn: #e8a317; --bad: #d64545; --good: #1fb89a; --folder: #e7b416;
  --in: #0e9f86; --out: #2b5c9e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.4 "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); overflow: hidden; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
.hidden { display: none !important; }

/* top bar */
.topbar { height: 52px; background: var(--navy); display: flex; align-items: center; gap: 14px; padding: 0 14px; color: #fff; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.logo svg { width: 26px; height: 26px; }
.search { display: flex; background: #fff; border-radius: 3px; overflow: hidden; width: 290px; }
.search input { border: 0; outline: 0; padding: 7px 8px 7px 30px; flex: 1; background: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231fb89a' stroke-width='3'><circle cx='10' cy='10' r='7'/><path d='m15 15 6 6'/></svg>") 8px center no-repeat; }
.search select { border: 0; border-left: 1px solid var(--line); background: #fff; padding: 0 6px; max-width: 110px; }
.btn { border: 1px solid #c9cfd6; background: #f7f7f7; border-radius: 3px; padding: 6px 12px; color: var(--text); }
.btn:hover { background: #eee; }
.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-d); }
.btn-danger { background: #fff; border-color: #e0b4b4; color: var(--bad); }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.navtabs { display: flex; gap: 2px; margin-left: 8px; }
.navtabs button { background: transparent; border: 0; color: #c8dcef; padding: 8px 12px; border-radius: 3px; }
.navtabs button.active, .navtabs button:hover { background: var(--navy-2); color: #fff; }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 8px; color: #dbe8f5; }
.role { font-size: 11px; padding: 2px 6px; border-radius: 10px; background: var(--teal); color: #fff; text-transform: uppercase; letter-spacing: .5px; }
.role.assistant { background: #7a8794; }
.iconbtn { background: transparent; border: 0; color: #fff; padding: 6px; border-radius: 3px; display: flex; }
.iconbtn:hover { background: var(--navy-2); }

/* layout */
.main { display: flex; height: calc(100vh - 52px); }
.sidebar { width: 225px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.sidebar.collapsed { width: 44px; }
.side-collapsed-tab { writing-mode: vertical-rl; transform: rotate(180deg); padding: 14px 12px; font-weight: 700; color: var(--navy); cursor: pointer; }
.panel-head { background: var(--sky); padding: 10px 10px 8px; display: flex; align-items: center; justify-content: space-between; font-weight: 700; color: var(--navy); text-transform: uppercase; font-size: 13px; }
.panel-head .lnk { text-transform: none; font-weight: 400; color: var(--navy); background: none; border: 0; padding: 0; }
.org { background: var(--sky); padding: 0 10px 10px; font-weight: 700; color: var(--navy); display: flex; gap: 8px; align-items: center; }
.tree { overflow: auto; flex: 1; padding: 6px 0; }
.tree .item { display: flex; align-items: center; gap: 7px; padding: 4px 10px 4px calc(12px + var(--depth, 0) * 14px); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #333; }
.tree .item:hover { background: var(--sky-2); }
.tree .item.active { background: #e4e7ea; font-weight: 600; }
.tree .item .name { overflow: hidden; text-overflow: ellipsis; }
.tree .item .lock { margin-left: auto; color: var(--muted); }
.tree .item.all { font-weight: 600; }
.tagbox { max-height: 30%; overflow: auto; }
.tag-dot { width: 12px; height: 12px; border-radius: 50% 50% 50% 0; transform: rotate(45deg); flex: none; }

.doclist { width: 262px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.doclist .panel-head { padding-bottom: 6px; }
.doclist .sort { text-transform: none; font-weight: 400; font-size: 12px; }
.doclist .sort select { border: 0; background: transparent; color: var(--navy); text-decoration: underline; padding: 0; }
.subtabs { background: var(--sky); display: flex; gap: 3px; padding: 0 6px; }
.subtabs button { border: 1px solid transparent; border-bottom: 0; background: #e6f0f8; padding: 5px 5px; font-size: 11px; white-space: nowrap; border-radius: 4px 4px 0 0; color: #333; }
.subtabs button.active { background: #fff; border-color: var(--line); }
.subtabs .cnt { color: var(--muted); font-size: 10.5px; }
.cards { overflow: auto; flex: 1; }
.card { display: flex; gap: 12px; padding: 14px 12px; border-bottom: 1px solid #eceff2; cursor: pointer; position: relative; overflow: hidden; }
.card:hover { background: #f7fafc; }
.card.active { background: #eceff1; }
.card .thumb { width: 50px; height: 50px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; flex: none; }
.card .meta { min-width: 0; flex: 1; font-size: 12px; color: #555; }
.card .meta b { display: block; color: #333; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .st { flex: none; align-self: center; }
.ribbon { position: absolute; left: -22px; top: 10px; transform: rotate(-45deg); background: var(--teal); color: #fff; font-size: 9px; font-weight: 700; padding: 2px 24px; }
.conf-badge { display: inline-block; font-size: 10px; color: #8a5a00; background: #fff3d6; border: 1px solid #f0d9a2; border-radius: 3px; padding: 0 4px; margin-top: 2px; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }
.scroll { overflow: auto; flex: 1; }

/* home / import */
.home { padding: 18px 22px; }
.home h2 { color: var(--navy); font-size: 20px; margin: 0 0 12px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.import-row { display: flex; gap: 40px; flex-wrap: wrap; margin-bottom: 22px; }
.import-tile { text-align: center; cursor: pointer; width: 150px; color: var(--navy); font-weight: 700; }
.import-tile .ic { width: 96px; height: 110px; margin: 0 auto 8px; display: grid; place-items: center; position: relative; }
.import-tile .chk { position: absolute; right: 10px; bottom: 4px; background: var(--teal); color: #fff; border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; border: 3px solid #fff; }
.dropzone { border: 2px dashed #b9c7d4; border-radius: 8px; padding: 26px; text-align: center; color: var(--muted); flex: 1; min-width: 260px; display: flex; flex-direction: column; justify-content: center; }
.dropzone.drag { border-color: var(--teal); background: #effaf7; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 18px; }
.chart-wide { grid-column: span 2; }
@media (max-width: 900px) { .chart-wide { grid-column: auto; } .grid2 { grid-template-columns: 1fr; } }
.box { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; background: #fff; }
.box h3 { margin: 0 0 10px; font-size: 14px; color: var(--navy); }
.rowline { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f0f2f4; cursor: pointer; }
.rowline:last-child { border-bottom: 0; }
.rowline .r { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { font-size: 11px; border-radius: 10px; padding: 1px 7px; }
.pill.bad { background: #fde8e8; color: #a32d2d; }
.pill.warn { background: #fff3d6; color: #8a5a00; }

/* document view */
.dochead { background: var(--sky); padding: 8px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dochead h1 { margin: 0; font-size: 15px; color: var(--navy); display: flex; align-items: center; gap: 6px; }
.dochead .actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }
.dochead .actions button { background: none; border: 0; color: var(--navy); text-decoration: underline; font-weight: 600; padding: 0; font-size: 12px; }
.dochead .actions .del { color: var(--navy); }
.taglist { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.taglist .t { background: var(--teal); color: #fff; padding: 2px 8px; border-radius: 3px; font-size: 11px; display: inline-flex; gap: 6px; align-items: center; }
.taglist .t button { background: none; border: 0; color: #fff; padding: 0; }
.docbody { display: flex; flex: 1; min-height: 0; }
.viewer { flex: 1; min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.vtools { display: flex; gap: 16px; padding: 8px 14px; color: var(--navy); }
.vtools button { background: none; border: 0; color: var(--navy); padding: 0; }
.stage { flex: 1; overflow: auto; background: #f3f4f5; display: flex; justify-content: center; align-items: flex-start; padding: 14px; }
.stage .page { transform-origin: top center; transition: transform .15s; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.stage img.page { max-width: 100%; }
.stage iframe.page { width: 100%; height: 100%; min-height: 600px; border: 0; }
.stage pre.page { padding: 16px; white-space: pre-wrap; font-size: 11.5px; max-width: 900px; width: 100%; margin: 0; }
.docmeta { text-align: center; font-size: 11px; color: var(--muted); padding: 6px; }

.details { width: 400px; flex: none; overflow: auto; background: #fff; }
.pager { background: #a9adb1; display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; color: #fff; }
.pager button { background: none; border: 0; color: #fff; font-size: 14px; }
.pager .approve { border: 1px solid #fff; border-radius: 3px; padding: 4px 10px; font-size: 12px; }
.pager .approve:hover { background: rgba(255,255,255,.15); }
.archive-hint { text-align: center; padding: 8px; font-size: 12px; }
.form { padding: 4px 22px 18px; }
.form .sec { display: flex; justify-content: space-between; align-items: center; margin: 10px 0 12px; font-weight: 700; color: #333; }
.f { display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 8px; margin-bottom: 10px; }
.f label { font-size: 12.5px; }
.f label.req::before { content: "*"; color: var(--bad); }
.f input, .f select, .f textarea { width: 100%; padding: 6px 8px; border: 1px solid #c9cfd6; border-radius: 2px; background: #fff; }
.f textarea { min-height: 60px; resize: vertical; }
.f .pair { display: flex; gap: 8px; }
.f .pair select { width: 80px; }
.lockline { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #f0d9a2; background: #fffaf0; border-radius: 4px; font-size: 12px; margin: 6px 0 12px; }
.statebox { border-top: 1px solid var(--line); padding: 14px 22px; }
.statebox h4 { margin: 0 0 8px; font-size: 12.5px; text-transform: uppercase; color: #333; }

/* analysis */
.analysis { padding: 16px 22px 40px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input { padding: 5px 8px; border: 1px solid #c9cfd6; border-radius: 3px; background: #fff; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; }
.kpi .l { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .s { color: var(--muted); font-size: 11.5px; }
.hbar { display: grid; grid-template-columns: 150px 1fr 90px; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; }
.hbar .lab { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.hbar .track { height: 14px; display: block; }
.hbar .fill { height: 14px; background: var(--out); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar:hover .fill { filter: brightness(1.15); }
.hbar .val { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: #eceff2; }
.chart text { font-size: 10.5px; fill: var(--muted); }
.tip { position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.12); border-radius: 4px; padding: 6px 8px; font-size: 12px; white-space: nowrap; z-index: 5; }
table.tx { width: 100%; border-collapse: collapse; font-size: 12px; }
table.tx th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px; position: sticky; top: 0; background: #fff; }
table.tx td { border-bottom: 1px solid #f0f2f4; padding: 5px 6px; }
table.tx td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tx select { border: 1px solid transparent; background: transparent; padding: 2px; }
table.tx select:hover { border-color: #c9cfd6; }
.neg { color: #333; } .pos { color: #0b7a66; }
.txwrap { max-height: 520px; overflow: auto; }

/* settings */
.settings { padding: 18px 22px; max-width: 980px; }
.settings h2 { color: var(--navy); font-size: 18px; margin: 18px 0 10px; }
.settings table { width: 100%; border-collapse: collapse; }
.settings td, .settings th { padding: 7px 6px; border-bottom: 1px solid #eef0f2; text-align: left; font-size: 12.5px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.inline-form input, .inline-form select { padding: 6px 8px; border: 1px solid #c9cfd6; border-radius: 3px; }
.note { background: var(--sky-2); border-left: 3px solid var(--navy); padding: 10px 12px; border-radius: 3px; font-size: 12.5px; }

/* auth */
.auth { height: 100vh; display: grid; place-items: center; background: linear-gradient(180deg, var(--navy) 0 38%, var(--bg) 38%); }
.auth form { background: #fff; width: 360px; padding: 28px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.15); }
.auth h1 { margin: 0 0 4px; color: var(--navy); font-size: 20px; display: flex; gap: 8px; align-items: center; }
.auth p { color: var(--muted); margin: 0 0 18px; }
.auth label { display: block; font-size: 12px; margin: 10px 0 4px; }
.auth input { width: 100%; padding: 9px 10px; border: 1px solid #c9cfd6; border-radius: 3px; }
.auth .btn { width: 100%; margin-top: 18px; padding: 10px; }
.err { color: var(--bad); font-size: 12px; min-height: 16px; margin-top: 8px; }

/* modal / toast / drop */
.modal-bg { position: fixed; inset: 0; background: rgba(12, 51, 89, .45); display: grid; place-items: center; z-index: 50; }
.modal { background: #fff; border-radius: 6px; width: min(520px, calc(100vw - 32px)); max-height: 86vh; overflow: auto; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal header { background: var(--sky); padding: 12px 16px; font-weight: 700; color: var(--navy); display: flex; justify-content: space-between; }
.modal .body { padding: 16px; }
.modal footer { padding: 12px 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.filelist { max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; margin: 8px 0 12px; font-size: 12px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #263238; color: #fff; padding: 10px 16px; border-radius: 4px; z-index: 60; max-width: 90vw; }
#dropOverlay { position: fixed; inset: 0; background: rgba(31, 184, 154, .18); border: 4px dashed var(--teal); z-index: 40; display: grid; place-items: center; font-size: 22px; color: var(--navy); font-weight: 700; }
#dropOverlay[hidden] { display: none; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .main { flex-direction: column; height: auto; }
  .sidebar, .doclist, .details { width: 100%; }
  .docbody { flex-direction: column; }
  .search { width: 160px; }
  .navtabs button { padding: 8px 6px; }
}

/* AI */
.btn-ai { background: linear-gradient(135deg, #7a62c9, #2b9fd8); border: 0; color: #fff; }
.btn-ai:hover { filter: brightness(1.08); }
.bell { position: relative; font-size: 17px; }
#bellCount { position: absolute; top: 0; right: -2px; background: #d64545; color: #fff; border-radius: 9px; font-size: 10px; padding: 0 5px; font-weight: 700; }
.tree .item .spark { margin-left: auto; visibility: hidden; background: none; border: 0; padding: 0 2px; font-size: 12px; }
.tree .item .lock + .spark { margin-left: 4px; }
.tree .item:hover .spark { visibility: visible; }
.aibar { background: var(--sky); padding: 2px 8px 6px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; gap: 6px; }
.aibar label { display: flex; gap: 4px; align-items: center; color: var(--navy); }
.card .sel { position: absolute; left: 4px; top: 4px; opacity: 0; }
.card:hover .sel, .card .sel:checked { opacity: 1; }
.exp { color: #8a5a00; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 12px; }
.preset { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.preset span { color: var(--muted); font-size: 11.5px; }
.preset.on { border-color: #7a62c9; background: #f5f2fd; box-shadow: 0 0 0 1px #7a62c9 inset; }
.modal textarea { width: 100%; min-height: 70px; padding: 8px; border: 1px solid #c9cfd6; border-radius: 3px; }
.report { padding: 20px 28px 40px; max-width: 1000px; }
.report-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 2px solid var(--navy); padding-bottom: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.report-head h1 { margin: 4px 0 0; font-size: 18px; color: var(--navy); }
.eyebrow { color: #7a62c9; font-size: 12px; font-weight: 600; }
.report-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.md { font-size: 13.5px; line-height: 1.6; }
.md h2, .md h3, .md h4 { color: var(--navy); margin: 18px 0 6px; }
.md table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.md td, .md th { border: 1px solid var(--line); padding: 5px 8px; text-align: left; font-size: 12.5px; vertical-align: top; }
.md th { background: var(--sky-2); }
.md .cite { font-size: 11.5px; color: #7a62c9; }
.srcs { margin-top: 20px; color: var(--muted); }
.srcs a { display: block; padding: 2px 0; }
.ai-loading { text-align: center; padding: 80px 20px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid #e0dcf5; border-top-color: #7a62c9; border-radius: 50%; animation: spin 0.9s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.aibox { background: #faf9fe; }
table.facts { width: 100%; border-collapse: collapse; font-size: 12px; }
table.facts td { border-bottom: 1px solid #eceaf5; padding: 3px 4px; vertical-align: top; }
table.facts td:first-child { color: var(--muted); width: 40%; }
.sform { display: grid; grid-template-columns: 180px minmax(0, 420px); gap: 8px 12px; align-items: center; margin: 10px 0; }
.sform input, .sform select { padding: 6px 8px; border: 1px solid #c9cfd6; border-radius: 3px; }
pre.cmd { white-space: pre-wrap; word-break: break-all; background: #0c3359; color: #e8f3fb; padding: 10px; border-radius: 4px; font-size: 11.5px; }
@media (max-width: 900px) { .sform { grid-template-columns: 1fr; } .presets { grid-template-columns: 1fr; } }

/* Artifacts ledger */
.ledger { padding: 20px 28px 50px; max-width: 1100px; }
.lg-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; border-bottom: 2px solid var(--navy); padding-bottom: 10px; }
.lg-head h1 { margin: 4px 0 2px; font-size: 19px; color: var(--navy); }
.lg-sub { color: var(--muted); font-size: 12.5px; }
.lg-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; }
.lg-tile { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.lg-tile b { font-size: 22px; color: var(--navy); }
.lg-tile span { font-size: 12px; color: var(--muted); }
.lg-tile.warn { border-color: #e8a317; background: #fffaf0; }
.lg-tile.bad { border-color: #d64545; background: #fff5f5; }
.lg-bar { height: 6px; background: #e6ebf0; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.lg-bar i { display: block; height: 100%; background: #0e9f86; border-radius: 3px; }
.lg-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.lg-filters input { margin-left: auto; padding: 6px 10px; border: 1px solid #c9cfd6; border-radius: 3px; min-width: 220px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.chip span { color: var(--muted); margin-left: 2px; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip.on span { color: #cfe3f3; }
.lg-req { background: #fff; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 12px; }
.lg-req > header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; }
.lg-req > header:hover { background: var(--sky); }
.lg-caret { color: var(--muted); width: 12px; }
.lg-id { background: var(--navy); color: #fff; font-weight: 700; font-size: 12px; border-radius: 4px; padding: 2px 7px; }
.lg-id.sm { background: #e6ebf0; color: var(--navy); font-size: 11px; }
.lg-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.lg-title b { color: var(--navy); }
.lg-title span { font-size: 12px; color: var(--muted); }
.lg-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.lg-body { padding: 4px 16px 14px 36px; border-top: 1px solid var(--line); }
.lg-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.lg-quote { margin: 0; padding: 10px 14px; background: #f6f8fb; border-left: 4px solid #2b9fd8; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; color: #1d2a36; }
.lg-item { border: 1px solid var(--line); border-radius: 5px; padding: 10px 12px; margin-bottom: 8px; }
.lg-item.reopened { border-color: #d64545; background: #fff7f7; }
.lg-item-top { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.lg-ask { flex: 1; font-weight: 600; color: var(--navy); min-width: 200px; }
.pill { font-size: 11px; font-weight: 600; border-radius: 10px; padding: 2px 8px; white-space: nowrap; }
.st-done { background: #e3f6f1; color: #0b7a67; }
.st-in_progress { background: #e5f1fb; color: #1f6fa8; }
.st-todo, .st-blocked { background: #eceff3; color: #4a5562; }
.st-waiting { background: #fff1d6; color: #8a5a00; }
.st-accept { background: #0e9f86; color: #fff; }
.st-reopen { background: #d64545; color: #fff; }
.lg-deliv { font-size: 13px; line-height: 1.5; margin: 6px 0 4px; }
.lg-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.lg-notes { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.lg-note { position: relative; background: #f7f6fd; border-radius: 4px; padding: 6px 28px 6px 10px; font-size: 12.5px; }
.lg-note.k-reopen { background: #fdecec; }
.lg-note.k-accept { background: #e3f6f1; }
.lg-note span { font-size: 11px; color: var(--muted); }
.lg-note p { margin: 3px 0 0; white-space: pre-wrap; }
.lg-x { position: absolute; top: 3px; right: 6px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.lg-actions { display: flex; gap: 6px; margin-top: 8px; }
.lg-form { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.lg-form textarea { width: 100%; min-height: 60px; padding: 8px; border: 1px solid #c9cfd6; border-radius: 3px; font: inherit; }
@media (max-width: 700px) { .ledger { padding: 14px 16px 40px; } .lg-body { padding-left: 16px; } .lg-filters input { margin-left: 0; min-width: 0; width: 100%; } }
@media print {
  .topbar, .no-print { display: none !important; }
  .main, .content, .scroll { overflow: visible !important; height: auto !important; display: block !important; }
  .lg-req, .lg-item { break-inside: avoid; }
}

/* Settings / admin (R7) */
.adm { display: flex; min-height: 100%; }
.adm-nav { width: 210px; flex: none; background: #f6f8fb; border-right: 1px solid var(--line); padding: 14px 0; display: flex; flex-direction: column; }
.adm-nav button { text-align: left; background: none; border: 0; padding: 9px 18px; font-size: 13.5px; color: var(--navy); cursor: pointer; border-left: 3px solid transparent; }
.adm-nav button:hover { background: var(--sky); }
.adm-nav button.on { background: #fff; border-left-color: var(--teal, #1fb89a); font-weight: 600; }
.adm-body { flex: 1; min-width: 0; padding: 18px 28px 50px; max-width: 1150px; }
.adm-body h2 { color: var(--navy); font-size: 17px; margin: 18px 0 8px; }
.adm-body h2:first-child { margin-top: 0; }
.adm-body h3 { color: var(--navy); font-size: 14px; margin: 18px 0 6px; }
.adm-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.adm-body td, .adm-body th { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
.adm-body th { background: var(--sky-2, #eef5fb); font-weight: 600; }
.adm-body tr.sugg td { background: #fffaf0; }
.warnbox { border-left: 4px solid #e8a317; background: #fffaf0; }
.bad { color: #b33; } .warnc { color: #8a5a00; }
.pwlist { list-style: none; padding: 0; margin: 6px 0; font-size: 12.5px; color: #6b7480; columns: 2; }
.pwlist li.ok { color: #0b7a67; font-weight: 600; }
.rule-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; align-items: end; background: #f6f8fb; padding: 12px; border-radius: 6px; }
.rule-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #4a5562; }
.rule-form select, .rule-form input { padding: 6px 8px; border: 1px solid #c9cfd6; border-radius: 3px; }
.refile a { color: var(--navy); font-weight: 600; }
.peekbox { max-height: 220px; overflow: auto; font-size: 12px; background: #f6f8fb; padding: 6px 8px; border-radius: 4px; }
.authbox { background: #fff; padding: 26px 30px; border-radius: 6px; box-shadow: 0 6px 30px rgba(0,0,0,.18); max-width: 560px; }
.authbox .sform { grid-template-columns: 140px 1fr; }
.hub-tabs { display: flex; gap: 4px; padding: 12px 28px 0; border-bottom: 1px solid var(--line); }
.hub-tabs button { background: none; border: 1px solid transparent; border-bottom: 0; padding: 8px 14px; border-radius: 6px 6px 0 0; color: var(--navy); cursor: pointer; font-size: 13.5px; }
.hub-tabs button.on { background: #fff; border-color: var(--line); font-weight: 600; margin-bottom: -1px; }
.dl-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; margin: 14px 0; }
.dl-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.dl-head h2 { margin: 0; font-size: 17px; color: var(--navy); }
.dl-meta { color: #6b7480; font-size: 12px; }
.dl-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.dl-actions input { padding: 6px 8px; border: 1px solid #c9cfd6; border-radius: 3px; }
.dl-card details { margin-top: 8px; font-size: 13px; }
.dl-card summary { cursor: pointer; color: var(--navy); font-weight: 600; }
.cl { margin: 8px 0 0 4px; } .cl ul { margin: 4px 0; padding-left: 20px; }
@media (max-width: 800px) { .adm { flex-direction: column; } .adm-nav { width: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0; } .adm-nav button { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; } .adm-nav button.on { border-bottom-color: var(--teal, #1fb89a); } .adm-body { padding: 14px 16px 40px; } .pwlist { columns: 1; } }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: grayscale(.4); }
.ledger table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.ledger td, .ledger th { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.ledger th { background: var(--sky-2, #eef5fb); }

/* Insights */
.chat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; min-height: 260px; max-height: 58vh; overflow: auto; margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.chat .msg { max-width: 85%; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.55; }
.chat .msg.user { align-self: flex-end; background: var(--navy); color: #fff; white-space: pre-wrap; }
.chat .msg.assistant { align-self: flex-start; background: #f5f2fd; }
.chat .msg.assistant table { border-collapse: collapse; margin: 6px 0; } .chat .msg.assistant td, .chat .msg.assistant th { border: 1px solid var(--line); padding: 3px 6px; font-size: 12.5px; }
.chat-form { display: flex; gap: 8px; } .chat-form textarea { flex: 1; padding: 8px; border: 1px solid #c9cfd6; border-radius: 4px; font: inherit; resize: vertical; }
.ent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.ent-card { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; text-decoration: none; color: var(--navy); }
.ent-card:hover { border-color: #2b9fd8; box-shadow: 0 1px 4px rgba(0,0,0,.08); } .ent-card span { color: #6b7480; font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; } @media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } .chat .msg { max-width: 100%; } }
.navcount{display:inline-block;min-width:16px;padding:0 5px;margin-left:4px;border-radius:8px;background:#e74c3c;color:#fff;font-size:11px;line-height:16px;text-align:center}
