:root { --bg:#f4f5f7; --card:#fff; --line:#d9dce1; --txt:#1c2330; --muted:#69727f; --pri:#1b6e3c; --pri-d:#14532d; --err:#b42318; --warn:#b54708; --ok:#067647; --blue:#175cd3; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--txt); background: var(--bg); }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 6px 10px; color: var(--txt); }
button:hover:not(:disabled) { border-color: #9aa3b0; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--pri); border-color: var(--pri); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--pri-d); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover:not(:disabled) { background: #e9ebef; border-color: transparent; }
button.danger { color: var(--err); }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--txt); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #8fc7a3; border-color: var(--pri); }
input.bad, select.bad { border-color: var(--err); }
label { display: block; font-size: 12px; color: var(--muted); }
label > input, label > select, label > textarea, label > .combo { margin-top: 2px; color: var(--txt); font-size: 14px; }
.muted { color: var(--muted); }
.err { color: var(--err); }
.badge { background: var(--pri); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.badge.warn { background: var(--warn); } .badge.err { background: var(--err); } .badge.gray { background: #8a93a0; } .badge.blue { background: var(--blue); }

.login { height: 100%; display: grid; place-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.login .card { width: 320px; display: grid; gap: 12px; }
.login h1 { margin: 0 0 4px; font-size: 20px; }

#app { height: 100%; display: grid; grid-template-rows: auto 1fr; position: relative; }
.top { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: #fff; border-bottom: 1px solid var(--line); }
.top select { width: auto; }
.brand { margin-right: 6px; }
.title { font-weight: 600; margin-left: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }
.spacer { flex: 1; }
.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); min-height: 0; }
.left, .right { min-height: 0; display: flex; flex-direction: column; }
.right { overflow: auto; border-left: 1px solid var(--line); background: var(--bg); padding: 12px; gap: 10px; }
.viewerbar { display: flex; gap: 4px; align-items: center; padding: 4px 8px; background: #fff; border-bottom: 1px solid var(--line); }
.viewer { flex: 1; overflow: auto; background: #6b7280; padding: 12px; }
.viewer .empty, .right .empty { color: #e5e7eb; text-align: center; margin-top: 20vh; }
.right .empty { color: var(--muted); }
.pagewrap { margin: 0 auto 4px; position: relative; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); width: fit-content; }
.pagewrap canvas { display: block; }
.viewer img.scan { display: block; margin: 0 auto; background: #fff; max-width: none; }
.splitbar { margin: 0 auto 10px; width: fit-content; min-width: 260px; text-align: center; }
.splitbar > button { background: rgba(255,255,255,.92); border: 2px dashed var(--pri); color: var(--pri-d); font-weight: 600; width: 100%; }
.splitbar > button:hover { background: #fff; border-style: solid; }
.splitbtn { border-color: var(--pri); color: var(--pri-d); font-weight: 600; }
.viewerbar .spacer { flex: 1; }
.splitbar .confirm { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; gap: 6px; text-align: left; font-size: 13px; }
.splitbar .confirm .row { display: flex; gap: 6px; }
.splitbar .confirm .row button { flex: 1; }

.drawer { position: absolute; top: 44px; left: 0; bottom: 0; width: 420px; max-width: 95vw; background: #fff; border-right: 1px solid var(--line); z-index: 20; display: flex; flex-direction: column; box-shadow: 4px 0 12px rgba(0,0,0,.15); }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; border: 0; border-radius: 0; border-bottom: 2px solid transparent; background: transparent; }
.tabs button.on { border-bottom-color: var(--pri); font-weight: 600; }
.list { overflow: auto; flex: 1; }
.item { padding: 8px 12px; border-bottom: 1px solid #eceef1; cursor: pointer; display: grid; gap: 2px; }
.item:hover { background: #f4f9f6; } .item.cur { background: #e6f2ea; }
.item .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.list .none { padding: 20px; color: var(--muted); text-align: center; }

.sec { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 10px; }
.sec h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid5 { display: grid; grid-template-columns: 0.8fr 0.9fr 1fr 0.8fr 1fr; gap: 8px; }
.row { display: flex; gap: 8px; align-items: end; }
.row > * { flex: 1; }
.row > .fit { flex: 0 0 auto; }
.pos { border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: grid; gap: 8px; background: #fbfcfd; }
.pos .head { display: flex; gap: 8px; align-items: end; }
.pos .head > label { flex: 1; }
.pos .net { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; padding: 7px 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 6px; max-height: 260px; overflow: auto; box-shadow: 0 6px 18px rgba(0,0,0,.18); min-width: 260px; }
.combo-list div { padding: 6px 8px; cursor: pointer; display: flex; gap: 8px; justify-content: space-between; }
.combo-list div small { color: var(--muted); }
.combo-list div.on, .combo-list div:hover { background: #e6f2ea; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { border-radius: 14px; padding: 3px 10px; background: #eaf3ee; border-color: #bcd9c8; font-size: 12px; }
.sum { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-variant-numeric: tabular-nums; }
.sum .k { color: var(--muted); } .sum .v { text-align: right; }
.sum .tot { font-weight: 700; border-top: 1px solid var(--line); padding-top: 3px; }
.diff.ok { color: var(--ok); font-weight: 600; } .diff.bad { color: var(--err); font-weight: 600; }
.taxrow { display: grid; grid-template-columns: 0.7fr 1fr 1.4fr; gap: 8px; align-items: end; }
.banner { border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.banner.warn { background: #fff4e5; border: 1px solid #f5c98b; color: #7a3c00; }
.banner.err { background: #fdecea; border: 1px solid #f3a9a2; color: #7a1a12; }
.banner.ok { background: #e8f6ee; border: 1px solid #a8d8bc; color: #0b4f2f; }
.banner.info { background: #eaf1fe; border: 1px solid #b7cdf5; color: #123a8a; }
.banner a { color: inherit; font-weight: 600; }
.todo { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 2px; }
.actions .spacer { flex: 1; }
.saved { font-size: 12px; color: var(--muted); }
details.log { font-size: 12px; color: var(--muted); }
details.log table { border-collapse: collapse; width: 100%; } details.log td { padding: 2px 6px 2px 0; vertical-align: top; }
.toasts { position: fixed; right: 12px; bottom: 12px; display: grid; gap: 6px; z-index: 50; }
.toast { background: #1c2330; color: #fff; padding: 8px 12px; border-radius: 8px; max-width: 420px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.toast.err { background: var(--err); }
.drophint { position: absolute; inset: 44px 0 0 0; background: rgba(27,110,60,.85); color: #fff; font-size: 24px; display: grid; place-items: center; z-index: 40; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 16px; width: 360px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { display: grid; gap: 10px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; grid-template-rows: 45vh 1fr; } .right { border-left: 0; border-top: 1px solid var(--line); } }

.xmlview { background: #fff; max-width: 820px; margin: 0 auto; padding: 24px 28px; box-shadow: 0 1px 4px rgba(0,0,0,.4); font-size: 13px; }
.xmlview h2 { margin: 0 0 12px; font-size: 18px; }
.xmlview table { border-collapse: collapse; width: 100%; margin-bottom: 14px; }
.xmlview .kv th { text-align: left; color: var(--muted); font-weight: 500; width: 110px; padding: 2px 8px 2px 0; vertical-align: top; }
.xmlview .kv td { padding: 2px 0; }
.xmlview .lines th, .xmlview .lines td { border-bottom: 1px solid #e5e7eb; padding: 5px 6px; text-align: left; vertical-align: top; }
.xmlview .lines th { color: var(--muted); font-weight: 500; font-size: 12px; }
.xmlview .sums { width: auto; margin-left: auto; }
.xmlview .sums th { width: auto; padding-right: 24px; }
.xmlview .sums td { text-align: right; font-variant-numeric: tabular-nums; }
