/* EEE Books: ledger-style theme. Paper, ink, hairline rules, red for negatives. */
:root {
  --bg: #f6f4ef; --panel: #fffefb; --ink: #1d1d1b; --muted: #6b6a64; --line: #dcd8ce; --rule: #1d1d1b;
  --side: #efece4; --accent: #1f4d3a; --accent-ink: #fff; --accent-soft: #e4ece7;
  --blue: #1f4d3a; --green: #1f4d3a; --green-bg: transparent; --red: #a1241b; --red-bg: transparent;
  --amber: #8a5a12; --amber-bg: transparent; --radius: 2px;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 10px; color: var(--ink); font-weight: 600; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.row > h3 { border-bottom: 0; padding-bottom: 0; }

/* Layout */
.app { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--ink); padding: 18px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line); }
.brand { padding: 0 18px 16px; margin-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 700; font-size: 14px; line-height: 1.25; }
.brand .sub { font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
.side a { display: flex; align-items: center; gap: 8px; color: var(--ink); padding: 6px 18px; font-weight: 400; border-left: 3px solid transparent; }
.side a:hover { background: rgba(0,0,0,.04); text-decoration: none; }
.side a.on { background: var(--panel); border-left-color: var(--accent); font-weight: 600; }
.side .sec { font-size: 12px; font-variant: small-caps; text-transform: lowercase; letter-spacing: .06em; color: var(--muted); padding: 14px 18px 3px; }
.side .badge { margin-left: auto; background: var(--accent); color: var(--accent-ink); padding: 0 6px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.main { padding: 20px 32px 60px; min-width: 0; }
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid var(--rule); flex-wrap: wrap; }
.top .spacer { flex: 1; }
.user { color: var(--muted); font-size: 13px; }
.btn.menu-btn { display: none; }

/* Panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; overflow-x: auto; }
.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)); } .g6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.span2 { grid-column: span 2; }

/* Figures strip: one ruled band instead of separate tiles */
.grid:has(> .kpi) { gap: 0; background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--rule); }
.grid > .kpi { border: 0; border-left: 1px solid var(--line); background: transparent; }
.grid > .kpi:first-child { border-left: 0; }
.grid > .kpi:hover { background: var(--accent-soft); }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 400; }
.kpi .value { font-size: 22px; font-weight: 600; margin: 4px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.kpi.bad .value { color: var(--red); } .kpi.warn .value { color: var(--amber); }
.mt { margin-top: 16px; }
.chart-box { position: relative; height: 260px; }

/* Alerts: a plain list, not stacked colored boxes */
.alert { padding: 7px 0 7px 14px; margin: 0; display: flex; gap: 8px; align-items: flex-start; border-bottom: 1px dotted var(--line); position: relative; }
.alert:last-child { border-bottom: 0; }
.alert::before { content: ''; position: absolute; left: 0; top: 13px; width: 6px; height: 6px; background: var(--muted); }
.alert.danger::before { background: var(--red); } .alert.warn::before { background: var(--amber); } .alert.info::before { background: var(--accent); }
.alert.danger { color: var(--red); }
.card.alert { padding: 12px 16px 12px 28px; border: 1px solid var(--red); }
.card.alert::before { left: 14px; top: 18px; }
body > #root > .alert, #page > .alert { background: var(--panel); border: 1px solid var(--line); padding: 10px 14px 10px 28px; margin-bottom: 12px; }
#page > .alert::before { left: 14px; top: 16px; }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; }

/* Tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 7px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--accent-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 1px solid var(--rule); border-bottom: 3px double var(--rule); background: transparent; }
tr.sub td { font-weight: 600; background: transparent; border-top: 1px solid var(--rule); }
.neg { color: var(--red); } .pos { color: var(--ink); }

/* Status labels */
.pill { display: inline-block; padding: 0 5px; border: 1px solid currentColor; border-radius: 1px; font-size: 11px; font-weight: 600; letter-spacing: .02em; white-space: nowrap; line-height: 17px; }
.pill.paid, .pill.posted, .pill.matched, .pill.approved, .pill.active { color: var(--accent); }
.pill.overdue, .pill.rejected { color: var(--red); }
.pill.open, .pill.partial, .pill.pending, .pill.new, .pill.bid { color: var(--amber); }
.pill.draft, .pill.void, .pill.excluded, .pill.closed, .pill.complete { color: var(--muted); }

/* Forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #bdb8ac; background: var(--panel); color: var(--ink); padding: 6px 12px; border-radius: var(--radius); font-weight: 500; font-size: 13px; font-family: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #173b2c; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 6px 8px; border: 1px solid #c4bfb3; border-radius: var(--radius); font: inherit; color: var(--ink); background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rule); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; color: var(--muted); font-weight: 500; border: 1px solid transparent; border-bottom: 0; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); background: var(--panel); border-color: var(--rule); border-bottom: 1px solid var(--panel); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.lines td input, .lines td select { padding: 4px 6px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .bold { font-weight: 700; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.progress { height: 5px; background: var(--line); overflow: hidden; min-width: 60px; }
.progress > div { height: 100%; background: var(--ink); }
.progress.over > div { background: var(--red); }

/* Password rules checklist */
.pw-rules { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--muted); grid-column: 1 / -1; }
.pw-rules li { padding: 1px 0 1px 18px; position: relative; }
.pw-rules li::before { content: ''; position: absolute; left: 2px; top: 6px; width: 8px; height: 8px; border: 1px solid var(--muted); }
.pw-rules li.ok { color: var(--accent); }
.pw-rules li.ok::before { background: var(--accent); border-color: var(--accent); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(29,29,27,.4); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius); width: 100%; max-width: 980px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.modal.narrow { max-width: 560px; }
.modal-h { display: flex; align-items: center; padding: 12px 18px; border-bottom: 2px solid var(--rule); }
.modal-h h2 { margin: 0; flex: 1; }
.modal-b { padding: 18px; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
#toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); display: none; z-index: 99; max-width: 420px; }
#toast.err { background: var(--red); }

/* Login */
.login { max-width: 380px; margin: 12vh auto; border-top: 3px solid var(--rule); padding: 22px 24px; }
.login .brand { border: 0; padding: 0 0 6px; text-align: center; font-size: 17px; }
.login h2 { font-weight: 400; color: var(--muted); font-size: 14px; }

/* Print */
.print-only { display: none; }
@media print {
  .side, .top .btn, .no-print, .tabs { display: none !important; }
  .app { display: block; } .main { padding: 0; } .card { border: 0; padding: 0; }
  .print-only { display: block; } body { background: #fff; }
}

/* Mobile (owners checking numbers on phones) */
@media (max-width: 1100px) {
  .g6 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(2, 1fr); }
  .grid > .kpi { border-bottom: 1px solid var(--line); }
  .g6 > .kpi:nth-child(3n+1), .g4 > .kpi:nth-child(odd) { border-left: 0; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; width: 240px; left: -260px; transition: left .2s; }
  .side.open { left: 0; }
  .btn.menu-btn { display: inline-flex; }
  .main { padding: 14px 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; } .g6 { grid-template-columns: repeat(2, 1fr); } .span2 { grid-column: auto; }
  .kpi .value { font-size: 19px; }
  .g6 > .kpi:nth-child(3n+1) { border-left: 1px solid var(--line); }
  .g6 > .kpi:nth-child(odd), .g4 > .kpi { border-left: 0; }
}
