[hidden] { display: none !important; }
:root {
  --bg: #f6f6f9; --panel: #ffffff; --panel-2: #fafafc; --ink: #1d1d27; --muted: #6b6b7b; --faint: #9a9aa8;
  --line: #e6e6ee; --line-2: #d9d9e3; --accent: #5b4bd5; --accent-ink: #fff; --accent-soft: #eeebfd;
  --green: #16794a; --green-bg: #e3f5ec; --red: #b4232c; --red-bg: #fde8e9; --amber: #92600a; --amber-bg: #fdf3dc;
  --blue: #1f5fbf; --blue-bg: #e5eefc; --purple: #6b3fb8; --purple-bg: #f0e9fc; --grey-bg: #efeff4;
  --shadow: 0 1px 2px rgba(20,20,40,.06), 0 1px 1px rgba(20,20,40,.03);
  --radius: 10px; --side: 232px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121218; --panel: #1b1b23; --panel-2: #20202a; --ink: #ececf3; --muted: #a0a0b2; --faint: #74748a;
    --line: #2b2b37; --line-2: #383846; --accent-soft: #2a2550;
    --green: #5fd49a; --green-bg: #173326; --red: #ff8a8f; --red-bg: #3b1c20; --amber: #f2c25b; --amber-bg: #3a2e14;
    --blue: #86b2ff; --blue-bg: #1b2a45; --purple: #c3a6ff; --purple-bg: #2c2245; --grey-bg: #2a2a35;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); } .neg { color: var(--red); }

/* layout */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.brand b { display: block; font-size: 14px; } .brand small { color: var(--muted); font-size: 11px; }
.company-switch { width: 100%; margin: 0 0 10px; }
.side .group { margin: 10px 0 2px; padding: 0 10px; font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; }
.side a.nav { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 7px; color: var(--ink); font-size: 13.5px; }
.side a.nav:hover { background: var(--grey-bg); text-decoration: none; }
.side a.nav.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side a.nav svg { width: 16px; height: 16px; opacity: .75; flex: none; }
.side .foot { margin-top: 16px; padding: 10px; border-top: 1px solid var(--line); font-size: 12px; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 28px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.topbar form { flex: 1; max-width: 420px; }
.topbar input[type=search] { width: 100%; }
.btn.menu-btn { display: none; }
.page { padding: 22px 28px 60px; max-width: 1400px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* panels & grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card + .card { margin-top: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 14px 18px 0; }
.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)); } .g-side { grid-template-columns: minmax(0, 1fr) 340px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; } .stat .value { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .note { font-size: 12px; color: var(--muted); margin-top: 2px; }
a.stat:hover { border-color: var(--line-2); text-decoration: none; }
a.stat { color: inherit; display: block; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; white-space: pre-line; }

/* tables */
table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--panel-2); }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--line-2); border-bottom: 0; }
.table td.wrap { white-space: pre-line; }
.table .sub-row td { padding-left: 28px; }
tr.total td { font-weight: 650; border-top: 1px solid var(--line-2); }
tr.grand td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--ink); }
tr.section td { font-weight: 650; background: var(--panel-2); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* forms & buttons */
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line-2); border-radius: 7px; padding: 7px 9px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 34px; width: 60px; }
textarea { width: 100%; resize: vertical; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 550; padding: 7px 13px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--grey-bg); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); } .btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 550; font-size: 13px; margin-bottom: 5px; }
.field input:not([type=checkbox]), .field select, .field textarea { width: 100%; }
.field.check { display: flex; align-items: center; gap: 8px; } .field.check label { margin: 0; order: 2; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.field .err, .errorlist { color: var(--red); font-size: 12px; margin: 4px 0 0; padding: 0; list-style: none; }
.form-actions { display: flex; gap: 8px; margin-top: 18px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs .count { background: var(--grey-bg); border-radius: 10px; padding: 0 7px; font-size: 11px; margin-left: 4px; }

/* badges, messages */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: var(--grey-bg); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); } .badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); } .badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.purple { background: var(--purple-bg); color: var(--purple); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11.5px; background: var(--accent-soft); color: var(--accent); margin: 0 3px 3px 0; }
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: var(--blue-bg); color: var(--blue); }
.messages li.success { background: var(--green-bg); color: var(--green); }
.messages li.error { background: var(--red-bg); color: var(--red); }
.messages li.warning { background: var(--amber-bg); color: var(--amber); }
.callout { background: var(--amber-bg); color: var(--amber); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.bar { height: 6px; background: var(--grey-bg); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.over > span { background: var(--red); }

/* kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.col.drag-over { outline: 2px dashed var(--accent); }
.col-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-weight: 650; }
.col-head .muted { font-weight: 400; font-size: 12px; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 11px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.kcard:active { cursor: grabbing; } .kcard.dragging { opacity: .4; }
.kcard .t { font-weight: 600; } .kcard .m { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; justify-content: space-between; gap: 6px; }
.kcard a { color: inherit; }

/* line editor */
.lines td { padding: 6px 6px; vertical-align: top; }
.lines input, .lines select, .lines textarea { width: 100%; padding: 6px 7px; }
.lines textarea { min-height: 36px; }
.lines .w-qty { width: 80px; } .lines .w-price { width: 110px; } .lines .w-disc { width: 70px; }
.lines .w-acct { width: 190px; } .lines .w-tax { width: 130px; } .lines .w-amt { width: 110px; }
.lines .w-x { width: 34px; }
.totals { margin-left: auto; width: 320px; } .totals td { padding: 5px 8px; }
.totals tr.grand td { font-size: 17px; }

/* charts */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.chart .m { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.chart .bars { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.chart .b { width: 40%; max-width: 22px; border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .b.in { background: var(--accent); } .chart .b.out { background: var(--line-2); }
.chart .lbl { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 130px 1fr 110px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; }
.login .card { width: 360px; padding: 28px; }

/* print (invoices) */
.paper { background: #fff; color: #1d1d27; max-width: 820px; margin: 0 auto; padding: 48px; border: 1px solid var(--line); border-radius: 6px; color-scheme: light; }
.paper table td, .paper table th { color: #1d1d27; }
@media print {
  body { background: #fff; }
  .side, .topbar, .no-print, .messages { display: none !important; }
  .shell { display: block; } .page { padding: 0; max-width: none; }
  .paper { border: 0; padding: 0; max-width: none; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; z-index: 20; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .btn.menu-btn { display: inline-flex; }
  .page { padding: 16px; } .topbar { padding: 10px 16px; }
  .g2, .g3, .g4, .g-side, .form-grid { grid-template-columns: 1fr; }
  .table-wrap { overflow-x: auto; }
}
.btn svg { width: 15px; height: 15px; flex: none; }
@media (max-width: 900px) { .topbar .actions { display: none; } .topbar form { max-width: none; } }
