/* Centerville-Farmington Rotary — Treasurer app theme (Rotary Royal Blue + Gold) */
:root {
  --royal: #17458f;
  --royal-dark: #0f3170;
  --royal-tint: #e8eefa;
  --gold: #f7a81b;
  --gold-dark: #c98600;
  --gold-tint: #fff5de;
  --azure: #0067c8;
  --ink: #1b2430;
  --muted: #5d6b80;
  --line: #dbe2ee;
  --bg: #f3f6fb;
  --card: #ffffff;
  --ok: #1b7f3b;
  --ok-bg: #e5f5ea;
  --warn: #8a5a00;
  --warn-bg: #fff2d6;
  --bad: #b3261e;
  --bad-bg: #fde8e6;
  --info: #0b5cab;
  --info-bg: #e3effc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 49, 112, .08), 0 4px 14px rgba(15, 49, 112, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Open Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--azure); }
h1, h2, h3 { line-height: 1.25; color: var(--royal-dark); margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(180deg, var(--royal) 0%, var(--royal-dark) 100%);
  color: #fff;
  border-bottom: 4px solid var(--gold);
}
#topbar .brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; min-width: 0; }
#topbar .brand img { width: 42px; height: 42px; border-radius: 50%; background: #fff; object-fit: contain; flex: none; }
#topbar .brand .t1 { font-weight: 700; font-size: 1rem; line-height: 1.15; }
#topbar .brand .t2 { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
#topbar .spacer { flex: 1; }
#topbar .who { text-align: right; font-size: .82rem; line-height: 1.25; }
#topbar .who strong { display: block; font-size: .9rem; }
#topbar .menu-btn { display: none; background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 1.1rem; cursor: pointer; }
#topbar .signout { background: transparent; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: .8rem; cursor: pointer; }
#topbar .signout:hover { background: rgba(255,255,255,.12); }

#layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 62px); }
#nav { background: #fff; border-right: 1px solid var(--line); padding: 14px 10px 30px; }
#nav .group { margin-bottom: 14px; }
#nav .group h4 { margin: 0 0 4px; padding: 0 10px; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
#nav a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: .92rem;
}
#nav a:hover { background: var(--royal-tint); }
#nav a.active { background: var(--royal); color: #fff; }
#nav a .count { background: var(--gold); color: #3a2800; border-radius: 999px; font-size: .72rem; padding: 1px 8px; font-weight: 700; }
main#app { padding: 22px clamp(14px, 3vw, 34px) 60px; max-width: 1280px; width: 100%; }

@media (max-width: 900px) {
  #layout { grid-template-columns: 1fr; }
  #nav { display: none; border-right: 0; border-bottom: 1px solid var(--line); }
  body.nav-open #nav { display: block; }
  #topbar .menu-btn { display: inline-block; }
  #topbar .who { display: none; }
  #topbar .brand .t1 { font-size: .9rem; }
}

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin: 2px 0 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- cards, tiles, tabs ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card > h2:first-child, .card > .card-head:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--royal); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile:hover { border-left-color: var(--gold); transform: translateY(-1px); }
.tile .v { font-size: 1.8rem; font-weight: 700; color: var(--royal-dark); line-height: 1.1; }
.tile .l { color: var(--muted); font-size: .85rem; font-weight: 600; }
.tile .s { color: var(--muted); font-size: .8rem; }
.tile.alert { border-left-color: var(--bad); }
.tile.alert .v { color: var(--bad); }
.tile.todo { border-left-color: var(--gold); }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a, .tabs button { background: none; border: 0; padding: 9px 16px; font: inherit; font-weight: 600; color: var(--muted); text-decoration: none; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.active, .tabs button.active { color: var(--royal); border-bottom-color: var(--gold); }
.tabs a:hover, .tabs button:hover { color: var(--royal); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--royal); background: #fff; color: var(--royal); font: inherit; font-weight: 600; padding: 8px 16px; border-radius: 8px; cursor: pointer; text-decoration: none; min-height: 38px; }
.btn:hover:not(:disabled) { background: var(--royal-tint); }
.btn.primary { background: var(--royal); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--royal-dark); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #2d2000; }
.btn.gold:hover:not(:disabled) { background: #ffb938; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: var(--bad-bg); }
.btn.danger.solid { background: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid rgba(247,168,27,.7); outline-offset: 1px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label, .field > .lbl { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; color: var(--royal-dark); }
.field .hint { color: var(--muted); font-size: .8rem; margin-top: 3px; }
.field .req { color: var(--bad); }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #b9c4d8; border-radius: 8px; background: #fff; color: var(--ink); min-height: 40px;
}
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { min-height: 70px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { background: #eef1f6; color: #6b7686; }
input.invalid, select.invalid { border-color: var(--bad); background: var(--bad-bg); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 6px; border: 1px solid #b9c4d8; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; background: #fff; margin: 0; color: var(--ink); }
.radio-row input { width: auto; min-height: 0; }
.radio-row label:has(input:checked) { border-color: var(--royal); background: var(--royal-tint); color: var(--royal-dark); }
.money-input { position: relative; }
.money-input::before { content: '$'; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money-input input { padding-left: 24px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.error-text { color: var(--bad); font-weight: 600; margin: 8px 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; background: var(--royal-tint); color: var(--royal-dark); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; padding: 9px 12px; white-space: nowrap; border-bottom: 2px solid var(--line); position: sticky; top: 0; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { background: #d9e3f7; }
table.data td { padding: 9px 12px; border-bottom: 1px solid #edf0f6; vertical-align: top; }
table.data tbody tr:nth-child(even) { background: #fafbfe; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--gold-tint); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tfoot td { font-weight: 700; background: var(--royal-tint); border-top: 2px solid var(--line); }
table.data tr.row-mismatch, table.data tbody tr.row-mismatch:nth-child(even) { background: var(--bad-bg); }
table.data tr.row-mismatch td:first-child { box-shadow: inset 5px 0 0 var(--bad); }
table.data tr.row-mismatch td { color: #6d130e; }
table.data tr.row-match td:first-child { box-shadow: inset 5px 0 0 var(--ok); }
table.data tr.row-pending td:first-child { box-shadow: inset 5px 0 0 var(--gold); }
table.data tr.subtotal td { background: #f0f4fb; font-weight: 700; }
table.data tr.group-head td { background: var(--royal); color: #fff; font-weight: 700; letter-spacing: .03em; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* ---------- badges, banners ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.gray { background: #eceff4; color: #4a5568; }
.badge.gold { background: var(--gold); color: #2d2000; }
.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; border: 1px solid; }
.banner.info { background: var(--info-bg); border-color: #b9d4f2; color: #0a3f77; }
.banner.warn { background: var(--warn-bg); border-color: #f0d28a; color: var(--warn); }
.banner.bad { background: var(--bad-bg); border-color: #f1b3ae; color: var(--bad); }
.banner.ok { background: var(--ok-bg); border-color: #a9d9b7; color: var(--ok); }
.banner.locked { background: #eef1f6; border-color: #c4ccda; color: #33415a; }

/* ---------- budget ---------- */
.committee-card h2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.bar { height: 8px; background: #e5eaf3; border-radius: 99px; overflow: hidden; min-width: 90px; }
.bar > span { display: block; height: 100%; background: var(--royal); }
.bar.over > span { background: var(--bad); }
.bar.income > span { background: var(--ok); }
.neg { color: var(--bad); font-weight: 700; }
.pos { color: var(--ok); }
.summary-strip { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.summary-strip .item { flex: 1 1 170px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.summary-strip .item .l { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.summary-strip .item .v { font-size: 1.25rem; font-weight: 700; color: var(--royal-dark); }
.edit-row { display: grid; grid-template-columns: 130px 1fr 150px 40px; gap: 8px; align-items: center; margin-bottom: 8px; }
.edit-row .head { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
@media (max-width: 640px) { .edit-row { grid-template-columns: 1fr 1fr; } .edit-row > :nth-child(2) { grid-column: 1 / -1; } }

/* ---------- deposit builder ---------- */
.total-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; background: var(--royal); color: #fff; border-radius: var(--radius); padding: 14px 18px; margin: 14px 0; border-left: 8px solid var(--gold); }
.total-bar .amt { font-size: 2rem; font-weight: 700; line-height: 1; }
.total-bar .parts { display: flex; gap: 22px; flex-wrap: wrap; font-size: .85rem; }
.total-bar .parts b { display: block; font-size: 1.05rem; }

/* ---------- modal / toast ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,32,70,.55); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 14px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: min(560px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.35); border-top: 6px solid var(--gold); }
.modal.wide { width: min(860px, 100%); }
.modal header { padding: 16px 20px 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal header h2 { margin: 0; }
.modal header .x { background: none; border: 0; font-size: 1.5rem; cursor: pointer; color: var(--muted); line-height: 1; }
.modal .body { padding: 14px 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; flex-wrap: wrap; }
.modal .modal-error { color: var(--bad); font-weight: 600; padding: 0 20px; }
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--royal-dark); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); border-left: 5px solid var(--gold); font-weight: 600; }
.toast.error { background: var(--bad); border-left-color: #fff; }
.toast.ok { background: var(--ok); border-left-color: #fff; }

.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--royal); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- receipts, details ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin: 0; }
.dl dt { font-weight: 600; color: var(--muted); font-size: .85rem; }
.dl dd { margin: 0; }
@media (max-width: 560px) { .dl { grid-template-columns: 1fr; } .dl dt { margin-top: 6px; } }
.receipt-box { border: 1px dashed #b9c4d8; border-radius: var(--radius); padding: 14px; background: #fafbfe; }
.receipt-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.receipt-preview { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
.receipt-preview img { max-height: 110px; max-width: 140px; border-radius: 8px; border: 1px solid var(--line); }
.receipt-view img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.receipt-view iframe { width: 100%; height: 60vh; border: 1px solid var(--line); border-radius: 8px; }
.approver-slots { display: grid; gap: 10px; margin: 12px 0; }
.approver-slot { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 2px dashed #b9c4d8; border-radius: 10px; }
.approver-slot.done { border: 2px solid var(--ok); background: var(--ok-bg); }
.approver-slot .n { width: 28px; height: 28px; border-radius: 50%; background: var(--royal); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.approver-slot.done .n { background: var(--ok); }
.signin-card { max-width: 440px; margin: 9vh auto; text-align: center; }
.signin-card img { width: 84px; height: 84px; border-radius: 50%; background: #fff; border: 3px solid var(--gold); }
.signin-card .gbtn { display: flex; justify-content: center; margin: 18px 0 8px; min-height: 44px; }
.stack > * + * { margin-top: 12px; }

@media print {
  #topbar, #nav, .toolbar, .btn, .tabs, .toasts { display: none !important; }
  #layout { display: block; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
