:root {
  color-scheme: light;
  --ink: #1f2927;
  --muted: #6d7874;
  --line: #dce3df;
  --paper: #f6f7f2;
  --panel: #fff;
  --accent: #ca6e48;
  --accent-dark: #9c4d31;
  --sage: #dfe9df;
  --shadow: 0 18px 50px rgba(31, 41, 39, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
.crm-login { width: min(440px, calc(100% - 32px)); margin: 12vh auto 0; padding: 38px; background: var(--panel); box-shadow: var(--shadow); border: 1px solid var(--line); }
.crm-login__mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--ink); color: #fff; letter-spacing: .12em; font-size: .78rem; margin-bottom: 28px; }
.crm-eyebrow { margin: 0 0 10px; text-transform: uppercase; letter-spacing: .14em; font-size: .69rem; color: var(--accent-dark); font-weight: 700; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 12px; font: 500 clamp(2rem, 5vw, 3.25rem)/1.04 Georgia, serif; letter-spacing: -.03em; }
.crm-lede { color: var(--muted); line-height: 1.6; margin-bottom: 30px; }
.crm-login__note { color: var(--muted); font-size: .8rem; margin: 20px 0 0; line-height: 1.5; }
.crm-button { min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 3px; font-weight: 700; font-size: .82rem; letter-spacing: .01em; }
.crm-button--primary { background: var(--accent); color: #fff; }
.crm-button--primary:hover { background: var(--accent-dark); }
.crm-button--quiet { background: transparent; border-color: var(--line); color: var(--ink); }
.crm-project-form { display: grid; gap: 14px; margin-top: 24px; }
.crm-project-form label { display: grid; gap: 6px; color: var(--muted); font-size: .75rem; font-weight: 700; }
.crm-project-form input, .crm-project-form select, .crm-project-form textarea { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 3px; padding: 9px 10px; color: var(--ink); background: #fff; font: inherit; font-weight: 400; }
.crm-project-form textarea { min-height: 84px; resize: vertical; }
.crm-project-form .crm-checkbox-label { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
.crm-project-form .crm-checkbox-label input { width: auto; min-height: 0; }
.crm-header, .crm-main { width: min(1440px, calc(100% - 40px)); margin-inline: auto; }
.crm-header { padding: 42px 0 26px; display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.crm-header h1 { margin-bottom: 0; }
.crm-header__actions { display: flex; align-items: center; gap: 14px; }
.crm-user { color: var(--muted); font-size: .78rem; }
.crm-main { padding-bottom: 60px; }
.crm-toolbar { display: flex; align-items: end; gap: 12px; padding: 14px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); margin-bottom: 16px; }
.crm-date-field { display: grid; gap: 5px; }
.crm-date-field label { color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-size: .64rem; font-weight: 700; }
.crm-date-field input { min-height: 42px; border: 1px solid var(--line); border-radius: 3px; padding: 8px 10px; color: var(--ink); background: #fff; }
.crm-message { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); color: var(--muted); font-size: .84rem; }
.crm-message--error { border-color: #d8a394; background: #fff5f1; color: #7f3d2a; }
.crm-message--info { background: #f7fbf8; }
.crm-time-note { margin: 0 0 12px; color: var(--muted); font-size: .74rem; line-height: 1.5; }
.crm-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.crm-metrics article { padding: 18px; background: var(--panel); border: 1px solid var(--line); }
.crm-metrics span { display: block; color: var(--muted); font-size: .72rem; }
.crm-metrics strong { display: block; margin-top: 10px; font-size: 1.75rem; font-weight: 500; }
.crm-updated { color: var(--muted); text-align: right; font-size: .72rem; min-height: 16px; }
.crm-panel { background: var(--panel); border: 1px solid var(--line); margin-top: 16px; overflow: hidden; }
.crm-panel__heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.crm-panel__heading h2 { margin: 0; font: 500 1.25rem/1.1 Georgia, serif; }
.crm-panel__heading span { color: var(--muted); font-size: .72rem; }
.crm-panel__heading--stacked { align-items: center; }
.crm-panel__heading--stacked > div { display: grid; gap: 5px; }
.crm-panel__heading--stacked .crm-button { flex: 0 0 auto; }
.crm-panel__actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.crm-custom-payment-form { display: grid; gap: 14px; padding: 20px; }
.crm-custom-payment-form label { display: grid; gap: 6px; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.crm-custom-payment-form input, .crm-custom-payment-form select { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 3px; padding: 10px 11px; color: var(--ink); background: #fff; font: inherit; font-weight: 400; letter-spacing: normal; text-transform: none; }
.crm-custom-payment-form .crm-checkbox-label { display: flex; align-items: center; gap: 8px; }
.crm-custom-payment-form .crm-checkbox-label input { width: auto; min-height: 0; }
.crm-form-result { min-height: 20px; margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.crm-form-result strong { color: var(--ink); }
.crm-form-result a { margin-left: 8px; color: var(--accent-dark); font-weight: 700; }
.crm-form-result small { display: block; margin-top: 4px; color: var(--muted); }
.crm-communication-tools { display: flex; align-items: end; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: #fbfcfa; }
.crm-search-field, .crm-status-field { display: grid; gap: 5px; color: var(--muted); font-size: .65rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.crm-search-field { flex: 1 1 360px; }
.crm-status-field { flex: 0 0 180px; }
.crm-search-field input, .crm-status-field select, .crm-compose-form input, .crm-compose-form select, .crm-compose-form textarea, .crm-communication-form input, .crm-communication-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 3px; padding: 10px 11px; color: var(--ink); background: #fff; font: inherit; font-weight: 400; letter-spacing: normal; text-transform: none; }
.crm-search-field input, .crm-status-field select { min-height: 42px; }
.crm-error-note { color: #9b4432 !important; }
.crm-table-wrap { overflow-x: auto; }
.crm-communication-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 16px; background: #f8faf7; }
.crm-communication-box { min-width: 0; overflow: hidden; border: 1px solid var(--line); background: var(--panel); }
.crm-communication-box__heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); background: #fff; }
.crm-communication-box__heading h3 { margin: 0; font: 600 1rem/1.15 Georgia, serif; }
.crm-communication-box__heading span { display: block; max-width: 250px; margin-top: 5px; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.crm-communication-box__heading > strong { display: grid; place-items: center; min-width: 28px; height: 28px; border-radius: 50%; background: var(--sage); color: #49614e; font-size: .72rem; font-weight: 700; }
.crm-communication-box .crm-communication-table { min-width: 540px; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 13px 20px; border-bottom: 1px solid #edf0ee; text-align: left; vertical-align: top; font-size: .8rem; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .62rem; font-weight: 700; white-space: nowrap; }
td strong { display: block; font-weight: 700; }
td small { display: block; color: var(--muted); margin-top: 4px; font-size: .72rem; }
tr:last-child td { border-bottom: 0; }
.crm-badge { display: inline-block; margin: 0 4px 4px 0; padding: 4px 7px; border-radius: 99px; background: var(--sage); color: #49614e; font-size: .64rem; text-transform: capitalize; white-space: nowrap; }
.crm-badge--payment-pending, .crm-badge--deposit-pending, .crm-badge--application-received, .crm-badge--scheduled { background: #fbecd8; color: #865428; }
.crm-badge--refunded, .crm-badge--payment-failed, .crm-badge--error { background: #f6ded8; color: #8a3e31; }
.crm-badge--not-required, .crm-badge--none { background: #eef1ef; color: #68736e; }
.crm-empty { color: var(--muted); text-align: center; padding-block: 28px; }
.crm-two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.crm-message-cell { max-width: 420px; white-space: pre-wrap; line-height: 1.5; }
.crm-open-button { border: 0; border-bottom: 1px solid currentColor; padding: 0 0 2px; background: transparent; color: var(--accent-dark); font-size: .74rem; font-weight: 700; }
.crm-open-button:hover { color: var(--ink); }
.crm-inline-link { color: var(--accent-dark); font-size: .74rem; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.crm-muted { color: var(--muted); font-size: .74rem; }
.crm-event-form { display: grid; gap: 15px; padding-top: 22px; }
.crm-event-form > label, .crm-event-form .crm-form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.crm-event-form input, .crm-event-form select, .crm-event-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 3px; padding: 10px 11px; color: var(--ink); background: #fff; font: inherit; font-weight: 400; letter-spacing: normal; text-transform: none; }
.crm-event-form input, .crm-event-form select { min-height: 44px; }
.crm-event-form textarea { min-height: 100px; line-height: 1.55; resize: vertical; }
.crm-checkbox-label { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 8px; }
.crm-checkbox-label input { width: auto !important; min-height: 0 !important; }
.crm-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.crm-section-heading > span { color: var(--muted); font-size: .65rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.crm-section-heading .crm-button { min-height: 34px; padding: 7px 11px; font-size: .7rem; }
.crm-inline-select { width: 100%; min-height: 34px; border: 1px solid var(--line); border-radius: 3px; padding: 6px 8px; color: var(--ink); background: #fff; font: inherit; font-size: .75rem; }
.crm-space-status { color: var(--muted); font-size: .74rem; }
.crm-timeline { display: grid; gap: 10px; }
.crm-timeline-item { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #edf0ee; }
.crm-timeline-item:first-child { border-top: 0; padding-top: 0; }
.crm-timeline-item strong, .crm-timeline-item small { display: block; }
.crm-timeline-item strong { font-size: .8rem; }
.crm-timeline-item small { margin-top: 4px; color: var(--muted); font-size: .7rem; }
.crm-badge--attendance-attended { background: #dbece0; color: #3f6849; }
.crm-badge--attendance-waitlisted { background: #fbecd8; color: #865428; }
.crm-badge--attendance-no-show, .crm-badge--attendance-cancelled { background: #f6ded8; color: #8a3e31; }
.crm-dialog-actions--compact { padding-top: 12px; }
.crm-dialog-actions--compact .crm-button { text-decoration: none; }
.crm-button--danger { border-color: #d8a394; color: #8a3e31; }
.crm-payment-links { display: grid; gap: 8px; margin-top: 14px; }
.crm-payment-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); background: #fbfcfa; }
.crm-payment-link strong, .crm-payment-link small { display: block; }
.crm-payment-link strong { font-size: .78rem; text-transform: capitalize; }
.crm-payment-link small { margin-top: 4px; color: var(--muted); font-size: .7rem; }
.crm-payment-link a { color: var(--accent-dark); font-size: .72rem; font-weight: 700; white-space: nowrap; }
.crm-detail-dialog { width: min(680px, calc(100% - 28px)); max-height: min(780px, calc(100vh - 40px)); padding: 0; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); box-shadow: 0 24px 80px rgba(31, 41, 39, .22); }
.crm-detail-dialog::backdrop { background: rgba(20, 29, 27, .45); }
.crm-detail-dialog > div { padding: 26px; }
.crm-dialog-head { display: grid; grid-template-columns: 1fr auto; gap: 6px 18px; align-items: start; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.crm-dialog-head .crm-eyebrow { grid-column: 1; margin-bottom: 0; }
.crm-dialog-head h2 { grid-column: 1; margin: 0; font: 500 1.8rem/1.1 Georgia, serif; }
.crm-icon-button { grid-column: 2; grid-row: 1 / span 2; width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; }
.crm-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 22px 0; }
.crm-detail-grid span, .crm-dialog-section > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .65rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.crm-detail-grid strong { display: block; font-size: .86rem; font-weight: 600; line-height: 1.45; }
.crm-dialog-section { padding: 16px 0; border-top: 1px solid var(--line); }
.crm-dialog-section p { margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.55; white-space: pre-wrap; }
.crm-dialog-copy { color: var(--ink) !important; }
.crm-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 22px; }
.crm-communication-form, .crm-compose-form { display: grid; gap: 15px; padding-top: 22px; }
.crm-communication-form > label, .crm-compose-form > label, .crm-form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.crm-communication-form textarea, .crm-compose-form textarea { min-height: 220px; line-height: 1.55; resize: vertical; }
.crm-compose-form input, .crm-compose-form select, .crm-communication-form input { min-height: 44px; }
.crm-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.crm-form-note { margin: -2px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }

@media (max-width: 850px) {
  .crm-header { align-items: start; flex-direction: column; }
  .crm-header__actions { width: 100%; justify-content: space-between; }
  .crm-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-two-columns { grid-template-columns: 1fr; }
  .crm-communication-columns { grid-template-columns: 1fr; }
  .crm-communication-tools { align-items: stretch; flex-direction: column; }
  .crm-search-field, .crm-status-field { flex-basis: auto; }
}

@media (max-width: 560px) {
  .crm-header, .crm-main { width: min(100% - 24px, 1440px); }
  .crm-header { padding-top: 26px; }
  .crm-toolbar { align-items: stretch; flex-direction: column; }
  .crm-toolbar .crm-button { width: 100%; }
  .crm-login { padding: 28px; margin-top: 7vh; }
  .crm-metrics { gap: 8px; }
  .crm-metrics article { padding: 14px; }
  .crm-metrics strong { font-size: 1.4rem; }
  .crm-detail-dialog > div { padding: 20px; }
  .crm-detail-grid { grid-template-columns: 1fr; gap: 13px; }
  .crm-panel__heading--stacked { align-items: flex-start; flex-direction: column; }
  .crm-panel__heading--stacked .crm-button { width: 100%; }
  .crm-panel__actions { width: 100%; align-items: stretch; flex-direction: column; }
  .crm-panel__actions .crm-status-field { width: 100%; }
  .crm-panel__actions .crm-button { width: 100%; }
  .crm-form-grid { grid-template-columns: 1fr; }
  .crm-communication-table { min-width: 0; }
  .crm-communication-box .crm-communication-table { min-width: 0; }
  .crm-communication-table thead { display: none; }
  .crm-communication-table tr { display: block; padding: 13px 16px; border-bottom: 1px solid #edf0ee; }
  .crm-communication-table tr:last-child { border-bottom: 0; }
  .crm-communication-table td { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; border: 0; font-size: .8rem; }
  .crm-communication-table td::before { flex: 0 0 58px; color: var(--muted); content: attr(data-label); font-size: .6rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
  .crm-communication-table td.crm-empty { display: block; text-align: center; }
  .crm-communication-table td.crm-empty::before { display: none; }
}

@media print {
  body { background: #fff; }
  .crm-header, .crm-main { width: 100%; }
  .crm-header { padding: 0 0 18px; }
  .crm-header__actions, .crm-toolbar { display: none; }
  .crm-panel, .crm-metrics article { box-shadow: none; }
  .crm-two-columns { grid-template-columns: 1fr; }
  .crm-panel { break-inside: avoid; }
  .crm-metrics { grid-template-columns: repeat(4, 1fr); }
  th, td { padding: 8px 10px; }
}
