:root {
  --bg: #f5f6f4; --panel: #ffffff; --ink: #1d2421; --muted: #66706b; --line: #e2e5e1;
  --brand: #0b6e5b; --brand-ink: #ffffff; --brand-soft: #e3f1ed;
  --warn: #9a5b00; --warn-soft: #fff4dd; --bad: #b42318; --bad-soft: #fde8e6; --ok: #1a7f37; --ok-soft: #e6f4ea;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 20, .06);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #12312a; color: #cfe0da; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 14px; display: block; }
.side .brand small { display: block; font-weight: 400; color: #8fb3a8; font-size: 12px; }
.side nav a { display: block; color: #cfe0da; padding: 7px 10px; border-radius: 7px; font-size: 13.5px; }
.side nav a:hover, .side nav a.on { background: #1d4a3f; color: #fff; text-decoration: none; }
.side nav .grp { text-transform: uppercase; font-size: 11px; letter-spacing: .06em; color: #7fa398; margin: 14px 10px 4px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top .who { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }
.btn.menu-btn { display: none; }

.panel { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .l { color: var(--muted); font-size: 12.5px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfa; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
.table-wrap { overflow-x: auto; }
tfoot td { font-weight: 650; }

/* badges */
.b { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef0ee; color: #3b4440; white-space: nowrap; }
.b.ok { background: var(--ok-soft); color: var(--ok); }
.b.warn { background: var(--warn-soft); color: var(--warn); }
.b.bad { background: var(--bad-soft); color: var(--bad); }
.b.brand { background: var(--brand-soft); color: var(--brand); }

/* forms */
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cfd5d1; border-radius: 8px; font: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=checkbox] { width: auto; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid #cfd5d1; background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f5f3; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: #095a4a; }
.btn.danger { color: var(--bad); border-color: #f0c7c2; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; }

/* scan box */
.scan input { font-size: 20px; padding: 14px; letter-spacing: .04em; font-family: ui-monospace, Menlo, monospace; }
.scan .hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

/* messages */
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.msg.success { background: var(--ok-soft); border-color: #b7dfc2; color: #10521f; }
.msg.error { background: var(--bad-soft); border-color: #f3c3bd; color: #8a1c12; }
.msg.warning, .msg.info { background: var(--warn-soft); border-color: #f1d9a6; color: #6b4000; }

dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.right { text-align: right; }
.mt { margin-top: 16px; }
.big { font-size: 18px; font-weight: 650; }
.lines-table input, .lines-table select { padding: 6px 8px; }

/* login */
.login { max-width: 380px; margin: 10vh auto; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .main { padding: 14px 16px 60px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  dl.kv { grid-template-columns: 1fr; }
}
@media (max-width: 520px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* print (invoices) */
@media print {
  .side, .top, .no-print, .msg { display: none !important; }
  .shell { display: block; } .main { padding: 0; } body { background: #fff; }
  .panel { border: 0; box-shadow: none; padding: 0; }
}
