:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1d2433; --muted: #66708a; --line: #e2e6ee;
  --brand: #0f4c81; --brand-ink: #ffffff; --accent: #12a37f; --danger: #c0392b; --warn: #b7791f;
  --side: #0b2340; --side-ink: #c9d6ea; --side-hi: #ffffff;
  --radius: 8px; font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--side); color: var(--side-ink); padding: 14px 10px; flex-shrink: 0; overflow-y: auto; }
.sidebar .logo { color: var(--side-hi); font-weight: 800; font-size: 19px; padding: 4px 8px 12px; letter-spacing: .3px; }
.sidebar .logo span { color: #5ec7a8; }
.sidebar h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #7f93b3; margin: 16px 8px 4px; }
.sidebar a { display: block; color: var(--side-ink); padding: 5px 8px; border-radius: 6px; font-size: 14px; }
.sidebar a:hover, .sidebar a.on { background: rgba(255,255,255,.09); color: var(--side-hi); text-decoration: none; }
.switcher select { width: 100%; padding: 7px; border-radius: 6px; border: 0; background: #183a63; color: #fff; font-weight: 600; }
.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.topbar .company { font-weight: 700; }
.topbar .company small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.content { padding: 22px 24px 60px; max-width: 1400px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 24px 0 10px; }
.head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.head h1 { margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.inactive td { color: #9aa3b5; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.table-wrap table { border: 0; }
.btn, button { display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover, button:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary, button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.green { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger, button.danger { color: var(--danger); border-color: #efc2bc; }
.btn.small, button.small { padding: 3px 9px; font-size: 13px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { font: inherit; font-size: 14px; padding: 7px 9px; border: 1px solid #cdd3df; border-radius: 6px; background: #fff; width: 100%; color: var(--ink); }
input[type=checkbox], input[type=radio] { width: auto; flex-shrink: 0; margin-top: 3px; }
.check { align-items: flex-start; }
input.num { text-align: right; }
textarea { min-height: 60px; }
.fields { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 16px; }
.check { display: flex; gap: 6px; align-items: center; color: var(--ink); font-size: 14px; }
.lines td { padding: 4px; border-bottom: 1px solid var(--line); }
.lines input, .lines select { padding: 5px 6px; }
.lines .x { color: var(--danger); background: none; border: 0; font-size: 18px; padding: 0 6px; }
.totals { margin-left: auto; width: 320px; margin-top: 12px; }
.totals td { border: 0; padding: 4px 8px; }
.totals tr.big td { font-size: 18px; font-weight: 700; border-top: 2px solid var(--ink); }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.flash.ok { background: #e6f6f0; color: #0b6b52; border: 1px solid #b5e3d2; }
.flash.error { background: #fdecea; color: #8a2419; border: 1px solid #f3c1ba; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: #eef1f6; color: var(--muted); text-transform: capitalize; }
.badge.open, .badge.pending, .badge.unapplied { background: #fff4e0; color: #8a5a00; }
.badge.paid, .badge.closed, .badge.accepted { background: #e6f6f0; color: #0b6b52; }
.badge.partial { background: #e8f0fb; color: #1d4f91; }
.badge.void, .badge.rejected { background: #f3f3f3; color: #999; text-decoration: line-through; }
.badge.overdue { background: #fdecea; color: #8a2419; }
.muted { color: var(--muted); }
.neg { color: var(--danger); }
.pos { color: #0b6b52; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters > div { min-width: 140px; }
.statement td { border-bottom: 0; padding: 4px 10px; }
.statement tr.header td { font-weight: 700; padding-top: 12px; }
.statement tr.line td:first-child { padding-left: 28px; }
.statement tr.subtotal td { font-weight: 600; border-top: 1px solid var(--line); }
.statement tr.total td { font-weight: 700; border-top: 1px solid #b9c0cf; }
.statement tr.grand td { font-weight: 800; border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); }
.report-title { text-align: center; margin-bottom: 14px; }
.report-title .co { font-size: 14px; color: var(--muted); }
.report-title .t { font-size: 22px; font-weight: 700; }
.bars { display: flex; gap: 14px; align-items: flex-end; height: 160px; padding-top: 10px; }
.bars .m { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 130px; }
.bars .b { width: 16px; border-radius: 3px 3px 0 0; }
.bars .inc { background: var(--accent); }
.bars .exp { background: #e07a5f; }
.bars .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: 4px; }
.auth { max-width: 380px; margin: 9vh auto; }
.auth .logo { font-size: 26px; font-weight: 800; text-align: center; margin-bottom: 18px; color: var(--side); }
.auth .logo span { color: var(--accent); }
.newmenu { position: relative; }
.newmenu .drop { display: none; position: absolute; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 12px; z-index: 10; width: 560px; grid-template-columns: repeat(3, 1fr); gap: 4px 18px; }
.newmenu:hover .drop, .newmenu:focus-within .drop { display: grid; }
.newmenu .drop h5 { margin: 4px 0; font-size: 11px; text-transform: uppercase; color: var(--muted); }
.newmenu .drop a { display: block; padding: 3px 0; font-size: 14px; }
.print-doc { background: #fff; max-width: 820px; margin: 20px auto; padding: 40px; border: 1px solid var(--line); }
@media print {
  .sidebar, .topbar, .noprint, .flash { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .print-doc { border: 0; margin: 0; padding: 0; }
  .card { border: 0; }
}
@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .newmenu .drop { width: 92vw; grid-template-columns: 1fr 1fr; }
}
a.card { display: block; color: inherit; }
a.card:hover { text-decoration: none; border-color: var(--brand); }
.auth.wide { max-width: 860px; margin-top: 4vh; padding: 0 16px; }
.section { border-top: 3px solid var(--brand); }
.section h2 { margin-top: 0; }
.legal { font-size: 13px; color: var(--muted); background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.kv { display: grid; grid-template-columns: 220px 1fr; gap: 4px 14px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } }
.attach-box { margin-top: 14px; padding: 10px 12px; border: 1px dashed #b9c3d3; border-radius: 8px; background: #fafbfd; }
.attach-box input[type=file] { border: 0; padding: 4px 0; background: transparent; }
.flash.warn { background: #fff7e6; color: #7a4b00; border: 1px solid #f1d39a; }
