@import url("/static/fonts.css");
:root {
  --ink: #111111;
  --ink-2: #3a3a3a;
  --muted: #7a7a7a;
  --line: #e6e6e6;
  --line-2: #d4d4d4;
  --bg: #f6f6f4;
  --card: #ffffff;
  --ok: #1f7a4d;
  --ok-bg: #e8f4ee;
  --warn: #9a5b00;
  --warn-bg: #fdf3e2;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg);
  font-feature-settings: "cv11", "tnum";
}
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.r { text-align: right; }
.nowrap { white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.shell > * { min-width: 0; }
.side { background: var(--ink); color: #fff; padding: 22px 16px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; text-decoration: none; }
.logo .mk { width: 32px; height: 32px; background: #fff; color: var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: -0.04em; }
.logo b { display: block; font-size: 14px; letter-spacing: 0.02em; }
.logo small { display: block; color: #9a9a9a; font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; color: #cfcfcf; text-decoration: none; font-weight: 500; }
.nav a:hover { background: #222; color: #fff; }
.nav a.on { background: #fff; color: var(--ink); }
.nav svg { width: 17px; height: 17px; flex: none; }
.side .spacer { flex: 1; }
.side .who { color: #9a9a9a; font-size: 12px; padding: 0 10px 8px; }
.side form button { width: 100%; text-align: left; background: none; border: 1px solid #333; color: #cfcfcf; padding: 8px 10px; border-radius: 7px; cursor: pointer; font: inherit; }
.side form button:hover { border-color: #666; color: #fff; }

.main { padding: 28px 36px 60px; max-width: 1240px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card .ch { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card .ch h2 { margin: 0; font-size: 14px; font-weight: 600; }
.card .cb { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid > *, .card { min-width: 0; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.lookup-box { background: #f7f7f5; border: 1px dashed var(--line-2); border-radius: 8px; padding: 14px 14px 10px; margin-bottom: 16px; }
.lookup-box .field { margin-bottom: 6px; }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--bad); }
.split { grid-template-columns: 1fr 300px; align-items: start; }
.stack > * + * { margin-top: 16px; }

.stat { padding: 16px 18px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.stat.dark .k, .stat.dark .s { color: #a8a8a8; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2a2a2a; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn svg { width: 15px; height: 15px; }
form.inline { display: inline; margin: 0; }

/* tables */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fbfbfa; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.link { cursor: pointer; }
table.t tr.link:hover td { background: #fafaf8; }
table.t td.strong a { font-weight: 600; text-decoration: none; }
table.t tfoot td { font-weight: 600; background: #fbfbfa; border-top: 1px solid var(--line); }
.tw { overflow-x: auto; }

/* pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.pill.draft { background: #f0f0ee; color: var(--ink-2); }
.pill.issued { background: #eef2fb; color: #2948a3; }
.pill.paid { background: var(--ok-bg); color: var(--ok); }
.pill.cancelled { background: #f3f3f3; color: #999; text-decoration: line-through; }
.pill.overdue { background: var(--bad-bg); color: var(--bad); }

/* tracker */
.nbadge { margin-left: auto; background: #f04438; color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); }
table.sum td, table.sum th { padding: 9px 14px; }
table.sum tr.sec td { background: #fbfbfa; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
table.sum tr.tot td { font-weight: 700; border-top: 1px solid var(--ink); }
table.sum td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); }
tr.rev td { background: #fff8eb; }
.kind { font-size: 12px; font-weight: 600; display: inline-block; min-width: 150px; }
.kind.none { color: var(--bad); }
.desc { font-size: 12px; color: var(--muted); white-space: pre-line; max-width: 420px; }
.amt-in { color: var(--ok); }
.ok-dot::before { content: "✓ "; color: var(--ok); }

/* partner badges */
.pt { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; letter-spacing: .01em; }
.pt.alex { background: #c2560c; color: #fff; }
.pt.deniss { background: #6a3fd4; color: #fff; }
.pt.split { background: linear-gradient(90deg, #c2560c 50%, #6a3fd4 50%); color: #fff; }
.pt.common { background: #f0f0ee; color: var(--ink-2); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend i.alex { background: #c2560c; }
.legend i.deniss { background: #6a3fd4; }
.bars .col { gap: 2px; }
.bars .col { display: flex; flex-direction: column-reverse; height: 100%; justify-content: flex-start; }
.bars .col .seg { width: 100%; min-height: 0; }
.bars .col .seg.alex { background: #c2560c; }
.bars .col .seg.deniss { background: #6a3fd4; }
.bars .col .seg:last-child { border-radius: 3px 3px 0 0; }
.export { display: flex; gap: 6px; }

/* forms */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=email], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; font: inherit; color: var(--ink);
}
textarea { height: auto; min-height: 70px; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; border-color: var(--ink); }
input.r { text-align: right; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: 16px; height: 16px; }

.items-table td { padding: 6px 6px; border-bottom: 0; }
.items-table th { padding: 6px; }
.items-table td:first-child { padding-left: 0; }
.items-table .del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 6px; }
.items-table .del:hover { color: var(--bad); }
.totals-box { margin-left: auto; width: 320px; }
.totals-box div { display: flex; justify-content: space-between; padding: 5px 0; }
.totals-box .grand { border-top: 1px solid var(--ink); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 18px; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.alert.info { background: #fff; border: 1px solid var(--line-2); }
.alert.err { background: var(--bad-bg); color: var(--bad); border: 1px solid #f6c9c4; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.filters select, .filters input { width: auto; height: 34px; }
.filters input[type=text] { min-width: 220px; }

.preview { width: 100%; height: 1120px; border: 0; background: #fff; display: block; }
.preview-wrap { background: #e9e9e6; padding: 24px; border-radius: var(--radius); }
.preview-wrap .paper { max-width: 800px; margin: 0 auto; box-shadow: 0 6px 30px rgba(0,0,0,.12); }

dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; }

.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 140px; }
.bars .b { background: var(--ink); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars .b:hover { background: #444; }
.bars-x { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; font-size: 11px; color: var(--muted); text-align: center; margin-top: 6px; }

.log { font-size: 12.5px; }
.log div { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; }
.log div:last-child { border: 0; }
.log .ts { color: var(--muted); white-space: nowrap; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--ink); }
.auth .box { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 32px; }
.auth .logo { padding: 0 0 22px; color: var(--ink); }
.auth .logo .mk { background: var(--ink); color: #fff; }
.auth h1 { font-size: 20px; margin: 0 0 4px; }
.auth p { color: var(--muted); margin: 0 0 20px; }
.auth .btn { width: 100%; justify-content: center; height: 42px; }
.qr { display: block; width: 200px; height: 200px; margin: 6px auto 12px; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: #f4f4f2; padding: 8px; border-radius: 6px; word-break: break-all; text-align: center; margin-bottom: 16px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .side .logo { padding: 0 8px 0 0; }
  .nav { display: flex; flex-wrap: nowrap; gap: 2px; overflow-x: auto; width: 100%; order: 3; }
  .nav a { white-space: nowrap; }
  .side form { margin-left: auto; }
  .side form button { padding: 6px 10px; }
  .side .spacer, .side .who { display: none; }
  .main { padding: 18px 16px 40px; }
  .g2, .g3, .g4, .split { grid-template-columns: 1fr; }
  .totals-box { width: 100%; }
  .preview { height: 800px; }
  .items-table thead { display: none; }
  .items-table tr { display: grid; grid-template-columns: 70px 1fr 1fr 32px; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .items-table td { padding: 0 !important; }
  .items-table td:first-child { grid-column: 1 / -1; }
}
