:root {
  color-scheme: light;
  --ink: #111111;
  --muted: #5f5f5f;
  --line: #dedede;
  --surface: #ffffff;
  --canvas: #ffffff;
  --accent: #ffed00;
  --accent-dark: #d8c900;
  --accent-ink: #766d00;
  --soft-accent: #fff8a8;
  --danger: #9f3434;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
a { color: var(--accent-dark); }
.topbar { min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 5vw; background: var(--surface); border-bottom: 3px solid var(--accent); }
.brand { display: inline-flex; align-items: center; flex: 0 0 auto; color: var(--ink); text-decoration: none; }
.brand-logo { display: block; width: clamp(150px, 15vw, 190px); height: auto; }
.user-menu { display: flex; align-items: center; gap: 1rem; color: var(--muted); font-size: .9rem; }
.user-menu form { margin: 0; }
.nav-link { color: var(--ink); font-weight: 750; text-decoration: none; }
.nav-link:hover { text-decoration: underline; text-decoration-thickness: 3px; text-decoration-color: var(--accent); }
.page-shell { width: min(1180px, 90vw); margin: 0 auto; padding: 3rem 0 5rem; }
.page-shell-wide { width: calc(100% - clamp(100px, 10vw, 200px)); max-width: none; }
.page-shell-profile { width: min(1280px, calc(100% - clamp(48px, 7vw, 112px))); padding-top: 1.5rem; }
.site-footer { margin-top: 2.5rem; text-align: center; font-size: .78rem; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.auth-card, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; box-shadow: 0 10px 30px rgba(17, 17, 17, .05); }
.auth-card { width: min(430px, 100%); margin: 5vh auto; padding: 2rem; }
.auth-card { border-top: 8px solid var(--accent); }
.narrow { max-width: 620px; margin: 0 auto; }
.eyebrow { margin: 0 0 .4rem; color: var(--accent-ink); font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0 0 .6rem; font-size: clamp(1.8rem, 4vw, 2.65rem); letter-spacing: -.04em; }
h2 { margin: 0; font-size: 1.1rem; }
.muted, .subline { color: var(--muted); }
.subline { margin-top: .2rem; font-size: .84rem; }
.page-heading, .profile-heading, .section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 1.8rem; height: 1.8rem; padding: 0 .5rem; border-radius: 999px; background: var(--accent); color: var(--ink); font-size: .8rem; vertical-align: middle; }
.filters { display: flex; align-items: end; flex-wrap: wrap; gap: .8rem; margin: 2rem 0 1rem; }
.filters label { flex: 0 1 190px; }
.filters .grow { flex: 1 1 260px; }
.filters .filter-checkbox { flex: 0 0 auto; min-height: 2.7rem; padding: 0 .2rem; white-space: nowrap; }
label { display: grid; gap: .4rem; color: var(--muted); font-size: .84rem; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: .72rem .8rem; background: #fff; color: var(--ink); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(255, 237, 0, .45); border-color: var(--ink); }
.stack { display: grid; gap: 1rem; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 9px; padding: .72rem 1rem; font: inherit; font-weight: 750; cursor: pointer; text-decoration: none; }
.button-primary { background: var(--accent); color: var(--ink); }
.button-primary:hover { background: var(--accent-dark); }
.button-ghost { padding: .35rem .6rem; background: transparent; color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
.member-table-wrap table { min-width: 1320px; font-size: .8rem; }
.member-table-wrap th, .member-table-wrap td { padding: .72rem .65rem; }
.member-table-wrap th { font-size: .68rem; }
th, td { padding: .9rem 1rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .76rem; letter-spacing: .04em; text-transform: uppercase; }
.table-sort { display: inline-flex; align-items: center; gap: .35rem; color: inherit; text-decoration: none; white-space: nowrap; }
.table-sort:hover { color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: var(--accent); }
.sort-indicator { color: var(--accent-ink); font-size: .95rem; line-height: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfe; }
.member-link { color: var(--ink); font-family: inherit; font-size: inherit; font-weight: 800; text-decoration: none; }
.member-link:hover { text-decoration: underline; text-decoration-thickness: 3px; text-decoration-color: var(--accent); }
.member-link.member-link-muted { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--muted); }
.member-link.member-link-muted:hover { text-decoration: line-through; text-decoration-thickness: 3px; text-decoration-color: var(--accent); }
.badge { display: inline-block; max-width: 100%; padding: .25rem .55rem; border-radius: 999px; background: var(--accent); color: var(--ink); font-size: .76rem; font-weight: 700; }
.badge-neutral { background: #e5e7eb; color: #626b75; }
.badge-first-contact { background: var(--accent); color: var(--ink); }
.badge-soon-expiring { background: #f6d09a; color: #7b4a0b; }
.badge-reminder { background: #e8bfbd; color: #74312e; }
.badge-up-to-date { background: #d4e8d3; color: #315f38; }
.badge-large { margin-top: .5rem; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
.alert { margin: 1rem 0; border-radius: 9px; padding: .8rem 1rem; }
.alert-error { background: #fff0f0; color: var(--danger); }
.alert-success { background: #effbea; color: #2f6b1f; }
.is-hidden { display: none; }
.back-link { display: inline-block; margin-bottom: 1.5rem; text-decoration: none; }
.profile-heading { align-items: center; margin-bottom: 1.5rem; }
.profile-identity { display: flex; align-items: center; gap: 1rem; }
.profile-photo, .photo-preview { width: 112px; height: 148px; overflow: hidden; border: 4px solid var(--accent); border-radius: 10px; background: var(--soft-accent); }
.profile-photo img, .photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-photo-empty, .map-detail-photo-empty { display: grid; place-items: center; color: var(--accent-ink); font-family: Arial, sans-serif; font-size: 3.4rem; line-height: 1; }
.profile-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: .75rem; }
.profile-actions form { margin: 0; }
.profile-page-layout { display: grid; gap: .75rem; }
.profile-inline-form { display: contents; }
.profile-inline-form .profile-edit-only { display: none; }
.profile-inline-form.is-editing [data-profile-view] { display: none; }
.profile-inline-form.is-editing .profile-edit-only { display: block; }
.profile-inline-form.is-editing .profile-edit-actions { display: flex; }
.profile-inline-form.is-editing .checkbox-label { display: flex; }
.profile-inline-form.is-editing .tag-chip button { display: inline-flex; }
.profile-inline-form.is-editing .card { border-color: #c9bd31; box-shadow: 0 8px 24px rgba(17, 17, 17, .06), 0 0 0 2px rgba(255, 237, 0, .15); }
.profile-hero { order: 1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .9rem; overflow: hidden; padding: 1rem 1.15rem; border-top: 4px solid var(--accent); }
.profile-hero .profile-identity { min-width: 0; }
.profile-hero .profile-photo { width: 76px; height: 100px; border-width: 3px; border-radius: 9px; }
.profile-hero .profile-photo-empty { font-size: 2.5rem; }
.profile-title-block { min-width: 0; }
.profile-title-block h1 { margin-bottom: .45rem; font-size: clamp(1.55rem, 3vw, 2.15rem); overflow-wrap: anywhere; }
.profile-name-input { width: min(560px, 100%); margin: .1rem 0 .65rem; font-size: 1.35rem; font-weight: 800; }
.profile-status-select { width: min(300px, 100%); }
.profile-hero-actions { display: flex; align-items: center; justify-content: flex-end; align-self: center; }
.profile-hero-actions .button { padding: .62rem .85rem; white-space: nowrap; }
.profile-edit-actions { align-items: center; flex-wrap: nowrap; gap: .35rem; }
.profile-photo-editor { grid-column: 1 / -1; padding-top: .75rem; border-top: 1px solid var(--line); }
.profile-photo-editor > label:first-child { max-width: 520px; }
.profile-dashboard { order: 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.profile-section { padding: 1rem 1.1rem; }
.profile-section-heading { margin-bottom: .55rem; }
.profile-section-heading .eyebrow { margin-bottom: .2rem; }
.inline-fields { display: grid; gap: 0; }
.inline-property { display: grid; grid-template-columns: minmax(135px, .8fr) minmax(0, 1.2fr); align-items: center; gap: .6rem; min-height: 2.35rem; padding: .32rem 0; border-bottom: 1px solid #eeeeea; }
.inline-property:last-child { border-bottom: 0; }
.inline-label { color: var(--muted); font-size: .76rem; font-weight: 750; letter-spacing: .02em; }
.inline-value { min-width: 0; color: var(--ink); font-size: .92rem; font-weight: 700; overflow-wrap: anywhere; }
.inline-derived-value { padding: .7rem .8rem; border: 1px dashed #c7bb39; border-radius: 9px; background: #fffdf0; color: var(--accent-ink); font-size: .9rem; font-weight: 750; }
.profile-inline-form.is-editing .inline-property { align-items: start; }
.profile-inline-form.is-editing .inline-property input,
.profile-inline-form.is-editing .inline-property select { padding: .5rem .62rem; }
.profile-tags-section { order: 4; }
.profile-tag-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.profile-tag-groups .tag-list { align-content: start; }
.tag-empty { font-weight: 500; }
.profile-lower-grid { order: 3; display: grid; grid-template-columns: minmax(280px, .7fr) minmax(0, 1.3fr); gap: .75rem; }
.note-compose-card, .history-card { margin-top: 0; padding: 1rem 1.1rem; }
.note-compose-card .section-heading, .history-card .section-heading { margin-bottom: .65rem; }
.note-compose-card .stack { gap: .65rem; }
.history-card .timeline { max-height: 350px; overflow: auto; padding-right: .35rem; }
.profile-delete { order: 5; display: flex; justify-content: flex-end; margin-top: .15rem; }
.member-create-form { display: grid; gap: .75rem; }
.member-form-hero { order: auto; }
.member-form-title { flex: 1; }
.profile-primary-fields { display: grid; grid-template-columns: minmax(260px, 1.4fr) minmax(190px, .6fr); gap: .65rem; align-items: end; }
.profile-primary-fields label { gap: .25rem; }
.profile-primary-fields label > span { font-size: .72rem; }
.member-form-hero .profile-name-input { width: 100%; margin: 0; padding: .55rem .65rem; font-size: 1rem; }
.member-form-hero .profile-status-select { width: 100%; padding: .55rem .65rem; }
.member-form-actions { align-self: end; }
.member-photo-editor { display: flex; align-items: end; gap: 1rem; padding-top: .55rem; }
.member-photo-editor > label:first-child { width: min(520px, 100%); }
.member-photo-editor input[type="file"] { padding: .45rem .55rem; }
.member-create-form .profile-dashboard { order: auto; }
.member-create-form .inline-property input,
.member-create-form .inline-property select { padding: .5rem .62rem; }
.member-form-tags { order: auto; }
.status-cell { min-width: 170px; }
.member-table-wrap .status-cell { min-width: 135px; }
.status-cell .badge { white-space: nowrap; }
.member-table-wrap .badge { padding: .2rem .45rem; font-size: .7rem; }
.contact-cell { max-width: 260px; overflow-wrap: anywhere; }
.event-cell { width: 6.2rem; min-width: 6.2rem; text-align: center !important; vertical-align: middle !important; }
.event-checkbox-label { display: flex; align-items: center; justify-content: center; min-height: 1.7rem; cursor: pointer; }
.event-checkbox-label input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--accent-dark); cursor: pointer; }
.event-checkbox-label input:disabled { cursor: not-allowed; opacity: .65; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.event-tag-field { grid-column: 1 / -1; padding-top: .9rem; border-top: 1px solid var(--line); }
.admin-event-columns { margin-top: 1rem; }
.admin-event-columns .section-heading { margin-bottom: 1rem; }
.admin-event-column-form { margin-bottom: 1.25rem; }
.admin-event-columns-table { margin-top: 1rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; padding-top: .5rem; border-top: 1px solid var(--line); }
.tag-field, .photo-field, .derived-fields { display: grid; gap: .6rem; }
.tag-field-label { color: var(--muted); font-size: .84rem; font-weight: 750; }
.tag-list { display: flex; flex-wrap: wrap; gap: .5rem; min-height: 1.25rem; }
.tag-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .45rem .35rem .7rem; border-radius: 999px; background: var(--accent); color: var(--ink); font-size: .82rem; font-weight: 750; }
.tag-chip button { width: 1.2rem; height: 1.2rem; padding: 0; border: 0; border-radius: 50%; background: rgba(17, 17, 17, .12); color: var(--ink); font-size: 1rem; line-height: 1; cursor: pointer; }
.tag-chip button:hover { background: rgba(17, 17, 17, .25); }
.tag-field > select, .tag-field > input { max-width: 560px; }
.photo-field input[type="file"] { padding: .55rem; }
.checkbox-label { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: .5rem; color: var(--muted); font-size: .84rem; font-weight: 500; }
.checkbox-label input { width: auto; }
.form-hint { margin: 0; color: var(--muted); font-size: .8rem; }
.derived-fields { grid-template-columns: auto auto auto; align-items: center; padding: 1rem; border: 1px dashed var(--line); border-radius: 10px; background: #fffdf0; }
.derived-fields .form-hint { grid-column: 1 / -1; }
input[readonly] { background: #f6f6f6; color: var(--muted); }
.details { display: grid; grid-template-columns: minmax(130px, .5fr) 1fr; gap: .75rem 1rem; margin: 1.25rem 0 0; }
.details dt { color: var(--muted); font-size: .86rem; }
.details dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.notes-card { margin-top: 1rem; }
.timeline { display: grid; gap: .7rem; margin-top: .7rem; }
.note { border-left: 3px solid var(--accent); padding: .05rem 0 .05rem .75rem; }
.note p { margin: .35rem 0 0; white-space: pre-wrap; }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; color: var(--muted); font-size: .82rem; }
.note-meta strong { color: var(--ink); }
.note-actions { display: inline-flex; align-items: center; gap: .55rem; margin-left: auto; }
.note-actions form { margin: 0; }
.note-actions a, .note-actions button { border: 0; padding: 0; background: transparent; color: var(--accent-ink); font: inherit; font-size: .78rem; font-weight: 750; cursor: pointer; text-decoration: none; }
.note-actions a:hover, .note-actions button:hover { color: var(--ink); text-decoration: underline; }
.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.danger-button { color: var(--danger); }
.map-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: .8rem; margin: 1.5rem 0 .7rem; }
.map-toolbar label { flex: 1 1 160px; }
.map-summary { margin: .6rem 0 .8rem; color: var(--muted); font-size: .86rem; font-weight: 700; }
.map-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1rem; min-height: 650px; }
.map-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 10px 30px rgba(17, 17, 17, .05); }
#member-map { min-height: 650px; height: 100%; }
.map-panel { min-width: 0; min-height: 650px; overflow: auto; }
.map-panel h2 { margin-bottom: .55rem; }
.map-member-list { display: grid; gap: .6rem; margin-top: 1rem; }
.map-member-row { display: grid; gap: .25rem; width: 100%; padding: .8rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
.map-member-row:hover { border-color: var(--ink); box-shadow: 4px 4px 0 var(--accent); }
.map-member-row span { color: var(--muted); font-size: .8rem; }
.map-member-detail { display: grid; gap: .7rem; }
.map-detail-photo { width: 112px; height: 148px; overflow: hidden; border: 4px solid var(--accent); border-radius: 10px; background: var(--soft-accent); object-fit: cover; }
.map-cluster-icon { border: 0; background: transparent; }
.map-cluster-circle { display: flex; align-items: center; justify-content: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--accent); color: var(--ink); font-size: .95rem; font-weight: 850; box-shadow: 0 3px 8px rgba(17, 17, 17, .2); }
.map-badges, .map-tags { display: flex; flex-wrap: wrap; gap: .45rem; }
.map-tags .tag-chip { font-size: .74rem; }
.map-detail-link { margin-top: .3rem; }
.map-note { padding: .75rem; border-left: 3px solid var(--accent); background: #fffdf0; }
.map-note p { margin: .45rem 0 0; white-space: pre-wrap; }
.help-page { max-width: 900px; margin: 0 auto; }
.help-page section { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.help-page section:first-of-type { margin-top: 1.5rem; }
.help-page p { line-height: 1.6; }
.help-page ul { margin: .75rem 0 0; padding-left: 1.3rem; }
.help-page li { line-height: 1.55; }
.help-page li + li { margin-top: .4rem; }
@media (max-width: 760px) {
  .page-shell { padding-top: 2rem; }
  .page-shell-wide { width: 90vw; }
  .page-shell-profile { width: 92vw; padding-top: 1.25rem; }
  .topbar { padding: 0 5vw; }
  .brand-logo { width: 150px; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .profile-heading { align-items: flex-start; flex-direction: column; }
  .profile-actions { justify-content: flex-start; }
  .profile-identity { align-items: flex-start; }
  .profile-hero { grid-template-columns: 1fr; }
  .profile-hero-actions { width: 100%; justify-content: flex-start; }
  .profile-primary-fields { grid-template-columns: 1fr; }
  .member-photo-editor { align-items: stretch; flex-direction: column; }
  .profile-dashboard, .profile-tag-groups, .profile-lower-grid { grid-template-columns: 1fr; }
  .profile-tags-section { grid-column: auto; }
  .inline-property { grid-template-columns: 1fr; gap: .3rem; }
  .derived-fields { grid-template-columns: 1fr; }
  .map-layout { grid-template-columns: 1fr; }
  .map-panel { min-height: auto; }
  #member-map { min-height: 500px; }
}
