:root {
  --bg: #f7f5f3;
  --surface: #ffffff;
  --border: #e6dfd9;
  --text: #1d1d1b;
  --muted: #5c5a57;
  --primary: #b14035;
  --primary-hover: #923228;
  --primary-soft: #fbf0ea;
  --primary-border: #e9c9be;
  --charcoal: #221e1b;
  --success: #1b6b4b;
  --success-bg: #edf7f2;
  --warn: #9a5b13;
  --warn-bg: #fef7ec;
  --danger: #a62626;
  --danger-bg: #fdf0f0;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "proxima-nova", "Lato", "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.topbar {
  background: var(--surface);
  border-top: 4px solid var(--primary);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
}

.brand-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--charcoal);
}

.subtitle {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.container {
  max-width: 1360px;
  margin: 22px auto;
  padding: 0 24px 48px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 13px;
  font-size: 11px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}

.btn-secondary:hover:not(:disabled) {
  background: #f5e2d8;
}

.btn-outline {
  background: var(--surface);
  color: var(--charcoal);
  border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: var(--primary-border);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  background: #efeae6;
  color: var(--charcoal);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-neutral {
  background: #efeae6;
  color: var(--muted);
}

.badge-ok {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-access {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  cursor: pointer;
}

.badge-access:hover {
  background: #f5e2d8;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #f7f5f3 0%, #fbf0ea 100%);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: 14px;
  padding: 40px 36px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 14px 36px rgba(29, 29, 27, 0.08);
}

.auth-logo {
  height: 52px;
  width: auto;
  margin: 0 auto 20px;
  display: block;
  object-fit: contain;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--charcoal);
}

.auth-btn {
  margin-top: 24px;
  width: 100%;
  padding: 12px 18px;
  font-size: 13px;
}

.banner {
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--charcoal);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
}

.banner.error {
  background: var(--danger-bg);
  border-color: #f4c7c7;
  color: var(--danger);
}

.banner.done {
  background: var(--success-bg);
  border-color: #b7e1ce;
  color: var(--success);
}

.status-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
}

.status-bar.syncing {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

.status-bar.ok {
  background: var(--success-bg);
  border-color: #b7e1ce;
}

.status-bar.error {
  background: var(--danger-bg);
  border-color: #f4c7c7;
  color: var(--danger);
}

.status-bar-left {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.status-bar-meta {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot-idle {
  background: var(--muted);
}

.dot-ok {
  background: var(--success);
}

.dot-error {
  background: var(--danger);
}

.dot-syncing {
  background: var(--primary);
  animation: pulseDot 1.2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.8); }
}

.invite-form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: #faf7f5;
  border-bottom: 1px solid var(--border);
}

.invite-form .field {
  min-width: 200px;
}

.invite-feedback {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--success);
}

.invite-feedback.error {
  color: var(--danger);
}

.notice {
  background: var(--warn-bg);
  border: 1px solid #f2d5a7;
  color: #6b3f0c;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13.5px;
}

.notice code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.filters-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}

.presets-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0ebe7;
}

.label-inline {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.spacer {
  flex: 1;
}

.chip {
  background: #f3efec;
  color: var(--charcoal);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 13px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chip.active,
.chip:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.field input,
.field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: #fff;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(177, 64, 53, 0.14);
}

.field-search {
  grid-column: span 2;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding-bottom: 8px;
  cursor: pointer;
  accent-color: var(--primary);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-primary {
  border-left: 4px solid var(--primary);
  background: linear-gradient(135deg, #ffffff 70%, #fbf0ea 100%);
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-value {
  font-size: 25px;
  font-weight: 700;
  color: var(--charcoal);
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  color: var(--muted);
}

.tabs-bar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.tab {
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.access-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  background: #faf7f5;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f2ede9;
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: #fcf9f7;
}

.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.donor-name {
  font-weight: 600;
  color: var(--charcoal);
}

.donor-email {
  font-size: 12px;
  color: var(--muted);
}

.fund-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.fund-pill {
  background: #f4efec;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11.5px;
  white-space: nowrap;
}

.pill-import {
  background: #fef3c7;
  color: #92400e;
}

.pill-noncash {
  background: #ede9fe;
  color: #5b21b6;
}

.pill-refund {
  background: #fee2e2;
  color: #991b1b;
}

.table-footer {
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--muted);
  background: #faf7f5;
  border-top: 1px solid var(--border);
}

.empty-cell {
  text-align: center;
  padding: 36px 16px !important;
  color: var(--muted);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(29, 29, 27, 0.55);
}

.modal-card {
  position: relative;
  z-index: 101;
  background: #fff;
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 12px;
  border-top: 4px solid var(--primary);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
}

.modal-header h2 {
  margin: 0;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.statement-body {
  padding: 24px;
}

.stmt-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.stmt-totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stmt-box {
  background: #faf7f5;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.stmt-box span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.stmt-box strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

@media print {
  body {
    background: #fff;
  }
  .no-print,
  .container {
    display: none !important;
  }
  .modal {
    position: static;
    display: block !important;
    padding: 0;
  }
  .modal-backdrop {
    display: none;
  }
  .modal-card {
    box-shadow: none;
    max-height: none;
    max-width: none;
  }
}
