:root {
  /* Bytebrick: slate, terracotta, cream. --serif now holds the heading face (bold sans), --amber the highlight. */
  --bg: #f5f3ef;
  --panel: #ffffff;
  --ink: #1e2a32;
  --muted: #66707a;
  --line: #e3dfd6;
  --side: #1e2a32;
  --side-ink: #d3dade;
  --side-hover: #2c3b46;
  --side-dim: #8fa1ac;
  --accent: #b5471f;
  --amber: #f6ede3;
  --cream: #f6ede3;
  --serif: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e1;
  --good: #14784a;
  --bad: #a3123a;
  --warn: #9a5b00;
  --radius: 8px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; font-weight: 700; font-family: var(--serif); letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 .6rem; font-weight: 650; }
p { margin: .4rem 0; }
small, .muted { color: var(--muted); }
.center { text-align: center; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.print-only { display: none; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 14px 10px 30px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--cream); font-family: var(--serif); font-weight: 700; font-size: 1.12rem; letter-spacing: -.01em; white-space: nowrap; padding: 6px 10px 14px; }
.brand:hover { text-decoration: none; }
.logo-mark { flex: none; }
.brand.dark { color: var(--side); padding: 0; font-size: 1.3rem; }
.brand.dark .logo-mark { background: var(--side); border-radius: 7px; padding: 3px; }
.side nav a { display: block; color: var(--side-ink); padding: 6px 10px; border-radius: 6px; font-size: .95rem; }
.side nav a:hover { background: var(--side-hover); text-decoration: none; color: #fff; }
.side nav a.on { background: var(--accent); color: #fff; box-shadow: inset 3px 0 0 var(--amber); }
.nav-group { text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; color: var(--side-dim); padding: 14px 10px 4px; }
.top { display: flex; align-items: center; gap: 12px; background: var(--panel); border-bottom: 1px solid var(--line); padding: 9px 22px; }
.top form { margin: 0; }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: .9rem; }
.content { padding: 20px 22px 60px; max-width: 1280px; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.lang button { border: 0; background: transparent; padding: 4px 9px; cursor: pointer; font-size: .78rem; color: var(--muted); font-weight: 600; }
.lang button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- sign-in ---------- */
.auth-wrap { max-width: 460px; margin: 0 auto; padding: 28px 16px; }
.auth-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; font-size: 1.15rem; }

/* ---------- blocks ---------- */
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { flex: 1; min-width: 200px; }
.page-head form { margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 14px 16px 0; }
.card.narrow { max-width: 460px; margin: 0 auto 16px; }
.narrow-report { max-width: 720px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.empty { color: var(--muted); padding: 18px 16px; margin: 0; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: #e7f5ec; border-color: #b5dcc4; color: #0d5a36; }
.flash.error { background: #fdecea; border-color: #f2b8b5; color: #8c1d18; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 5px 12px; border-radius: 999px; color: var(--muted); font-size: .9rem; }
.tabs a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #faf8f2; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfbf7; }
td form { margin: 0; display: inline; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ctr { text-align: center; }
.code { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
table.dense th, table.dense td { padding: 6px 10px; font-size: .9rem; }
tr.group th { background: #f0ede3; color: var(--ink); text-transform: none; letter-spacing: 0; font-size: .92rem; }
tr.sel td { background: var(--accent-soft); }
tr.struck td { color: var(--muted); text-decoration: line-through; }
tr.struck td:last-child { text-decoration: none; }
tfoot th { background: #f3f0e7; color: var(--ink); font-size: .9rem; text-transform: none; letter-spacing: 0; border-top: 2px solid var(--line); border-bottom: 0; }
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: #e9edf2; color: #475466; white-space: nowrap; }
.badge.posted, .badge.doing, .badge.requested, .badge.normal { background: #e2ecfb; color: #1c4f9c; }
.badge.paid, .badge.done, .badge.approved, .badge.low { background: #dff3e7; color: var(--good); }
.badge.overdue, .badge.high, .badge.rejected { background: #fde3e1; color: var(--bad); }
.badge.void { background: #eee; color: #777; text-decoration: line-through; }

/* ---------- forms ---------- */
.form.grid, .form .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.form .grid { margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full, .actions.full { grid-column: 1 / -1; }
.field.grow { flex: 1; }
label { font-size: .86rem; font-weight: 600; color: #3a4757; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; padding-top: 22px; }
.req { color: var(--bad); }
input, select, textarea { font: inherit; color: inherit; padding: 7px 9px; border: 1px solid #c6ced8; border-radius: 6px; background: #fff; width: 100%; min-width: 0; }
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input.num { text-align: right; }
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.btn { display: inline-block; font: inherit; font-weight: 600; font-size: .9rem; padding: 7px 14px; border-radius: 6px; border: 1px solid #c6ced8; background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f6f4ee; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #97391a; }
.btn.danger { color: var(--bad); border-color: #e7b3af; }
.btn.danger:hover { background: #fdecea; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: #ebe7db; color: var(--ink); }
.btn.small { padding: 3px 9px; font-size: .8rem; }
.btn.wide { width: 100%; padding: 9px; margin-top: 6px; }
.card.narrow .form { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.danger-zone { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.filter, .search { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.search { margin: 0; }
.filter label { display: flex; flex-direction: column; gap: 3px; }
.filter input, .filter select, .search input { width: auto; }
.card > .filter { margin: 14px 0 0; }

/* ---------- document lines ---------- */
table.lines th, table.lines td { padding: 5px 6px; border-bottom: 0; }
table.lines th { background: transparent; }
table.lines tbody tr:hover td { background: transparent; }
.w-prod { width: 24%; } .w-acc { width: 36%; } .w-n { width: 12%; } .w-tax { width: 9%; }
.doc-foot { display: flex; gap: 24px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-top: 12px; }
table.totals { width: auto; min-width: 290px; margin-left: auto; }
table.totals td, table.totals th { padding: 5px 10px; }
table.totals.small { margin-left: 0; min-width: 240px; font-size: .88rem; }
tr.grand td { font-weight: 700; font-size: 1.08rem; border-top: 2px solid var(--ink); border-bottom: 0; }

/* ---------- printable invoice ---------- */
.paper { padding: 28px 30px; }
.paper.voided { background-image: repeating-linear-gradient(-45deg, transparent 0 22px, rgba(179, 38, 30, .05) 22px 44px); }
.paper-head { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.paper-head h2 { font-size: 1.2rem; margin-bottom: 4px; }
.paper-head p { margin: 1px 0; font-size: .9rem; }
.paper-title { text-align: right; }
.paper-title h1 { font-size: 1.5rem; letter-spacing: .06em; text-transform: uppercase; }
.docno { font-size: 1.15rem; font-weight: 700; margin: 2px 0 8px; }
.paper-buyer { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; margin-bottom: 18px; max-width: 420px; font-size: .92rem; }
.paper-lines th, .paper-lines td { font-size: .9rem; padding: 7px 8px; }
.paper-note { white-space: pre-line; font-size: .9rem; margin-top: 14px; }
.signatures { display: flex; justify-content: space-between; margin-top: 56px; }
.signatures span { border-top: 1px solid var(--ink); padding-top: 4px; width: 200px; text-align: center; font-size: .85rem; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding-bottom: 10px; }
  .side nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav-group { width: 100%; padding-top: 8px; }
  .content { padding: 14px 12px 40px; }
  .paper-head { flex-direction: column; }
  .paper-title { text-align: left; }
}

@media print {
  :root { font-size: 12px; }
  body { background: #fff; }
  .no-print, .flash { display: none !important; }
  .print-only { display: block; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; margin-bottom: 14px; }
  .card.keep { break-inside: avoid; }
  .paper { padding: 0; }
  a { color: inherit; }
  th { background: transparent !important; }
}

.cols.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
details summary { cursor: pointer; font-weight: 600; margin: 8px 0; }
.period-line { font-weight: 600; margin-bottom: 8px; }
.euid { font-size: .8rem; margin-top: 6px; word-break: break-all; }
.made-with { text-align: center; color: var(--muted); font-size: .75rem; margin-top: 28px; }
