/* PPS Books — single-file style, no framework. */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #68727f;
  --line: #e2e6eb;
  --brand: #14532d;
  --brand-ink: #ffffff;
  --accent: #166534;
  --danger: #b91c1c;
  --ok-bg: #e8f5ee;
  --ok-ink: #14532d;
  --err-bg: #fdecec;
  --err-ink: #7f1d1d;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
h1 { font-size: 20px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 8px 0; }
a { color: var(--accent); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 28px; width: 340px; box-shadow: 0 8px 30px rgba(20, 35, 60, 0.08);
}
.login-card h1 { color: var(--brand); }

/* ---------- Shell ---------- */
.app { display: flex; min-height: 100vh; }
.nav {
  width: 200px; flex: 0 0 200px; background: var(--brand); color: #dcefe3;
  display: flex; flex-direction: column; padding: 14px 10px;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-size: 18px; font-weight: 700; color: #fff; padding: 6px 10px 14px; letter-spacing: .4px; }
.brand span { font-weight: 400; opacity: .75; }
.nav #nav { flex: 1; overflow-y: auto; }
.navitem {
  display: block; padding: 8px 10px; border-radius: 7px; color: #dcefe3;
  text-decoration: none; margin-bottom: 2px;
}
.navitem:hover { background: rgba(255,255,255,.09); }
.navitem.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.navfoot { padding: 10px; border-top: 1px solid rgba(255,255,255,.15); font-size: 12px; }
.navfoot .fhelp { color: #bcd9c8; word-break: break-all; margin-bottom: 6px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.titlebar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 12px 20px;
}
.view { padding: 16px 20px 40px; flex: 1; }
.loading { color: var(--muted); padding: 20px 0; }

/* ---------- Toolbar / tabs ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  border: none; background: none; padding: 8px 12px; cursor: pointer;
  color: var(--muted); font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.rpt { }

/* ---------- Cards ---------- */
.cards { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 9px;
  padding: 12px 16px; min-width: 170px; flex: 1 1 170px;
}
.card .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.card .val { font-size: 20px; font-weight: 700; margin-top: 2px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Tables ---------- */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; margin: 10px 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th {
  text-align: left; padding: 8px 10px; background: #f0f2f5; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f6faf7; }
tr.foot td { font-weight: 700; background: #f0f2f5; }
.neg { color: var(--danger); }

/* ---------- Forms ---------- */
.frow { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.flabel { font-weight: 600; font-size: 12.5px; color: var(--muted); }
.fhelp { color: var(--muted); font-size: 12px; }
input, select, textarea {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfe3cd; border-color: var(--accent); }
.formcard { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 16px; max-width: 760px; margin: 8px 0; }
form.busy button { opacity: .55; pointer-events: none; }
.detailhead { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.detailhead h2 { margin: 0; flex: 1 1 auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons / pills ---------- */
.btn {
  font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 12px; border-radius: 7px; cursor: pointer;
}
.btn:hover { border-color: #c6cdd5; background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { color: var(--danger); border-color: #eac9c9; }
.btn.danger:hover { background: #fdf1f1; }
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; background: #eef1f4; color: var(--muted);
}
.pill.open { background: #fdf3d7; color: #8a5b00; }
.pill.paid, .pill.closed, .pill.reconciled, .pill.linked { background: var(--ok-bg); color: var(--ok-ink); }
.pill.void, .pill.ignored, .pill.imported { background: #eef1f4; color: var(--muted); }

/* ---------- Flash ---------- */
.flash {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 8px; font-weight: 600; z-index: 60;
  box-shadow: 0 6px 24px rgba(20,35,60,.18); max-width: 80vw;
}
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid #bfe3cd; }
.flash.err { background: var(--err-bg); color: var(--err-ink); border: 1px solid #f2c4c4; }
.flash.sticky { position: static; transform: none; margin: 8px 0; }

/* ---------- Misc ---------- */
.doclist { margin: 6px 0; }
.doclist .doc {
  display: flex; gap: 10px; align-items: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px;
}
.doc a { font-weight: 600; }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.lines { width: 100%; }
.lines td, .lines th { padding: 5px 8px; }

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .nav { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .brand { padding: 8px 10px; }
  .nav #nav { display: flex; flex-wrap: wrap; }
  .navitem { margin-right: 4px; }
  .navfoot { border: none; }
}

/* ---------- Form grid, line editor, modals ---------- */
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.frow.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; margin-bottom: 0; }
.frow.inline .flabel { width: auto; margin-bottom: 0; }
.factions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.linedetail { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.linedetail .lines { margin: 4px 0 0; }
.form { width: 100%; }
form.formcard { margin-top: 4px; }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.checklist { display: grid; gap: 6px; }
.check { display: flex; gap: 8px; align-items: center; }

/* ---------- Report tables ---------- */
.report td { font-size: 13.5px; }
.report tr.sec td { font-weight: 700; background: #f0f2f6; }
.report tr.totalrow td { font-weight: 700; border-top: 2px solid var(--line); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; width: min(520px, 92vw); box-shadow: 0 18px 50px rgba(20, 35, 60, .25); }
