:root {
  --paper: #F6F3EC; --paper-raised: #FFFFFF; --navy: #0F2A4A; --navy-soft: #1D3E63;
  --seal: #A8241C; --gold: #B8901F; --ink: #2B2E33; --ink-soft: #6B7280; --line: #DCD6C6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--paper); color: var(--ink); font-family: 'Inter', sans-serif; padding: 76px 16px 60px; }

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: #FFFFFF; border-bottom: 1px solid #E5E1D6; padding: 14px 18px;
}
.topbar .left { display: flex; align-items: center; gap: 14px; }
.topbar a.back { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: #F1EEE4; color: var(--navy); text-decoration: none; font-size: 15px; }
.topbar a.back:hover { background: var(--navy); color: #fff; }
.topbar span.title { font-family: 'Inter', sans-serif; font-weight: 700; font-size: 20px; color: var(--navy); }
.topbar-logo { width: 34px; height: 34px; border-radius: 8px; border: 1.5px solid var(--line); }

.denied { text-align: center; margin-top: 100px; color: var(--ink-soft); }
.denied i { font-size: 42px; color: var(--seal); margin-bottom: 14px; }
.denied h2 { font-family: 'Lora', serif; color: var(--navy); margin-bottom: 8px; }

.wrap { max-width: 1100px; margin: 0 auto; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: 6px; padding: 18px; text-align: center; border-top: 4px solid var(--navy); }
.stat-card.gold { border-top-color: var(--gold); }
.stat-card.navy { border-top-color: var(--seal); }
.stat-card.seal { border-top-color: #7f1d1d; }
.stat-sub { display: block; font-size: 10px; color: var(--ink-soft); margin-top: 4px; font-family: 'IBM Plex Mono', monospace; }
.stat-card p { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); font-weight: 600; margin-bottom: 6px; }
.stat-card h3 { font-family: 'IBM Plex Mono', monospace; font-size: 24px; color: var(--navy); }

.tabs { display: flex; gap: 8px; margin-bottom: 20px; overflow-x: auto; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.tab-btn { padding: 9px 16px; border: none; background: var(--paper-raised); border: 1px solid var(--line); color: var(--ink-soft); font-weight: 600; font-size: 13px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.tab-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.tab-btn.owner-only { display: none; }
body.role-owner .tab-btn.owner-only { display: inline-block; }

.owner-only { display: none; }
body.role-owner .owner-only { display: block; }
body.role-owner .tab-btn.owner-only { display: inline-block; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: 6px; padding: 22px; margin-bottom: 20px; }
.panel-card.narrow { max-width: 420px; }
.panel-card h3 { font-family: 'Lora', serif; color: var(--navy); margin-bottom: 16px; font-size: 17px; }
.panel-card .hint { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 14px; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.filter-row { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.filter-btn { padding: 8px 14px; border: 1px solid var(--line); background: var(--paper-raised); border-radius: 5px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink); }
.filter-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.filter-row input[type=date] { padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; font-family: 'IBM Plex Mono', monospace; font-size: 12px; }

.period-summary { display: flex; gap: 30px; margin-bottom: 20px; padding: 16px; background: var(--paper); border-radius: 6px; }
.period-summary p { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; margin-bottom: 4px; }
.period-summary h2 { font-family: 'IBM Plex Mono', monospace; color: var(--navy); font-size: 26px; }

.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th { text-align: left; padding: 10px 12px; background: var(--paper); color: var(--ink-soft); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--line); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.date-divider td { background: var(--paper); color: var(--navy); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 7px 12px; border-bottom: 1px solid var(--line); }

.badge { padding: 3px 9px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.badge.on { background: #dcfce7; color: #166534; }
.badge.off { background: #fee2e2; color: #991b1b; }

.btn-sm { padding: 6px 12px; border: none; border-radius: 5px; font-size: 11.5px; font-weight: 700; cursor: pointer; color: #fff; margin-right: 4px; }
.btn-sm.approve { background: #16a34a; }
.btn-sm.reject { background: var(--seal); }
.btn-sm.edit { background: var(--navy); }
.btn-sm.toggle { background: var(--gold); }

.btn-primary { padding: 11px 20px; background: var(--seal); color: #fff; border: none; border-radius: 6px; font-weight: 700; cursor: pointer; font-size: 13.5px; }
.btn-primary:hover { background: #8E1E17; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.form-grid input, .panel-card.narrow input {
  padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 5px; font-family: 'IBM Plex Mono', monospace;
  font-size: 13px; outline: none; background: #FCFAF5; width: 100%; margin-bottom: 10px;
}
.form-grid input:focus, .panel-card.narrow input:focus { border-color: var(--navy); }

.inline-input {
  width: auto; min-width: 44px; max-width: 100%;
  field-sizing: content;
  padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px;
}

.history-label { display: block; margin: 22px 0 10px; font-weight: 700; color: var(--ink-soft); font-size: 12px; text-transform: uppercase; }

@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

@media (max-width: 600px) {
  body { padding: 70px 10px 50px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card h3 { font-size: 19px; }
  .panel-card { padding: 16px; }
  .period-summary { flex-direction: column; gap: 14px; }
  .filter-row { gap: 6px; }
  .filter-btn { padding: 7px 11px; font-size: 11.5px; }
  .filter-row input[type=date] { flex: 1; min-width: 120px; }
  table { min-width: 520px; font-size: 12px; }
  .tabs { gap: 6px; }
  .tab-btn { padding: 8px 12px; font-size: 12px; }
}


/* ---------- Payment Clearance tab ---------- */
.split-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.split-row:last-child { border-bottom: none; }
.split-row span { font-size: 13px; font-weight: 600; color: var(--ink); }
.split-row input { width: 80px; }

.clearance-preview { background: var(--paper); padding: 14px; border-radius: 6px; margin-top: 14px; }
.clearance-preview p { font-size: 13.5px; margin-bottom: 10px; }

.clearance-batch { border: 1px solid var(--line); border-radius: 6px; margin-bottom: 14px; overflow: hidden; }
.clearance-batch-head { background: var(--paper); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.clearance-batch-head b { color: var(--navy); font-size: 13.5px; }
.clearance-batch-head span { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--ink-soft); }

.share-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; gap: 8px; }
.share-row .share-name { font-weight: 600; font-size: 13px; min-width: 100px; }
.share-row .share-amounts { font-size: 12px; color: var(--ink-soft); font-family: 'IBM Plex Mono', monospace; }
.share-row .share-actions { display: flex; gap: 6px; align-items: center; }
.share-row input.pay-input { width: 90px; padding: 6px 8px; }

@media (max-width: 600px) {
  .share-row { flex-direction: column; align-items: flex-start; }
  .share-row .share-actions { width: 100%; }
}

/* ---------- Clearance confirmation modal ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 800;
  background: rgba(15,42,74,0.6); align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--paper-raised); border-radius: 8px; max-width: 480px; width: 100%;
  max-height: 86vh; overflow-y: auto; padding: 22px 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.modal-box h3 { font-family: 'Lora', serif; color: var(--navy); margin-bottom: 6px; }
.modal-share-row { border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin-bottom: 10px; }
.modal-share-row .msr-name { font-weight: 700; color: var(--navy); margin-bottom: 8px; font-size: 13.5px; }
.modal-share-row .msr-due { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 8px; }
.modal-share-row label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 8px; cursor: pointer; }
.modal-share-row input[type=number] { width: 100%; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 5px; font-family: 'IBM Plex Mono', monospace; font-size: 13px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }


