:root {
  --ink: #22222e;
  --yellow: #ffcb00;
  --yellow-2: #e6b800;
  --muted: #919299;
  --line: #e8eaee;
  --bg: #f3f4f7;
  --card: #ffffff;
  --side: #22222e;
  --ok: #15803d;
  --warn: #a16207;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}
a { color: inherit; text-decoration: none; }
.side {
  position: fixed; inset: 0 auto 0 0; width: 220px;
  background: var(--side); color: #fff;
  display: flex; flex-direction: column; padding: 18px 12px;
  z-index: 5;
}
.logo {
  font-weight: 700; letter-spacing: 0.12em; font-size: 15px;
  padding: 8px 12px 22px; color: #fff;
}
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a {
  color: #c9cad1; padding: 10px 12px; border-radius: 8px; font-size: 14px;
}
.side nav a.on, .side nav a:hover { background: #2e2e3c; color: #fff; }
.side nav a.on { box-shadow: inset 3px 0 0 var(--yellow); }
.side nav a.out { margin-top: auto; color: #919299; }
.shell { margin-left: 220px; min-height: 100vh; }
.head {
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; position: sticky; top: 0; z-index: 4;
}
.head-title { font-weight: 600; font-size: 16px; }
.head-user { color: var(--muted); font-size: 13px; }
.page { padding: 20px 24px 40px; max-width: 980px; }
h1 { font-size: 22px; margin: 0 0 16px; font-weight: 650; }
h2 { font-size: 14px; margin: 22px 0 10px; color: var(--muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; margin-bottom: 12px;
}
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 15px; background: #fff; color: var(--ink);
  font-family: inherit;
}
textarea { min-height: 80px; }
.btn {
  display: inline-block; background: var(--yellow); color: var(--ink);
  border: 0; border-radius: 8px; padding: 10px 16px; font-size: 14px;
  font-weight: 650; cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--yellow-2); }
.btn.ghost { background: #fff; border: 1px solid var(--line); font-weight: 500; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-block; font-size: 12px; padding: 3px 8px; border-radius: 999px;
  background: #f3f4f7; color: var(--ink); font-weight: 600;
}
.chip.new { background: #eef0f4; }
.chip.quote { background: #e8f0ff; color: #1e3a8a; }
.chip.invoice { background: #fff3c4; color: #854d0e; }
.chip.awaiting_payment { background: #ffedd5; color: #9a3412; }
.chip.in_progress { background: #dcfce7; color: var(--ok); }
.chip.shipped { background: #d1fae5; color: var(--ok); }
.pay-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pay-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.pay-btn.on.unpaid { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.pay-btn.on.partial { background: #ffedd5; border-color: #fed7aa; color: #9a3412; }
.pay-btn.on.paid { background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.pay-btn:not(.on):hover { border-color: #c5c7ce; }
.chip.partial { background: #ffedd5; color: #9a3412; }
.chip.paid { background: #dcfce7; color: var(--ok); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.inv-tabs { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
@media print { .print-hide { display: none !important; } }
.err { background: #fef2f2; color: #991b1b; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.item { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.actions { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.hist { font-size: 14px; position: relative; padding-left: 16px; }
.hist:before {
  content: ""; position: absolute; left: 0; top: 8px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--yellow);
}
.hist .when { color: var(--muted); font-size: 12px; }
form.inline { display: flex; gap: 8px; align-items: flex-end; margin: 8px 0 16px; }
form.inline input { flex: 1; }
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.table th {
  text-align: left; font-size: 12px; color: var(--muted); font-weight: 600;
  padding: 10px 14px; background: #fafafa; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fbfbfd; }
.table a { font-weight: 600; }
.muted { color: var(--muted); font-size: 14px; }
body.auth {
  background: var(--ink); color: #fff;
}
body.auth .shell { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
body.auth .page { max-width: 420px; width: 100%; padding: 24px; }
body.auth .card { color: var(--ink); }
body.auth h1 { color: var(--ink); }
body.auth .muted { color: var(--muted); }
.auth-brand {
  text-align: center; letter-spacing: 0.16em; font-weight: 700;
  margin-bottom: 18px; color: #fff;
}
.ava {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--yellow); color: var(--ink); font-weight: 700; font-size: 12px;
}
.ava.lg { width: 56px; height: 56px; font-size: 18px; flex-shrink: 0; }
.hero { display: flex; gap: 16px; align-items: flex-start; }
.hero h1 { margin: 0 0 4px; }
.stats { display: flex; gap: 10px; margin: 0 0 16px; flex-wrap: wrap; }
.stats.mini { margin: 10px 0 0; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; min-width: 110px;
}
.stat-n { font-size: 22px; font-weight: 700; }
.stat-l { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; margin-bottom: 12px; }
.table.wide { min-width: 2400px; }
.table.wide th, .table.wide td { white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.kv-row { display: grid; grid-template-columns: 180px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv-k { color: var(--muted); font-size: 13px; }
.kv-v { font-size: 14px; word-break: break-word; }
.pager { display: flex; gap: 16px; margin: 16px 0; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs a { padding: 8px 12px; border-radius: 8px; background: #fff; border: 1px solid var(--line); }
.tabs a.on { background: var(--yellow); border-color: var(--yellow); font-weight: 650; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .btn { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .filters { grid-template-columns: 1.4fr 1fr 1fr 1fr; }
  .filters .btn { grid-column: auto; }
}
@media (max-width: 760px) {
  .side {
    position: sticky; inset: auto; width: 100%; flex-direction: row;
    align-items: center; padding: 10px 12px; gap: 8px;
  }
  .logo { padding: 0 8px 0 0; }
  .side nav { flex-direction: row; flex: 1; overflow-x: auto; }
  .side nav a { white-space: nowrap; padding: 8px 10px; }
  .side nav a.on { box-shadow: inset 0 -3px 0 var(--yellow); }
  .side nav a.out { margin-top: 0; margin-left: auto; }
  .shell { margin-left: 0; }
  .page { padding: 14px; }
  .table { display: block; overflow-x: auto; }
  body.page-products .head { display: none !important; }
  body.page-products .page.cat { min-height: calc(100dvh - 52px); }
}
.page.cat { max-width: none; padding: 0; background: #111114; color: #e8e8ed; min-height: calc(100vh - 54px); }
.cat-top {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px 8px; border-bottom: 1px solid #2a2a33; align-items: flex-end;
}
.cat-kicker { color: #919299; font-size: 13px; margin-bottom: 8px; }
.cat-tabs { display: flex; gap: 8px; }
.cat-tabs a {
  padding: 8px 14px; border-radius: 8px; background: #1c1c24; color: #c9cad1;
  border: 1px solid #2a2a33;
}
.cat-tabs a.on { background: var(--yellow); color: var(--ink); border-color: var(--yellow); font-weight: 650; }
.cat-metrics { display: flex; gap: 16px; color: #c9cad1; font-size: 13px; padding-bottom: 8px; }
.cat-metrics b { color: #fff; }
.cat-note { margin: 12px 20px; padding: 12px 14px; background: #1c1c24; border-radius: 10px; color: #c9cad1; font-size: 14px; }
.cat-bar {
  display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 20px; align-items: center;
}
.cat-bar input, .cat-bar select {
  background: #1c1c24; color: #fff; border-color: #2a2a33; width: auto; min-width: 160px; flex: 1;
}
.cat-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 20px 12px; align-items: center; }
.cat-actions.sticky { padding: 8px 0; }
.cat-layout { display: grid; grid-template-columns: 280px 1fr; min-height: 60vh; }
.cat-tree {
  border-right: 1px solid #2a2a33; padding: 12px 0 24px; overflow-y: auto; max-height: calc(100vh - 180px);
}
.tree-search { padding: 4px 16px 10px; color: #919299; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.tree-item {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 7px 16px; color: #c9cad1; font-size: 13px;
}
.tree-item span { color: #919299; }
.tree-item:hover, .tree-item.on { background: #1c1c24; color: #fff; }
.tree-item.l2 { padding-left: 28px; }
.tree-item.l3 { padding-left: 40px; font-size: 12px; }
.cat-main { min-width: 0; }
.cat-table { background: #16161c; border-color: #2a2a33; }
.cat-table th { background: #1c1c24; color: #919299; }
.cat-table td { border-color: #2a2a33; color: #e8e8ed; }
.cat-table tr:hover td { background: #1c1c24; }
.cat-table .pname { font-weight: 600; }
.cat-table tr.is-hid td { opacity: .55; }
.page.cat .muted { color: #919299; padding: 0 20px; }
.page.cat .pager { padding: 8px 20px 24px; }
.page.cat .pager a { color: var(--yellow); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: #22c55e; }
.dot.no { background: #4b4b55; }
.price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.btn.mini { padding: 6px 10px; font-size: 12px; }
.page.cat .btn.ghost { background: #1c1c24; color: #e8e8ed; border-color: #2a2a33; }
.chk { display: flex; align-items: center; gap: 8px; cursor: pointer; color: #e8e8ed; }
.pricat-list { padding: 0 20px 40px; }
.pricat-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid #2a2a33;
}
.pricat-row.sub { padding-left: 36px; background: #16161c; }
.pricat-name { font-weight: 600; }
.pricat-meta { display: flex; gap: 16px; color: #919299; font-size: 13px; }
.pricat-meta a { color: var(--yellow); }
.inv-actions { display: flex; gap: 8px; margin: 0 0 14px; }
.inv {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 22px 22px 28px; max-width: 820px;
}
.inv h1 { font-size: 18px; margin: 0 0 16px; text-transform: none; letter-spacing: 0; }
.inv-kv { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 13px; }
.inv-kv th {
  width: 120px; text-align: left; color: var(--muted); font-weight: 600;
  padding: 4px 10px 4px 0; vertical-align: top;
}
.inv-kv td { padding: 4px 0; }
.inv-kv.buyer { background: #DCE6F1; border-radius: 8px; }
.inv-kv.buyer th, .inv-kv.buyer td { padding: 6px 10px; }
.inv-items { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 12px; }
.inv-items th {
  background: #1F4E78; color: #fff; font-weight: 600; text-align: left;
  padding: 8px 8px; font-size: 11px;
}
.inv-items td { padding: 8px; border-bottom: 1px solid #d9e2ec; vertical-align: top; }
.inv-items td:nth-child(5),
.inv-items td:nth-child(6),
.inv-items td:nth-child(7) { text-align: right; white-space: nowrap; }
.inv-total { text-align: right; background: #EAF2F8; padding: 10px 12px; font-size: 15px; border-radius: 8px; }
.inv-pay, .inv-note, .inv-sign { font-size: 13px; color: #333; }
.inv-note { color: var(--muted); }
@media print {
  .side, .head, .inv-actions { display: none !important; }
  .shell { margin: 0 !important; }
  .page { padding: 0 !important; max-width: none !important; }
  .inv { border: 0; border-radius: 0; padding: 0; }
}
@media (max-width: 900px) {
  .cat-layout { grid-template-columns: 1fr; }
  .cat-tree { max-height: 240px; border-right: 0; border-bottom: 1px solid #2a2a33; }
  .inv-items { font-size: 12px; }
}
