@font-face { font-family: 'Schibsted'; src: url(schibsted-grotesk-latin-wght-normal.woff2) format('woff2'); font-weight: 400 900; font-display: swap; }
@font-face { font-family: 'JBMono'; src: url(jetbrains-mono-latin-wght-normal.woff2) format('woff2'); font-weight: 100 800; font-display: swap; }

:root {
  --ink: #10232F;
  --ink-2: #3D4F5A;
  --muted: #6E7C83;
  --paper: #F2EEE5;
  --surface: #FBF9F4;
  --white: #FFFFFF;
  --line: #E0D8C8;
  --line-2: #CFC5B1;
  --coral: #E0553A;
  --coral-soft: #FBE4DC;
  --sea: #1C6873;
  --sea-soft: #DCEDEC;
  --ok: #2E7650;
  --ok-soft: #DDEFE3;
  --amber: #A86B12;
  --amber-soft: #F6EACB;
  --mono: 'JBMono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans: 'Schibsted', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
  display: flex; flex-direction: column;
}
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.mono, .num { font-family: var(--mono); font-feature-settings: 'zero' 0; }
.num { text-align: right; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip:focus { left: 8px; }
.link { background: none; border: 0; padding: 0; color: var(--sea); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* header */
.top {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 58px; background: var(--ink); color: var(--paper);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: #0B1A23; }
.logo { width: 32px; height: 32px; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.05; color: var(--paper); }
.brand-txt strong { font-size: 16px; font-weight: 750; letter-spacing: -0.01em; }
.brand-txt span { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #9FB0B8; }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tabs button {
  display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; cursor: pointer;
  color: #B8C5CB; padding: 8px 12px; border-radius: 8px; font-weight: 550;
}
.tabs button svg { width: 17px; height: 17px; }
.tabs button:hover { color: #fff; background: rgba(255,255,255,.06); }
.tabs button[aria-selected="true"] { color: #fff; background: rgba(255,255,255,.1); box-shadow: inset 0 -2px 0 var(--coral); }
.badge { font: 600 11px/1 var(--mono); background: var(--coral); color: #fff; padding: 3px 6px; border-radius: 99px; }
.badge:empty { display: none; }
.who { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.sync { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: #B8C5CB; }
.sync i { width: 7px; height: 7px; border-radius: 50%; background: #5BC48A; box-shadow: 0 0 0 3px rgba(91,196,138,.18); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #2A4351; font-size: 12px; font-weight: 650; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); background: var(--surface); }
.stat { padding: 11px 20px 12px; display: grid; grid-template-columns: auto 1fr; grid-template-areas: 'k k' 'v d'; column-gap: 10px; align-items: baseline; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .k { grid-area: k; font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }
.stat .v { grid-area: v; font: 600 24px/1.15 var(--mono); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .v.warn { color: var(--coral); }
.stat .d { grid-area: d; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .v.bump { animation: bump .6s var(--ease); }
@keyframes bump { 0% { color: var(--sea); transform: translateY(-2px); } 100% { transform: none; } }

main { flex: 1; min-height: 0; display: flex; overflow: auto; }
.view { flex: 1; min-width: 0; }
.view[hidden] { display: none !important; }

/* inbox view */
.view-inbox { display: grid; grid-template-columns: 330px minmax(0, 1fr) 410px; height: 100%; min-height: 0; }
.list { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.list-head h1 { font-size: 15px; font-weight: 700; }
.list-head p { margin: 3px 0 0; font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--sea); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(28,104,115,.45); } 70% { box-shadow: 0 0 0 7px rgba(28,104,115,0); } 100% { box-shadow: 0 0 0 0 rgba(28,104,115,0); } }
.mails { list-style: none; margin: 0; padding: 6px 0; overflow-y: auto; flex: 1; }
.mails li { overflow: hidden; }
.mails li.arrive { animation: arrive .7s var(--ease); }
@keyframes arrive { from { max-height: 0; opacity: 0; transform: translateY(-12px); } to { max-height: 140px; opacity: 1; transform: none; } }
.mail {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 11px 18px 12px 26px; display: grid; gap: 3px; position: relative; border-left: 3px solid transparent;
}
.mail:hover { background: #F4F0E7; }
.mail[aria-current="true"] { background: #EFE9DC; border-left-color: var(--ink); }
.mail .unread { position: absolute; left: 11px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); }
.mail .row1 { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.mail .from { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail .time { font: 12px var(--mono); color: var(--muted); }
.mail .subj { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.mail .row3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.att { display: inline-flex; align-items: center; gap: 6px; font: 11.5px var(--mono); color: var(--ink-2); background: var(--white); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px 2px 5px; }
.att svg { width: 13px; height: 13px; color: var(--coral); }
.pill { font-size: 11.5px; font-weight: 600; border-radius: 99px; padding: 2px 9px; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.pill.queued { background: #ECE7DC; color: var(--ink-2); }
.pill.extracting { background: var(--sea-soft); color: var(--sea); }
.pill.review { background: var(--coral-soft); color: #A63A22; }
.pill.ready { background: var(--sea-soft); color: var(--sea); }
.pill.posted { background: var(--ok-soft); color: var(--ok); }
.pill.returned { background: #E9E4F0; color: #57476E; }
.pill.extracting::before { content: ''; width: 9px; height: 9px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.list-foot { padding: 10px 18px 14px; font-size: 12.5px; border-top: 1px solid var(--line); margin: 0; }

/* document column */
.doc-col { display: flex; flex-direction: column; min-height: 0; background: #E7E1D4; }
.doc-bar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); background: #ECE6DA; min-height: 47px; }
.doc-bar .fname { font: 12.5px var(--mono); }
.doc-bar .meta { font-size: 12px; color: var(--muted); }
.doc-bar .back { display: none; }
.doc-bar .sp { flex: 1; }
.iconbtn { display: inline-flex; align-items: center; gap: 6px; background: var(--white); border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 9px; font-size: 12.5px; cursor: pointer; }
.iconbtn:hover { border-color: var(--ink-2); }
.iconbtn svg { width: 14px; height: 14px; }
.doc-scroll { flex: 1; overflow: auto; padding: 22px 18px 40px; }
.doc-fit { margin: 0 auto; position: relative; }
.doc-empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 40px; }
.doc-empty svg { width: 54px; height: 54px; color: var(--line-2); margin-bottom: 10px; }

/* invoice page (fixed size, scaled in JS) */
.page {
  width: 600px; background: #fff; color: #1d1d1d; position: absolute; left: 0; top: 0; transform-origin: 0 0;
  padding: 38px 40px 30px; box-shadow: 0 1px 2px rgba(16,35,47,.08), 0 10px 30px rgba(16,35,47,.12);
  font: 10.5px/1.4 var(--sans);
}
.page.scan { background: #F7F5EF; filter: grayscale(.85) contrast(1.05); }
.page.scan .pg-in { transform: rotate(-.7deg); }
.page .pg-in { position: relative; }
.pg-top { display: flex; justify-content: space-between; gap: 20px; }
.sup { display: flex; gap: 10px; }
.sup-mark { width: 38px; height: 38px; flex: none; }
.sup-name { font-weight: 750; font-size: 13.5px; letter-spacing: -0.01em; color: var(--sc); }
.sup small { display: block; color: #555; font-size: 9.5px; }
.doc-title { text-align: right; }
.doc-title .t { font-size: 20px; font-weight: 800; letter-spacing: .12em; color: var(--sc); }
.doc-title .n { font: 600 11.5px var(--mono); margin-top: 2px; }
.doc-title .orig { font-size: 8.5px; color: #777; text-transform: uppercase; letter-spacing: .08em; }
.pg-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 22px 0 14px; }
.box { border: 1px solid #ddd; border-radius: 4px; padding: 8px 10px; }
.box .lab { font-size: 8px; letter-spacing: .1em; text-transform: uppercase; color: #888; margin-bottom: 3px; }
.box b { font-size: 11px; }
.pg-meta { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid #ddd; border-radius: 4px; margin-bottom: 14px; }
.pg-meta div { padding: 6px 9px; border-right: 1px solid #ddd; }
.pg-meta div:last-child { border-right: 0; }
.pg-meta .lab { font-size: 8px; letter-spacing: .1em; text-transform: uppercase; color: #888; }
.pg-meta .val { font: 600 10.5px var(--mono); }
.pg-lines { width: 100%; border-collapse: collapse; }
.pg-lines th { font-size: 8px; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: var(--sc); text-align: left; padding: 5px 6px; font-weight: 600; }
.pg-lines td { padding: 5px 6px; border-bottom: 1px solid #eee; vertical-align: top; }
.pg-lines .r { text-align: right; font-family: var(--mono); font-size: 10px; white-space: nowrap; }
.pg-lines .c { font-family: var(--mono); font-size: 9.5px; color: #666; }
.pg-bottom { display: grid; grid-template-columns: 1fr 210px; gap: 18px; margin-top: 14px; align-items: start; }
.vat-tbl { width: 100%; border-collapse: collapse; }
.vat-tbl th { font-size: 8px; letter-spacing: .08em; text-transform: uppercase; color: #888; text-align: right; font-weight: 600; padding: 3px 6px; border-bottom: 1px solid #ddd; }
.vat-tbl th:first-child, .vat-tbl td:first-child { text-align: left; }
.vat-tbl td { font: 10px var(--mono); text-align: right; padding: 3px 6px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; font-size: 10.5px; }
.totals div span:last-child { font-family: var(--mono); }
.totals .grand { border-top: 2px solid var(--sc); margin-top: 4px; padding-top: 6px; font-weight: 800; font-size: 13px; }
.pg-foot { display: flex; gap: 14px; align-items: flex-end; margin-top: 22px; padding-top: 12px; border-top: 1px solid #eee; }
.qr { width: 64px; height: 64px; flex: none; }
.pg-foot .legal { font-size: 8.5px; color: #666; line-height: 1.5; }
.pg-foot .legal b { font-family: var(--mono); color: #222; font-weight: 600; }
.pg-pay { margin-top: 10px; font-size: 9px; color: #555; }

/* highlights on the document */
.hl { position: absolute; pointer-events: none; border-radius: 3px; border: 1.5px solid var(--sea); background: rgba(28,104,115,.1); opacity: 0; transition: all .28s var(--ease); z-index: 3; }
.hl.on { opacity: 1; }
.hl.bad { border-color: var(--coral); background: rgba(224,85,58,.12); }
.hl .tag { position: absolute; left: -1.5px; bottom: 100%; margin-bottom: 3px; font: 600 9.5px/1 var(--mono); color: #fff; background: var(--sea); padding: 3px 5px; border-radius: 3px; white-space: nowrap; }
.hl.bad .tag { background: var(--coral); }
.flag-mark { position: absolute; pointer-events: none; border-radius: 3px; background: rgba(224,85,58,.16); box-shadow: inset 0 0 0 1.5px var(--coral); z-index: 2; animation: fadein .4s var(--ease); }
@keyframes fadein { from { opacity: 0; } }
.scanbar { position: absolute; left: -6px; right: -6px; height: 70px; top: 0; z-index: 4; pointer-events: none;
  background: linear-gradient(180deg, rgba(28,104,115,0), rgba(28,104,115,.14) 70%, rgba(28,104,115,.6) 97%, rgba(28,104,115,0));
  animation: scan 1.1s var(--ease) forwards; }
@keyframes scan { from { transform: translateY(-70px); } to { transform: translateY(var(--h)); opacity: .2; } }

/* panel */
.panel { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; min-height: 0; padding-bottom: 36px; }
.p-head { padding: 16px 20px 14px; border-bottom: 1px solid var(--line); }
.p-head .l1 { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.p-head h2 { font-size: 17px; font-weight: 720; }
.p-head .l2 { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.steps { display: flex; gap: 0; margin-top: 14px; }
.steps li { list-style: none; flex: 1; font-size: 11px; color: var(--muted); position: relative; padding-top: 14px; }
.steps { padding: 0; margin-bottom: 0; }
.steps li::before { content: ''; position: absolute; top: 3px; left: 0; right: 0; height: 3px; background: var(--line); }
.steps li::after { content: ''; position: absolute; top: 0; left: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); }
.steps li.done { color: var(--ink); }
.steps li.done::before { background: var(--sea); }
.steps li.done::after { background: var(--sea); border-color: var(--sea); }
.steps li.bad::after { background: var(--coral); border-color: var(--coral); }
.steps li.bad::before { background: linear-gradient(90deg, var(--sea), var(--coral)); }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps li.now::after { border-color: var(--ink); }
.sec { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.sec h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 650; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.sec h3 .aside { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.field { text-align: left; background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px 8px; cursor: pointer; display: grid; gap: 1px; position: relative; min-width: 0; transition: border-color .2s, box-shadow .2s; }
.field.wide { grid-column: span 2; }
.field:hover, .field.act { border-color: var(--sea); box-shadow: 0 0 0 3px rgba(28,104,115,.1); }
.field .fl { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; }
.field .fv { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field .fv.mono { font-size: 12.5px; }
.conf { font: 600 10.5px var(--mono); color: var(--ok); display: inline-flex; align-items: center; gap: 5px; }
.conf i { width: 26px; height: 4px; border-radius: 2px; background: var(--line); position: relative; overflow: hidden; display: inline-block; }
.conf i b { position: absolute; inset: 0 auto 0 0; background: currentColor; border-radius: 2px; }
.conf.mid { color: var(--amber); }
.pend .fv { color: transparent; background: linear-gradient(90deg, #EEE9DF, #F7F4EE, #EEE9DF); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; border-radius: 4px; }
.pend .conf { opacity: 0; }
.field .fv, .field .conf { transition: color .25s, opacity .25s; }
@keyframes shimmer { to { background-position: -200% 0; } }
.vatgrid { display: grid; grid-template-columns: auto 1fr 1fr; gap: 2px 14px; font-size: 12.5px; }
.vatgrid span { font-family: var(--mono); text-align: right; }
.vatgrid .h { font: 11px var(--sans); color: var(--muted); text-align: right; }
.vatgrid .h:first-child, .vatgrid .rt { text-align: left; }
.match { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.match th { font-size: 10.5px; color: var(--muted); font-weight: 500; text-align: right; padding: 0 0 4px; }
.match th:first-child { text-align: left; }
.match td { padding: 6px 0; border-top: 1px solid var(--line); text-align: right; font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.match td:first-child { font-family: var(--sans); font-size: 12.5px; text-align: left; white-space: normal; padding-right: 8px; }
.match td.st { width: 22px; }
.match tr { cursor: pointer; }
.match tr:hover td { background: #F4F0E7; }
.match .bad { color: var(--coral); font-weight: 700; }
.match tr.pend td.st svg { opacity: 0; }
.ico { width: 15px; height: 15px; vertical-align: -3px; }
.exc { margin-top: 12px; border-radius: 9px; background: var(--coral-soft); border: 1px solid #F2B9A8; padding: 11px 12px; display: grid; gap: 4px; animation: fadein .4s var(--ease); cursor: pointer; text-align: left; width: 100%; }
.exc .t { display: flex; align-items: center; gap: 7px; font-weight: 700; color: #9B341E; }
.exc p { margin: 0; font-size: 12.5px; color: #5E2A1E; }
.banner { margin-top: 12px; width: 100%; text-align: left; border: 1px solid #F2B9A8; background: var(--coral-soft); color: #6B2A1B; border-radius: 9px; padding: 8px 11px; font-size: 12.5px; display: flex; gap: 8px; align-items: flex-start; cursor: pointer; animation: fadein .4s var(--ease); }
.banner b { color: #9B341E; }
.banner:hover { border-color: var(--coral); }
.okline { margin-top: 12px; border-radius: 9px; background: var(--ok-soft); color: #1F5A3B; padding: 10px 12px; font-size: 12.5px; display: flex; gap: 8px; align-items: flex-start; animation: fadein .4s var(--ease); }
.note { font-size: 13px; color: var(--ink-2); min-height: 40px; margin: 0; }
.note .cur { display: inline-block; width: 7px; height: 14px; background: var(--sea); vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.ai-tag { display: inline-flex; align-items: center; gap: 5px; color: var(--sea); }
.ai-tag svg { width: 13px; height: 13px; }
.actions { padding: 16px 20px 22px; display: grid; gap: 10px; }
.btn { border: 0; border-radius: 9px; padding: 11px 14px; font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #1B3747; }
.btn-ghost { background: var(--white); border: 1px solid var(--line-2); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sendback { display: grid; gap: 8px; animation: fadein .3s var(--ease); }
.sendback label { font-size: 12px; color: var(--muted); }
.sendback textarea { width: 100%; min-height: 108px; resize: vertical; border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 10px; font: 13px/1.45 var(--sans); background: #fff; color: var(--ink); }
.sendback textarea:focus { outline: 2px solid var(--sea); outline-offset: 0; }
.done-box { border-radius: 10px; padding: 12px 14px; display: grid; gap: 6px; font-size: 13px; }
.done-box.posted { background: var(--ok-soft); color: #1F5A3B; }
.done-box.returned { background: #EEEAF3; color: #3F3354; }
.done-box .t { font-weight: 700; display: flex; align-items: center; gap: 7px; }
.done-box blockquote { margin: 2px 0 0; padding: 8px 10px; border-left: 3px solid #A898BE; background: rgba(255,255,255,.55); border-radius: 0 6px 6px 0; font-size: 12.5px; }
.jl { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.jl td { padding: 3px 0; border-top: 1px solid rgba(31,90,59,.15); }
.jl td.num { font-size: 11.5px; }
.empty-panel { padding: 40px 24px; color: var(--muted); text-align: center; }

/* flow */
.view-flow { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0; align-self: stretch; }
.flow-main { padding: 22px 26px; min-width: 0; }
.flow-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 10px; }
.flow-head h2 { font-size: 20px; }
.flow-head p { margin: 4px 0 0; max-width: 62ch; }
.flow-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.flow-legend i { display: inline-block; width: 16px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.lg-ok { background: var(--sea); }
.lg-ex { background: var(--coral); }
.flow-canvas { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; background-image: radial-gradient(#DDD5C5 1px, transparent 1px); background-size: 18px 18px; }
#flowSvg { width: 100%; height: auto; display: block; }
.fnode rect.b { fill: #fff; stroke: var(--line-2); stroke-width: 1.2; }
.fnode.hot rect.b { stroke: var(--sea); stroke-width: 2; }
.fnode.hot.ex rect.b { stroke: var(--coral); }
.fnode .nl { font: 650 13px var(--sans); fill: var(--ink); }
.fnode .ns { font: 11px var(--sans); fill: var(--muted); }
.fnode .nc { font: 600 22px var(--mono); fill: var(--ink); letter-spacing: -0.03em; }
.fnode .nq { font: 600 10.5px var(--mono); fill: var(--coral); }
.fnode .ic { stroke: var(--sea); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fnode .icbg { fill: var(--sea-soft); }
.fnode.ex .ic { stroke: var(--coral); }
.fnode.ex .icbg { fill: var(--coral-soft); }
.fedge { fill: none; stroke: #B9C9CB; stroke-width: 2; }
.fedge.ex { stroke: #EDB3A4; stroke-dasharray: 5 4; }
.fedge-flow { fill: none; stroke: var(--sea); stroke-width: 2; stroke-dasharray: 2 10; stroke-linecap: round; opacity: .55; animation: dash 1.2s linear infinite; }
.fedge-flow.ex { stroke: var(--coral); }
@keyframes dash { to { stroke-dashoffset: -24; } }
.elabel { font: 600 10.5px var(--sans); fill: var(--muted); }
.elabel-bg { fill: var(--surface); }
.token { fill: var(--sea); }
.token.ex { fill: var(--coral); }
.flow-side { border-left: 1px solid var(--line); background: var(--surface); padding: 20px; display: grid; gap: 16px; align-content: start; }
.card h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 8px; }
.rules { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 13px; }
.rules li { padding-left: 14px; position: relative; color: var(--ink-2); }
.rules li::before { content: ''; position: absolute; left: 0; top: 7px; width: 6px; height: 6px; border-radius: 1px; background: var(--sea); }
.rules b { color: var(--ink); }
.log { list-style: none; margin: 0; padding: 0; font: 11.5px/1.5 var(--mono); display: grid; gap: 5px; max-height: 330px; overflow: hidden; }
.log li { display: grid; grid-template-columns: 62px 1fr; gap: 6px; color: var(--ink-2); animation: fadein .4s var(--ease); }
.log li time { color: var(--muted); }
.log li.ex span { color: #A63A22; }

/* ledger */
.view-ledger { padding: 22px 26px 40px; }
.ledger-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 14px; }
.ledger-head h2 { font-size: 20px; }
.ledger-head p { margin: 4px 0 0; }
.ledger-sum { display: flex; gap: 22px; font-size: 12px; color: var(--muted); }
.ledger-sum b { display: block; font: 600 17px var(--mono); color: var(--ink); }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ledger { width: 100%; border-collapse: collapse; font-size: 13px; }
.ledger th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.ledger th.num { text-align: right; }
.ledger td { padding: 10px 14px; border-bottom: 1px solid #EFEAE0; }
.ledger tr.row { cursor: pointer; }
.ledger tr.row:hover td { background: #FAF7F1; }
.ledger tr.row[aria-expanded="true"] td { background: #F6F2EA; }
.ledger tr.fresh td { animation: freshrow 2.4s var(--ease); }
@keyframes freshrow { 0% { background: var(--sea-soft); } 100% { background: transparent; } }
.ledger .je { font: 600 12px var(--mono); }
.ledger .sub { display: block; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.erp { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.erp.ok { color: var(--ok); }
.erp.wait { color: var(--sea); }
.erp.wait::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
.ledger tr.lines td { background: #F6F2EA; padding: 2px 14px 14px; }
.ledger tr.lines table { width: 100%; max-width: 640px; border-collapse: collapse; font-size: 12.5px; }
.ledger tr.lines table td { background: none; padding: 5px 8px; border-bottom: 1px dashed #DCD4C4; }
.ledger tr.lines th { background: none; border: 0; padding: 6px 8px 3px; }

/* toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 40; }
.toast { background: var(--ink); color: #fff; border-radius: 10px; padding: 11px 14px; font-size: 13px; max-width: 340px; box-shadow: 0 10px 30px rgba(16,35,47,.3); display: flex; gap: 9px; align-items: flex-start; animation: toastin .4s var(--ease); }
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: #7FD3A4; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .3s; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }

.ribbon { position: fixed; left: 12px; bottom: 12px; z-index: 45; font: 600 11px/1 var(--sans); letter-spacing: .02em; color: var(--ink-2); background: rgba(251,249,244,.92); border: 1px solid var(--line-2); padding: 6px 9px; border-radius: 99px; text-decoration: none; }
.ribbon:hover { color: var(--ink); border-color: var(--ink-2); }

/* responsive */
@media (max-width: 1240px) {
  .view-inbox { grid-template-columns: 290px minmax(0, 1fr) 370px; }
  .sync { display: none; }
}
@media (max-width: 1000px) {
  .view-flow { grid-template-columns: 1fr; }
  .flow-side { border-left: 0; border-top: 1px solid var(--line); grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  body { height: auto; min-height: 100vh; overflow: visible; }
  main { overflow: visible; display: block; }
  .top { padding: 0 12px; gap: 10px; height: 54px; }
  .brand-txt span { display: none; }
  .logo { width: 30px; height: 30px; }
  .tabs { margin-left: 0; gap: 0; }
  .tabs button { padding: 8px 8px; font-size: 13px; gap: 5px; }
  .tabs button svg { display: none; }
  .who { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 8px 14px 9px; border-bottom: 1px solid var(--line); }
  .stat:nth-child(2n) { border-right: 0; }
  .stat:nth-child(n+3) { border-bottom: 0; }
  .stat .v { font-size: 19px; }
  .stat .d { display: none; }
  .view-inbox { display: block; height: auto; min-height: 0; }
  .list { border-right: 0; }
  .ribbon { position: static; display: block; width: max-content; margin: 18px auto 22px; }
  .actions { padding-bottom: 24px !important; }
  .flow-side, .view-ledger { padding-bottom: 20px !important; }
  .show-s { display: block !important; }
  .flow-cards { grid-template-columns: 1fr !important; }
  .table-wrap { overflow-x: auto; }
  .mails { overflow: visible; }
  .doc-col, .panel { display: none; }
  body.detail .list { display: none; }
  body.detail .doc-col, body.detail .panel { display: flex; }
  body.detail .panel { display: block; border-left: 0; }
  body.detail .stats { display: none; }
  .doc-col { min-height: 0; }
  .doc-bar { padding: 8px 12px; position: sticky; top: 54px; z-index: 5; }
  .doc-bar .back { display: inline-flex; }
  .doc-bar .meta, .doc-bar .hide-s { display: none; }
  .doc-scroll { padding: 14px 12px 18px; overflow: visible; }
  .p-head, .sec, .actions { padding-left: 16px; padding-right: 16px; }
  .actions { padding-bottom: 60px; }
  .flow-main { padding: 16px 14px; }
  .flow-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .flow-head h2, .ledger-head h2 { font-size: 18px; }
  .flow-canvas { padding: 6px; }
  .flow-side { grid-template-columns: 1fr; padding: 16px 14px 60px; }
  .view-ledger { padding: 16px 12px 60px; }
  .ledger-head { flex-direction: column; align-items: flex-start; }
  .ledger .hide-s { display: none; }
  .ledger th, .ledger td { padding: 9px 10px; }
  .ledger { font-size: 12.5px; }
  .toasts { left: 12px; right: 12px; bottom: 48px; }
  .toast { max-width: none; }
}
@media (max-width: 380px) {
  .tabs button { padding: 8px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .scanbar, .fedge-flow { display: none; }
}

.show-s { display: none; }
.flow-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.fc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 16px; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.bars li { display: grid; grid-template-columns: 170px 1fr 28px; gap: 10px; align-items: center; font-size: 12.5px; color: var(--ink-2); }
.bars i { height: 8px; background: #ECE6DA; border-radius: 4px; overflow: hidden; display: block; }
.bars b { display: block; height: 100%; background: var(--coral); opacity: .75; border-radius: 4px; transition: width .5s var(--ease); }
.bars li.hot b { opacity: 1; }
.bars em { font: 600 12px var(--mono); font-style: normal; text-align: right; color: var(--ink); }
.ttp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ttp div { display: grid; gap: 2px; }
.ttp b { font: 600 22px var(--mono); letter-spacing: -0.03em; }
.ttp div:last-child b { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.ttp span { font-size: 12px; color: var(--muted); }
@media (max-width: 420px) { .bars li { grid-template-columns: 1fr 70px 24px; } }
