/* Ledgr console. Builds on ledgr.css tokens. */
body.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; background: var(--bg); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* Sidebar */
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 14px; background: var(--green-deep); color: var(--on-green); }
.side :focus-visible { outline-color: var(--on-green); }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 24px; }
.side-brand span { font-family: var(--font-display); font-weight: 600; font-size: 25px; line-height: 1; letter-spacing: -.02em; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; font-size: 14.5px; color: var(--on-green-2); transition: background-color var(--t-fast) ease, color var(--t-fast) ease; }
@media (hover: hover) and (pointer: fine) { .side-nav a:hover { background: rgba(244,239,225,.06); color: var(--on-green); } }
.side-nav a[aria-current='page'] { background: rgba(244,239,225,.1); color: var(--on-green); }
.side-nav a[aria-current='page']::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: #E0705F; }
.side-badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--c-amt); color: var(--green-deep); font-size: 11px; display: grid; place-items: center; font-weight: 500; }
.side-badge-soft { background: rgba(244,239,225,.14); color: var(--on-green); }
.side-foot { margin-top: auto; display: grid; gap: 16px; padding: 0 6px; }
.side-org { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; background: rgba(244,239,225,.06); font-size: 13.5px; }
.side-muted { color: rgba(244,239,225,.6); font-size: 12px; }
.org-dot { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--on-green); color: var(--green-deep); font-size: 12px; }
.side-db { padding-left: 6px; color: var(--on-green-2); }

/* Main */
.main { min-width: 0; padding: 16px clamp(16px, 3vw, 36px) 40px; }
.demo-banner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 18px; border-radius: 8px; background: var(--amber-soft); color: var(--amber); font-size: 12px; }
.demo-banner a { text-decoration: underline; text-underline-offset: 3px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.top-kicker { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.top-title { font-family: var(--font-display); font-weight: 500; font-size: 42px; line-height: 1.05; letter-spacing: -.022em; font-variation-settings: 'opsz' 96; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.client-pick { position: relative; }
.client-pick select, .sel select, .rule-form select, .rule-form input {
  appearance: none; -webkit-appearance: none; height: 40px; padding: 0 34px 0 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); font-size: 14px; color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='m3 4.5 3 3 3-3' stroke='%2313261D' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}
.client-pick select { min-width: 260px; font-weight: 600; }
.rule-form input { background-image: none; padding-right: 12px; }
.client-pick select:focus-visible, .sel select:focus-visible, .rule-form select:focus-visible, .rule-form input:focus-visible { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,80,58,.18); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:active { transform: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 6px; }

.view[data-entering] { animation: viewIn 320ms var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }

.panel { padding: 18px 20px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h3 { font-size: 15px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.link-btn { font-size: 12.5px; color: var(--green); text-decoration: underline; text-underline-offset: 3px; margin-left: 8px; }
.acc { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--green); white-space: nowrap; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi { padding: 16px 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.kpi p { font-size: 13px; color: var(--muted); }
.kpi b { display: block; font-size: 30px; font-weight: 500; line-height: 1.25; letter-spacing: -.03em; margin: 4px 0 2px; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.kpi-warn b { color: var(--amber); }

/* Clients table */
.c-row { display: grid; grid-template-columns: minmax(0, 1.7fr) 150px 110px 110px 150px; gap: 14px; align-items: center; padding: 13px 10px; border-top: 1px solid var(--line); border-radius: 8px; }
.c-th { border-top: 0; padding-block: 6px; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
[data-client-rows] .c-row { cursor: pointer; transition: background-color 120ms ease; }
@media (hover: hover) and (pointer: fine) { [data-client-rows] .c-row:hover { background: var(--bg); } }
[data-client-rows] .c-row:focus-visible { outline-offset: -2px; }
.c-co b { display: block; font-weight: 600; font-size: 15px; }
.c-co i { display: block; font-style: normal; font-size: 12.5px; color: var(--muted); }
.c-num { font-size: 14px; }
.c-num small { display: none; font-family: var(--font-ui); font-size: 12px; color: var(--muted); }
.c-num.warn { color: var(--amber); }
.steps { display: inline-flex; gap: 4px; }
.steps i { width: 28px; height: 6px; border-radius: 2px; background: var(--bg-2); }
.steps i.on { background: var(--green); }
.stp { display: inline-block; font-style: normal; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 4px; white-space: nowrap; }
.stp-wait { border: 1px dashed var(--line-2); color: var(--muted); }
.stp-review { background: var(--amber-soft); color: var(--amber); }
.stp-ready { background: var(--green-soft); color: var(--green); }
.stp-done { background: var(--green); color: var(--on-green); }

/* Review */
.stmt-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.sb-file { display: flex; align-items: center; gap: 12px; color: var(--green); min-width: 0; }
.sb-file b { display: block; color: var(--ink); font-size: 14.5px; }
.sb-file span { display: block; font-size: 12px; color: var(--muted); }
.sb-sums { display: flex; gap: 26px; margin: 0; flex-wrap: wrap; }
.sb-sums dt { font-size: 11.5px; color: var(--muted); }
.sb-sums dd { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sb-wait { font-size: 14.5px; color: var(--ink-2); }
.prog { position: relative; width: 70px; height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.prog i { position: absolute; inset: 0; background: var(--green); transform-origin: left; transform: scaleX(var(--p)); transition: transform 500ms var(--ease-out); }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tool-r { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13.5px; font-weight: 500; transition: background-color var(--t-fast) ease, color var(--t-fast) ease, border-color var(--t-fast) ease, transform var(--t-press) var(--ease-out); }
.chip b { font-weight: 400; font-size: 12px; color: var(--muted); }
.chip-warn b { color: var(--amber); font-weight: 500; }
.chip[aria-pressed='true'] { background: var(--green-deep); color: var(--on-green); border-color: var(--green-deep); }
.chip[aria-pressed='true'] b { color: rgba(244,239,225,.72); }
.search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line-2); color: var(--muted); width: 260px; transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease; }
.search:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,80,58,.16); }
.search input { border: 0; outline: 0; background: none; width: 100%; font-size: 14px; color: var(--ink); }

.t-row { display: grid; grid-template-columns: 54px minmax(0, 1.5fr) 120px minmax(180px, 1fr) 104px 130px; gap: 12px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--line); transition: background-color 200ms ease; }
.t-th { border-top: 0; padding-block: 9px; background: var(--bg); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
[data-review-rows] .t-row:first-child { border-top: 0; }
.t-row[data-st='review'] { background: rgba(246,231,193,.28); box-shadow: inset 3px 0 0 var(--c-amt); }
.t-row[data-st='accepted'] { background: rgba(220,233,221,.35); }
.t-d { font-size: 12px; color: var(--muted); }
.t-n { min-width: 0; }
.t-n .mono { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-n small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-amt { font-size: 13px; white-space: nowrap; }
.t-amt small { margin-left: 4px; font-size: 10px; color: var(--muted); }
.t-amt.is-cr { color: var(--green); }
.t-h { min-width: 0; }
.sel { display: block; }
.sel select { width: 100%; height: 34px; font-size: 13.5px; font-weight: 600; padding-left: 10px; }
.sel-changed select { border-color: var(--green); background-color: var(--green-soft); }
.sel select:disabled { background-image: none; background-color: transparent; border-color: transparent; padding-left: 0; opacity: 1; color: var(--ink); }
.t-grp { display: block; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.t-c { display: flex; align-items: center; gap: 8px; }
.cbar { position: relative; width: 44px; height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; flex: none; }
.cbar i { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--v)); }
.cb-hi i { background: var(--c-ok); }
.cb-mid i { background: #8DB89E; }
.cb-lo i { background: var(--c-amt); }
.cval { font-size: 12.5px; }
.c-you { background: var(--green); color: var(--on-green); }
.t-a { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; }

/* Vouchers */
.export-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 16px 18px; margin-bottom: 12px; border-radius: 12px; background: var(--green-deep); color: var(--on-green); }
.export-bar .muted { color: var(--on-green-2); }
.export-bar :focus-visible { outline-color: var(--on-green); }
.eb-title { font-size: 16px; font-weight: 600; }
.eb-title b { font-weight: 500; }
.eb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.export-bar .btn-line { background: transparent; color: var(--on-green); border-color: rgba(244,239,225,.3); }
.export-bar .btn-green { background: var(--on-green); color: var(--green-deep); box-shadow: none; }
.xml-pre { margin: 0 0 12px; padding: 16px; max-height: 360px; overflow: auto; border-radius: 12px; background: #0B241B; color: #CFE3D6; font-size: 12px; line-height: 1.55; white-space: pre; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.vch { padding: 14px 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 10px; }
.vch header { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11.5px; }
.vt { font-size: 11px; padding: 2px 8px; border-radius: 4px; letter-spacing: .04em; }
.vt-payment { background: var(--red-soft); color: #8E2A20; }
.vt-receipt { background: var(--green-soft); color: var(--green); }
.vt-contra { background: var(--bg-2); color: var(--ink-2); }
.vlines { margin: 0; border-top: 1px solid var(--line); border-bottom: 3px double var(--line-2); }
.vlines div { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; padding: 7px 0; font-size: 14px; }
.vlines div + div { border-top: 1px solid var(--line); padding-left: 16px; grid-template-columns: 26px minmax(0, 1fr) auto; }
.vlines dt { color: var(--muted); font-size: 12px; padding-top: 2px; }
.vlines dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vlines dd.mono { font-size: 13px; }
.vnar { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* GST */
.buckets-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.bucket { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 8px; text-align: left; padding: 14px 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); transition: border-color var(--t-fast) ease, background-color var(--t-fast) ease, transform var(--t-press) var(--ease-out); }
.bucket .sw { width: 9px; height: 9px; }
.bucket span { font-size: 13.5px; font-weight: 600; grid-column: 2; }
.bucket .sw + span { grid-column: 2; }
.bucket b { grid-column: 1 / -1; font-size: 26px; font-weight: 500; line-height: 1.2; letter-spacing: -.03em; margin-top: 4px; }
.bucket small { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); }
.bucket[aria-pressed='true'] { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); background: #F9FBF6; }
@media (hover: hover) and (pointer: fine) { .bucket:hover { border-color: var(--line-2); } }
.g-row { display: grid; grid-template-columns: minmax(0, 1.25fr) 130px 104px 118px minmax(0, 1.5fr) 150px; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.g-th { border-top: 0; padding-block: 9px; background: var(--bg); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
[data-gst-rows] .g-row:first-child { border-top: 0; }
.g-row[data-followed] { opacity: .72; }
.g-s b { display: block; font-size: 14px; font-weight: 600; }
.g-s i { display: block; font-style: normal; font-size: 11.5px; color: var(--muted); }
.g-i { font-size: 12.5px; }
.g-i small { display: block; font-size: 11.5px; color: var(--muted); }
.g-b, .g-2 { font-size: 13px; }
.g-lab { display: none; }
.diff { display: block; font-size: 11.5px; color: var(--amber); }
.g-r small { display: block; margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }
.g-a { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; }

/* Rules */
.rules-top { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; margin-bottom: 12px; }
.thr-val { font-size: 22px; color: var(--green); }
.range { width: 100%; margin: 4px 0 10px; accent-color: var(--green); height: 24px; }
.lock-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 3px 9px; border-radius: 4px; background: var(--green-soft); color: var(--green); }
.rule-form { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) 130px auto; gap: 10px; align-items: end; padding: 14px; margin-bottom: 12px; border-radius: 10px; background: var(--bg); }
.rule-form label span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.rule-form input, .rule-form select { width: 100%; }
.r-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) 100px minmax(0, 1fr) 60px; gap: 12px; align-items: center; padding: 11px 6px; border-top: 1px solid var(--line); font-size: 14px; }
.r-th { border-top: 0; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-block: 6px; }
.r-m { font-size: 13px; }
.r-row b { font-weight: 600; }
.r-row[data-off] > span:not(:last-child) { opacity: .5; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--line-2); transition: background-color var(--t-fast) ease; }
.switch i { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform var(--t-ui) var(--ease-out); }
.switch[aria-checked='true'] { background: var(--green); }
.switch[aria-checked='true'] i { transform: translateX(16px); }

.demo-note { margin-top: 28px; display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.toasts { bottom: 20px; }

/* Responsive */
@media (max-width: 1320px) {
  .buckets-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-row { grid-template-columns: minmax(0, 1.2fr) 120px 100px 110px minmax(0, 1.4fr) 140px; }
  .t-row { grid-template-columns: 50px minmax(0, 1.3fr) 112px minmax(160px, 1fr) 96px 120px; }
}
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .c-row { grid-template-columns: minmax(0, 1.6fr) 110px 90px 90px 140px; }
  .g-th { display: none; }
  .g-row { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: 's b tb' 'i r r' 'a a a'; row-gap: 6px; }
  .g-s { grid-area: s; } .g-i { grid-area: i; } .g-b { grid-area: b; } .g-2 { grid-area: tb; } .g-r { grid-area: r; } .g-a { grid-area: a; justify-content: flex-start; }
  .g-a:empty { display: none; }
  .g-lab { display: inline; font-family: var(--font-ui); color: var(--muted); font-size: 11.5px; }
}
@media (max-width: 980px) {
  body.app { grid-template-columns: minmax(0, 1fr); padding-bottom: 76px; }
  .side { position: fixed; z-index: 60; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 30px -18px rgba(0,0,0,.5); }
  .side-brand, .side-foot { display: none; }
  .side-nav { grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
  .side-nav a { flex-direction: column; gap: 3px; padding: 7px 2px; font-size: 11.5px; }
  .side-nav a[aria-current='page']::before { left: 30%; right: 30%; top: -6px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .side-badge { position: absolute; top: 1px; left: calc(50% + 6px); margin: 0; min-width: 18px; height: 16px; font-size: 10px; }
  .toasts { bottom: 90px; left: 12px; right: 12px; }
  .toast { max-width: none; }
  .top-actions { width: 100%; }
  .client-pick { flex: 1; min-width: 0; }
  .client-pick select { width: 100%; min-width: 0; }
  .rules-top { grid-template-columns: minmax(0, 1fr); }
  .rule-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .r-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 50px; }
  .r-row > span:nth-child(3), .r-row > span:nth-child(4) { display: none; }

  .t-th { display: none; }
  .t-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'd a' 'n n' 'h h' 'c x'; row-gap: 8px; padding: 14px 16px; }
  .t-d { grid-area: d; }
  .t-n { grid-area: n; }
  .t-amt { grid-area: a; font-size: 15px; }
  .t-h { grid-area: h; }
  .t-c { grid-area: c; }
  .t-a { grid-area: x; }
  .t-n small { white-space: normal; }
}
@media (max-width: 720px) {
  .top-title { font-size: 34px; }
  .buckets-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .buckets-row .bucket:first-child { grid-column: 1 / -1; }
  .g-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 's s' 'i i' 'b tb' 'r r' 'a a'; }
  .g-b, .g-2 { text-align: left; }
  .c-th { display: none; }
  .c-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'co st' 'sp sp' 'rv is'; row-gap: 8px; padding: 14px 8px; }
  .c-row > :nth-child(1) { grid-area: co; } .c-row > :nth-child(2) { grid-area: sp; } .c-row > :nth-child(3) { grid-area: rv; text-align: left; } .c-row > :nth-child(4) { grid-area: is; } .c-row > :nth-child(5) { grid-area: st; }
  .c-num small { display: inline; }
  .steps i { width: 40px; }
  .search { width: 100%; }
  .tool-r { width: 100%; }
  .tool-r .btn { width: 100%; }
  .kpi b { font-size: 24px; }
  .kpi { padding: 14px; }
  .rule-form { grid-template-columns: minmax(0, 1fr); }
  .vgrid { grid-template-columns: minmax(0, 1fr); }
  .eb-actions, .eb-actions .btn { width: 100%; }
  .eb-actions .btn { flex: 1; }
  .stmt-bar { padding: 12px 14px; }
  .sb-sums { gap: 16px; }
}
