:root {
  --bg: #0f1115; --panel: #181b22; --panel2: #1f232c; --line: #2a2f3a;
  --text: #e7e9ee; --muted: #9aa3b2; --accent: #4f8cff; --accent2: #6c5ce7;
  --ok: #2ecc71; --warn: #f1c40f; --bad: #e74c3c; --info: #3498db;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--panel); border-inline-start: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.content { flex: 1; padding: 24px 28px; min-width: 0; }
.brand { font-weight: 800; letter-spacing: .5px; font-size: 18px; margin-bottom: 18px; }
.brand span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.brand.center { text-align: center; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: var(--text); position: relative;
}
nav a:hover { background: var(--panel2); text-decoration: none; }
nav a.active { background: var(--accent); color: #fff; }
nav .ico { width: 18px; text-align: center; }
nav .badge {
  margin-inline-start: auto; background: var(--bad); color: #fff; border-radius: 999px;
  font-size: 11px; padding: 1px 7px; font-weight: 700;
}
.logout { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.logout .who { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.logout button, button, .btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: transparent; border-color: var(--bad); color: var(--bad); }

h1 { margin: 0 0 18px; font-size: 22px; }
h2 { font-size: 15px; color: var(--muted); margin: 24px 0 10px; text-transform: uppercase; letter-spacing: .5px; }

/* flash */
.flash { background: var(--panel2); border: 1px solid var(--accent); padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.bad { border-color: var(--bad); }

/* cards / kpis */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.card .value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.card.alert { border-color: var(--bad); }
.card.alert .value { color: var(--bad); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* tables */
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; background: var(--panel2); }
tr:hover td { background: var(--panel2); }
td.wrap, th.wrap { white-space: normal; }

/* pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.ok { background: rgba(46,204,113,.15); color: var(--ok); }
.pill.warn { background: rgba(241,196,15,.15); color: var(--warn); }
.pill.bad { background: rgba(231,76,60,.15); color: var(--bad); }
.pill.info { background: rgba(52,152,219,.15); color: var(--info); }
.pill.muted { background: rgba(154,163,178,.15); color: var(--muted); }

/* forms */
form.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; min-width: 140px;
}
.row { display: flex; gap: 20px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 280px; }
.muted { color: var(--muted); }
.right { text-align: end; }
pre.raw { background: #0b0d11; border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow: auto; max-height: 320px; direction: ltr; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
.grid2 .k { color: var(--muted); }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: 320px; display: flex; flex-direction: column; gap: 14px; }
.login-card button { padding: 10px; }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .logout { margin: 0; border: 0; padding: 0; }
}

/* nav groups (added with ledger/consignment) */
.nav-group { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .6px; margin: 14px 12px 4px; opacity: .7; }
.nav-group:first-child { margin-top: 0; }
table.compact th, table.compact td { padding: 6px 9px; }
.line-editor td { padding: 4px; }
.line-editor input { min-width: 90px; }
.totals { font-weight: 700; }
.totals td { border-top: 2px solid var(--line); }
@media print {
  .sidebar, .toolbar, form.filters, .no-print { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; color: #000; }
  .panel, table { border-color: #ccc; }
  th { background: #f2f2f2 !important; color: #000 !important; }
}
.doc-head { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:16px; }
.badge-soft { background: var(--panel2); border:1px solid var(--line); border-radius:6px; padding:2px 8px; font-size:12px; }
