:root {
  --bg: #f4f6f9; --surface: #fff; --line: #dfe4ec; --line-soft: #edf0f5;
  --text: #1a2433; --muted: #64708a; --side: #14213a; --side-text: #c5cee0;
  --brand: #1d5fd1; --brand-dark: #174ca8; --ok: #17794a; --ok-bg: #e4f5ec;
  --err: #b3261e; --err-bg: #fdeceb; --warn-bg: #fff6dc; --warn-line: #e9cf7a;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--text); background: var(--bg); line-height: 1.45; }
h1 { font-size: 1.45rem; margin: 0; font-weight: 600; }
h2 { font-size: 1.05rem; margin: 0 0 .4rem; font-weight: 600; }
h2.section { margin: 1.6rem 0 .6rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }
[hidden] { display: none !important; }

/* frame */
body.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 1rem .7rem 2rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: block; color: #fff; font-size: 1.35rem; font-weight: 700; letter-spacing: .01em; padding: .2rem .6rem 1rem; }
.brand:hover { text-decoration: none; }
.brand.dark { color: var(--side); padding-left: 0; }
.side nav a { display: block; color: var(--side-text); padding: .42rem .6rem; border-radius: 6px; }
.side nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.side nav a.on { background: var(--brand); color: #fff; }
.nav-group { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #7f8cab; padding: 1rem .6rem .3rem; }
.main { min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--surface); border-bottom: 1px solid var(--line); padding: .6rem 1.6rem; position: sticky; top: 0; z-index: 5; }
.top .company strong { font-size: 1.02rem; }
.top .company .link { margin-left: .6rem; font-size: .87rem; }
.top-right { display: flex; align-items: center; gap: .9rem; }
main { padding: 1.4rem 1.6rem 3rem; max-width: 1280px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* plain pages */
body.plain { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.card.narrow { width: 100%; max-width: 400px; padding: 1.8rem; }
.card.narrow h1 { margin-bottom: .8rem; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font: inherit; font-weight: 500; padding: .45rem .9rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f4f9; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--err); border-color: #e7b5b1; }
.btn.danger:hover { background: var(--err-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: .22rem .6rem; font-size: .87rem; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input, select { font: inherit; color: inherit; padding: .42rem .55rem; border: 1px solid #c9d1de; border-radius: 6px; background: #fff; max-width: 100%; }
input[readonly] { background: #f1f4f9; color: var(--muted); }
input.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
input.short { width: 8rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .87rem; color: var(--muted); font-weight: 500; }
label input, label select { color: var(--text); font-weight: 400; font-size: 1rem; }
label.check { flex-direction: row; align-items: center; gap: .45rem; color: var(--text); font-size: .95rem; font-weight: 400; margin: .3rem 0; }
.hint { font-weight: 400; font-size: .8rem; }
form.inline { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.toggle button { font: inherit; font-size: .87rem; border: 0; background: var(--surface); color: var(--muted); padding: .3rem .7rem; cursor: pointer; }
.toggle button.on { background: var(--brand); color: #fff; cursor: default; font-weight: 600; }
.toggle button:not(.on):hover { background: #f1f4f9; color: var(--text); }
.user { font-weight: 500; }

/* blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
details.card { margin-bottom: 1rem; }
details.card summary { cursor: pointer; font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.narrow-form { max-width: 420px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.1rem; max-width: 860px; }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: none; align-items: end; }
.form-grid .wide { grid-column: 1 / -1; }
.inline-form { display: flex; align-items: flex-end; gap: .8rem; flex-wrap: wrap; }
.toolbar { display: flex; align-items: flex-end; gap: .9rem; flex-wrap: wrap; margin: 0 0 .9rem; }
.toolbar label { flex-direction: row; align-items: center; gap: .4rem; }
.toolbar .grow, .grow { flex: 1 1 14rem; }
.toolbar .grow input { flex: 1; }
.grid { display: grid; gap: 1rem; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin: 1rem 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.6rem; }
.company-card.current { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.company-card .btn { margin-top: .4rem; }
.stat { display: flex; flex-direction: column; color: var(--muted); }
.stat:hover { text-decoration: none; border-color: var(--brand); }
.stat .n { font-size: 1.7rem; font-weight: 650; color: var(--text); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem 1.2rem; margin-bottom: 1rem; }
.facts .wide { grid-column: 1 / -1; }
.facts span { display: block; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.empty { color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 1.4rem; text-align: center; }
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: #b5dfc8; color: #0f5a36; }
.flash.err { background: var(--err-bg); border-color: #f1bfbb; color: #8c1d17; }
.notice { background: #eaf1fd; border: 1px solid #bfd3f6; border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.tag { display: inline-block; font-size: .78rem; font-weight: 600; padding: .12rem .55rem; border-radius: 99px; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.off { background: #eceff4; color: #5b6578; }
.tag.draft { background: #fff1d6; color: #8a5a00; }
.danger-zone { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.form-actions { display: flex; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
.equiv { align-self: center; padding-bottom: .5rem; }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8f9fc; padding: .55rem .8rem; border-bottom: 1px solid var(--line); font-weight: 600; }
.table td { padding: .5rem .8rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfe; }
.table.compact td { padding: .3rem .8rem; }
.table tfoot td { font-weight: 600; background: #f8f9fc; border-top: 1px solid var(--line); border-bottom: 0; }
.table td.code { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.group td { font-weight: 600; }
.table tr.title td { font-weight: 650; background: #f1f4f9; }
.table tr.total td { font-weight: 600; border-top: 1px solid var(--line); }
.table tr.total.grand td { border-top: 2px solid var(--text); border-bottom: 2px solid var(--text); font-size: 1.02rem; }
.d1 { padding-left: 1.7rem !important; } .d2 { padding-left: 2.6rem !important; } .d3 { padding-left: 3.5rem !important; }
.d4 { padding-left: 4.4rem !important; } .d5 { padding-left: 5.3rem !important; } .d6 { padding-left: 6.2rem !important; }
.narrow-report { max-width: 820px; }
.table.report td.code { width: 7.5rem; }
.report-head { display: none; }
.good { color: var(--ok); } .bad { color: var(--err); }

/* voucher lines */
.entry .card { margin-bottom: 1rem; }
.table.lines td { padding: .25rem .35rem; }
.table.lines input { width: 100%; border-color: transparent; background: transparent; }
.table.lines input:hover { border-color: var(--line); }
.table.lines input:focus { border-color: var(--brand); background: #fff; }
.table.lines tfoot td { padding: .5rem .8rem; }
.w-acc { width: 34%; } .w-amt { width: 14%; } .w-x { width: 2.6rem; }

@media (max-width: 860px) {
  body.app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: .5rem .7rem .6rem; }
  .side nav { display: flex; flex-wrap: wrap; gap: .15rem; }
  .side nav a { padding: .28rem .55rem; font-size: .87rem; }
  .nav-group { display: none; }
  .brand { padding-bottom: .35rem; }
  .top { position: static; padding: .6rem .9rem; }
  main { padding: 1rem .9rem 2rem; }
  .form-grid, .form-grid.four { grid-template-columns: 1fr; }
}

@media print {
  body.app { display: block; background: #fff; }
  .side, .top, .actions, .no-print, .toolbar, .danger-zone, .flash, details.card { display: none !important; }
  main { padding: 0; max-width: none; }
  .page-head { display: none; }
  .report-head { display: flex; flex-direction: column; align-items: center; margin-bottom: .8rem; }
  .report-head strong { font-size: 1.15rem; }
  .table, .card { border: 0; }
  .table th, .table tfoot td, .table tr.title td { background: #fff; }
  a { color: inherit; }
  html { font-size: 11px; }
}

/* documents */
.tag.bad { background: var(--err-bg); color: var(--err); }
.upload-form { margin-top: .9rem; }
.row-actions { white-space: nowrap; text-align: right; }
.share { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.share input { flex: 1 1 22rem; font-size: .87rem; background: #f8f9fc; }
.inline-form .full { flex-basis: 100%; margin: 0; }
ul.plain { margin: .4rem 0 0; padding-left: 1.1rem; }
ul.plain li { margin: .15rem 0; }

/* icons */
.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; }
.side nav a { display: flex; align-items: center; gap: .55rem; }
.side nav a .ic { width: 1.1rem; height: 1.1rem; opacity: .85; }
.side nav a.on .ic { opacity: 1; }
.launch { display: grid; gap: 1.1rem; margin: 1rem 0 1.5rem; }
.launch h2 { font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .5rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: .7rem; }
.tile { display: flex; flex-direction: column; align-items: center; gap: .55rem; text-align: center; padding: 1.05rem .6rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); font-size: .9rem; line-height: 1.25; }
.tile .ic { width: 2.1rem; height: 2.1rem; stroke-width: 1.5; color: var(--brand); }
.tile:hover { border-color: var(--brand); background: #f6f9ff; text-decoration: none; }
.tile.strong { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.tile.strong .ic { color: #fff; }
.tile.strong:hover { background: var(--brand-dark); }
@media print { .launch { display: none; } }

/* opening balances */
.table.opening td { padding: .2rem .5rem; }
.table.opening input { width: 100%; padding: .25rem .4rem; }
.table.opening .w-amt { width: 11rem; }
.sticky-totals { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem 1rem; display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; margin-top: .8rem; box-shadow: 0 -4px 14px rgba(20, 33, 58, .08); }
.sticky-totals .n { font-variant-numeric: tabular-nums; font-weight: 650; }
.sticky-totals .spacer { flex: 1; }

/* banks */
.bank-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.bank-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .35rem; }
.bank-card.off { opacity: .6; }
.bank-card .bal { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.bank-card .links { display: flex; gap: .9rem; flex-wrap: wrap; margin-top: .3rem; font-size: .9rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.words { font-weight: 600; letter-spacing: .01em; }
.signatures { display: none; }
.recon-sum { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1.5rem; max-width: 34rem; font-variant-numeric: tabular-nums; }
.recon-sum .n { text-align: right; }
.recon-sum .total { font-weight: 650; border-top: 1px solid var(--line); padding-top: .3rem; }
.table.recon td.tick { width: 2.4rem; text-align: center; }
.table.recon tr.cleared td { color: var(--muted); }
@media print {
  .signatures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2rem; margin-top: 4.5rem; text-align: center; }
  .signatures div { border-top: 1px solid #000; padding-top: .3rem; }
  .bank-cards, .btn-row { display: none; }
}

/* clients and suppliers */
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.split .card { margin: 0; }
.split h2 { margin-top: 0; }
.big { font-size: 1.3rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.late { color: var(--err); font-weight: 600; }
.table.pay input { width: 100%; padding: .25rem .4rem; }
@media print { .split .btn-row { display: none; } }

/* payroll */
.table.payroll { font-size: .88rem; }
.table.payroll td, .table.payroll th { padding: .3rem .45rem; white-space: nowrap; }
.table.payroll td.name { white-space: normal; min-width: 11rem; }
.table.payroll input { width: 6.6rem; padding: .22rem .35rem; }
.table.payroll input.hrs { width: 4.2rem; }
.table.payroll .sep { border-left: 2px solid var(--line); }
.scroll-x { overflow-x: auto; }
.slips { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 1rem; }
.slip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; break-inside: avoid; }
.slip h3 { margin: 0 0 .1rem; font-size: 1rem; }
.slip dl { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; margin: .6rem 0 0; font-variant-numeric: tabular-nums; }
.slip dd { margin: 0; text-align: right; }
.slip .tot { font-weight: 650; border-top: 1px solid var(--line); padding-top: .2rem; }
.slip .sign { margin-top: 2.2rem; border-top: 1px solid #000; padding-top: .2rem; font-size: .8rem; text-align: center; }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .8rem 1.1rem; }
@media print {
  .slips { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .slip { border: 1px solid #000; }
  .table.payroll { font-size: 8.5px; }
  .table.payroll td, .table.payroll th { padding: 2px 3px; }
}

/* employee file */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.figure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.figure .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.figure .n { font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; margin: .15rem 0; }
.figure .sub { font-size: .85rem; color: var(--muted); }

/* ---------- two-step sign-in ---------- */
.steps { padding-left: 1.2rem; display: grid; gap: .7rem; max-width: 46rem; }
.secret-key code { display: inline-block; font-size: 1.15rem; letter-spacing: .06em; padding: .5rem .8rem; background: #f3f5f9; border: 1px solid var(--line); border-radius: 8px; user-select: all; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .5rem; max-width: 40rem; }
.recovery-codes code { font-size: 1.05rem; padding: .35rem .6rem; background: #f3f5f9; border: 1px solid var(--line); border-radius: 6px; text-align: center; }
