/* PrimeGuard Books — clean light app with PrimeGuard black/gold identity.
   Structure and component classes mirror LoraLedger's styles.css; the
   palette is swapped to black ink + gold accents on warm off-white. */
:root {
  --ink: #141414;
  --ink-deep: #0d0d0f;
  --gold: #c9a227;
  --gold-bright: #f5c542;
  --gold-deep: #8a6d14;
  --gold-soft: #fdf6dd;
  --page: #f6f5f1;
  --card: #ffffff;
  --slate: #4b5563;
  --faint: #6b7280;
  --line: #e5e2d8;
  --green: #16a34a;
  --amber: #f59e0b;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber-soft: #fffbeb;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 20, 20, .07), 0 4px 14px rgba(20, 20, 20, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 980px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
}
.btn:hover { border-color: var(--gold); }
.btn.primary {
  background: var(--ink-deep);
  border-color: var(--ink-deep);
  color: #fff;
}
.btn.primary:hover { border-color: var(--gold); color: var(--gold-bright); }
.btn.gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-bright));
  border-color: transparent;
  color: var(--ink-deep);
}
.btn.gold:hover { filter: brightness(1.05); }
.btn.google { width: 100%; }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn.ghost { background: transparent; color: #f3e9c8; border-color: rgba(255,255,255,.35); }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.wide { width: 100%; }
.btn.linklike { background: none; border: none; color: var(--gold-deep); margin-top: 14px; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- gates (login) ---------- */
.gate {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #0d0d0f 0%, #1c1a12 55%, #3a2f08 130%);
}
.gate-card {
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  padding: 34px 30px 28px;
  width: 100%; max-width: 400px;
  text-align: center;
}
.wordmark { width: 84px; height: 84px; border-radius: 20px; object-fit: cover; box-shadow: 0 6px 18px rgba(20,20,20,.25); }
.gate-card h1 { margin: 12px 0 4px; font-size: 28px; letter-spacing: -.02em; }
.gate-sub { color: var(--slate); margin: 0 0 20px; font-size: 14.5px; line-height: 1.45; }
.gate-card form { text-align: left; }
.gate-card label { display: block; font-size: 13px; font-weight: 600; color: var(--slate); margin-bottom: 14px; }
.gate-card input {
  display: block; width: 100%; margin-top: 5px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
}
.gate-card input:focus { outline: 2px solid rgba(201,162,39,.4); border-color: var(--gold); }
.gate-actions { display: flex; gap: 10px; }
.gate-actions .btn { flex: 1; }
.gate-note { font-size: 12.5px; color: var(--faint); margin: 16px 0 0; line-height: 1.45; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--faint); font-size: 12.5px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.error {
  background: var(--red-soft); color: var(--red);
  border: 1px solid #fecaca; border-radius: 10px;
  padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; text-align: left;
}
.notice {
  background: #e7f6ee; color: #14532d;
  border: 1px solid #86c79b; border-radius: 10px;
  padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; text-align: left;
}

/* ---------- app frame ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px;
  background: var(--ink-deep);
  color: #fff;
  position: sticky; top: 0; z-index: 20;
  border-bottom: 2px solid var(--gold);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; object-fit: cover; }
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.brand-name .gold { color: var(--gold-bright); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sync-status { font-size: 12.5px; color: #e8ddae; margin-right: 4px; }

.layout-single { padding: 14px 20px 30px; max-width: 1120px; margin: 0 auto; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  border: none; background: transparent; padding: 9px 14px; font-size: 14.5px; font-weight: 600;
  color: var(--slate); border-radius: 10px;
}
.tab:hover { background: #edebe2; }
.tab.active { background: var(--ink-deep); color: var(--gold-bright); }
.tabpane { display: flex; flex-direction: column; gap: 14px; }

/* ---------- cards & content ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2 { margin: 0 0 6px; font-size: 17px; letter-spacing: -.01em; }
.card h4 { margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.card .sub { color: var(--slate); font-size: 13.5px; line-height: 1.5; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; }
.stat { flex: 1 1 160px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.stat .v { font-size: 23px; font-weight: 750; margin-top: 3px; letter-spacing: -.02em; }
.stat .v.neg { color: var(--red); }
.stat .v.pos { color: var(--green); }
.stat .note { font-size: 12px; color: var(--faint); margin-top: 2px; }

table.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
table.ledger th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.ledger td { padding: 9px 6px; border-bottom: 1px solid #f2f0e8; vertical-align: top; }
table.ledger tr:last-child td { border-bottom: none; }
table.ledger td.num, table.ledger th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num.out { color: var(--ink); }
td.num.in { color: var(--green); font-weight: 600; }
td.num.neg { color: var(--red); }
table.ledger tr.total td { font-weight: 750; border-top: 2px solid var(--ink); border-bottom: none; }

.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 980px; background: #eef0f1; color: var(--slate); white-space: nowrap; }
.pill.gold { background: var(--gold-soft); color: var(--gold-deep); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.green { background: #e9f9ef; color: var(--green); }
.pill.amber { background: var(--amber-soft); color: #92400e; }
.pill.blue { background: var(--blue-soft); color: var(--blue); }

/* invoice status chips */
.chip { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 980px; white-space: nowrap; }
.chip.draft { background: #eef0f1; color: var(--slate); }
.chip.sent { background: var(--blue-soft); color: var(--blue); }
.chip.paid { background: #e9f9ef; color: var(--green); }
.chip.overdue { background: var(--red-soft); color: var(--red); }

/* row action buttons */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions .btn { padding: 4px 11px; font-size: 12.5px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.form-grid label, .f-label { font-size: 12.5px; font-weight: 600; color: var(--slate); display: flex; flex-direction: column; gap: 4px; }
.form-grid input, .form-grid select, .form-grid textarea,
.inline-form input, .inline-form select, .inline-form textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 14.5px; background: #fff;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { outline: 2px solid rgba(201,162,39,.4); border-color: var(--gold); }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 700px) { .form-grid .span2 { grid-column: span 1; } }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.inline-form label { font-size: 12.5px; font-weight: 600; color: var(--slate); display: flex; flex-direction: column; gap: 4px; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }

/* invoice line items */
.line-items { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.line-item { display: grid; grid-template-columns: 1fr 74px 110px 96px 34px; gap: 8px; align-items: center; }
.line-item input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; width: 100%; }
.line-item .li-total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; font-size: 14px; }
.line-item .li-del { border: 1px solid #fecaca; background: #fff; color: var(--red); border-radius: 8px; height: 34px; font-weight: 700; }
@media (max-width: 700px) { .line-item { grid-template-columns: 1fr 60px 92px 34px; } .line-item .li-total { display: none; } }
.inv-totals { margin-left: auto; max-width: 320px; width: 100%; margin-top: 12px; font-size: 14px; }
.inv-totals .row { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; }
.inv-totals .row.grand { font-weight: 800; font-size: 16px; border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 7px; }

/* accounts */
.account-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; text-align: left; background: none; border: none;
  padding: 9px 6px; border-radius: 10px; border-bottom: 1px solid #f2f0e8;
}
.account-row:last-child { border-bottom: none; }
.acct-name { font-size: 14px; font-weight: 600; }
.acct-meta { font-size: 12px; color: var(--faint); }
.acct-bal { text-align: right; }
.acct-bal .amt { font-size: 14.5px; font-weight: 700; }
.acct-bal .amt.owed { color: var(--red); }
.acct-bal .amt.have { color: var(--green); }
.acct-bal .avail { font-size: 11.5px; color: var(--faint); }

/* plaid connection setup (owner only; lives in #plaidModal) */
#plaidModal label { display: block; font-size: 13px; font-weight: 600; color: var(--slate); margin-bottom: 12px; }
#plaidModal input {
  display: block; width: 100%; margin-top: 5px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
}
#plaidModal input:focus { outline: 2px solid rgba(201,162,39,.4); border-color: var(--gold); }
#plaidModal .fineprint { margin: 10px 0 0; }
#plaidModal .sub { color: var(--slate); font-size: 13.5px; line-height: 1.5; }
#plaidModal .setup-status { margin-top: 14px; }
.setup-status { font-size: 13.5px; color: var(--slate); margin: 2px 0 12px; }
.setup-status.ok { color: var(--green); font-weight: 600; }

.empty { color: var(--slate); font-size: 14px; line-height: 1.55; padding: 8px 0; }
.appfoot { margin-top: 18px; }
.appfoot .fineprint, .fineprint { font-size: 12px; color: var(--faint); line-height: 1.5; }
.month-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--slate); }
.month-pick input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink-deep); color: #fff; padding: 11px 20px; border-radius: 980px;
  font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 50;
  max-width: 90vw; text-align: center; border: 1px solid var(--gold);
}

/* ---------- bank transaction categories (Expenses) ---------- */
.cat-select {
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; background: #fff; max-width: 170px;
}
.cat-select:focus { outline: 2px solid rgba(201,162,39,.4); border-color: var(--gold); }
.bank-month-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bank-month-nav .mnav {
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; width: 32px; height: 32px; font-size: 18px; line-height: 1;
}
.bank-month-nav .mnav:hover { border-color: var(--gold); }
.bank-month-nav .mlabel { font-weight: 700; font-size: 15px; min-width: 130px; text-align: center; }

/* ---------- calendar tab (ported from the admin cal2 pattern) ---------- */
.cal2-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal2-head h3 { font-size: 19px; margin: 0 auto 0 4px; letter-spacing: -.01em; }
.cal2-nav {
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; width: 34px; height: 34px; font-size: 20px; line-height: 1;
}
.cal2-nav:hover { border-color: var(--gold); }
.cal2-dow { display: grid; grid-template-columns: repeat(7, 1fr); margin-top: 12px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; }
.cal2-dow span { padding: 6px 8px; }
.cal2-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--card); }
.cal2-cell { min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 5px 6px; cursor: pointer; overflow: hidden; }
.cal2-cell:hover { background: var(--gold-soft); }
.cal2-cell.dim { opacity: .42; }
.cal2-dnum { font-size: 13px; font-weight: 650; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal2-cell.today .cal2-dnum { background: var(--gold); color: var(--ink-deep); }
.cal2-ev { display: block; margin-top: 4px; padding: 2px 6px; border-radius: 6px; font-size: 11.5px; line-height: 1.35; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal2-inv { display: block; margin-top: 4px; padding: 2px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 700; line-height: 1.35; background: var(--gold); color: var(--ink-deep); border: 1px solid var(--gold-deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal2-more { font-size: 11px; color: var(--faint); margin-top: 3px; }
.cal2-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--slate); }
.cal2-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.cal2-dayitem {
  display: flex; justify-content: space-between; gap: 10px; width: 100%;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px;
  margin-top: 8px; cursor: pointer; background: var(--card); text-align: left;
  color: var(--ink); font: inherit; font-size: 13.5px;
}
.cal2-dayitem:hover { border-color: var(--gold); }
.cal2-modal { position: fixed; inset: 0; background: rgba(13,13,15,.55); display: flex; align-items: flex-start; justify-content: center; padding: 24px 14px; z-index: 60; overflow: auto; }
.cal2-modal-card { background: var(--card); color: var(--ink); border-radius: 16px; max-width: 520px; width: 100%; padding: 20px; border: 1px solid var(--gold); box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.cal2-form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.cal2-form label { font-size: 12.5px; font-weight: 600; color: var(--slate); display: flex; flex-direction: column; gap: 4px; }
.cal2-form input, .cal2-form select, .cal2-form textarea { padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 14.5px; background: #fff; }
.cal2-form input:focus, .cal2-form select:focus, .cal2-form textarea:focus { outline: 2px solid rgba(201,162,39,.4); border-color: var(--gold); }
.cal2-form .sub { color: var(--slate); font-size: 13px; }
@media (max-width: 640px) { .cal2-cell { min-height: 78px; padding: 4px; } .cal2-ev, .cal2-inv { font-size: 10.5px; } }

/* ---------- print: reports only ---------- */
@media print {
  .topbar, .tabs, .appfoot, .no-print { display: none !important; }
  body { background: #fff; }
  .layout-single { padding: 0; max-width: none; }
  .tabpane.hidden { display: none !important; }
  #tab-reports { display: flex !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
