:root {
  color-scheme: light;
  --ink: #203b36;
  --muted: #73817d;
  --line: #dfe8e4;
  --paper: #ffffff;
  --canvas: #f3f7f5;
  --green: #1c6b59;
  --green-deep: #173f39;
  --green-soft: #eaf5f0;
  --gold-soft: #fbf4e5;
  --gold: #9a6a13;
  --rose-soft: #fff0ed;
  --rose: #ad4e3e;
  --shadow: 0 12px 30px rgba(29, 65, 54, .055);
  font-family: 'DM Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.app-shell { min-height: 100vh; }
.topbar { height: 76px; padding: 0 max(28px, calc((100vw - 1240px) / 2)); background: var(--paper); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: #fff; font-size: 21px; font-weight: 700; background: var(--green-deep); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .02em; }
.brand small { margin-top: 3px; font-size: 11px; color: var(--muted); }
.local-badge { display: inline-flex; align-items: center; gap: 8px; color: var(--green); background: var(--green-soft); border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 600; }
.local-badge span { width: 7px; height: 7px; background: #329b78; border-radius: 50%; }
main { width: min(1240px, calc(100% - 56px)); margin: 0 auto; padding: 40px 0 48px; }
.page-intro { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.eyebrow { color: #8a9a94; font-size: 10px; font-weight: 700; letter-spacing: .15em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; margin-top: 8px; font-size: clamp(26px, 3vw, 34px); letter-spacing: -.035em; line-height: 1.2; }
.page-intro p { color: var(--muted); font-size: 14px; margin-bottom: 0; }
.button { border: 1px solid transparent; border-radius: 10px; padding: 11px 16px; font-weight: 600; font-size: 13px; transition: background .18s, border-color .18s, transform .18s; }
.button:active { transform: translateY(1px); }
.button-outline { background: #fff; color: var(--ink); border-color: var(--line); }
.button-outline:hover { border-color: #afc2b9; background: #fbfdfc; }
.button-primary { color: #fff; background: var(--green); }
.button-primary:hover { background: #145746; }
.button:disabled { cursor: wait; opacity: .65; }
.filter-panel { display: grid; grid-template-columns: 1.1fr .8fr 1.3fr; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 16px; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span { color: #657770; font-size: 11px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #dce5e0; border-radius: 9px; background: #fff; color: var(--ink); min-height: 44px; padding: 10px 12px; outline: none; transition: border-color .18s, box-shadow .18s; }
.filter-panel .field select { appearance: none; -webkit-appearance: none; padding-right: 44px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m3 6 5 5 5-5' stroke='%23203b36' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 18px center; background-size: 16px 16px; }
.field textarea { resize: vertical; line-height: 1.55; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #61a38e; box-shadow: 0 0 0 3px rgba(51, 132, 107, .12); }
.field input::placeholder, .field textarea::placeholder { color: #a4b0ab; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0 36px; }
.summary-card { display: flex; align-items: center; justify-content: space-between; min-height: 70px; padding: 14px 17px; border: 1px solid var(--line); border-radius: 13px; text-align: left; color: var(--ink); background: #fff; transition: box-shadow .18s, border-color .18s, transform .18s; }
.summary-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.summary-card.is-active { border-color: #3b9278; box-shadow: 0 0 0 2px rgba(59, 146, 120, .12); }
.summary-card span { display: inline-flex; align-items: center; gap: 8px; color: #5d7069; font-size: 12px; font-weight: 600; }
.summary-card strong { font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-yes { background: #29936d; }
.dot-no { background: #d06d56; }
.dot-blank { background: #b7c2bd; }
.results-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 15px; }
.results-heading h2 { margin: 6px 0 5px; font-size: 20px; letter-spacing: -.02em; }
.muted { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.result-count { color: var(--green); background: var(--green-soft); border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.results { display: flex; flex-direction: column; gap: 18px; }
.building-group { border: 1px solid var(--line); background: #fff; border-radius: 15px; box-shadow: var(--shadow); overflow: hidden; }
.building-group-heading { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; background: #f8fbf9; border-bottom: 1px solid var(--line); }
.building-group-heading h3 { margin: 0; font-size: 14px; }
.building-group-heading span { color: var(--muted); font-size: 11px; }
.record-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; padding: 0; }
.record-card { padding: 7px 18px; border-bottom: 1px solid #edf1ef; border-radius: 0; min-width: 0; }
.record-card.record-yes { background: #e8f5ee; }
.record-card.record-no { background: #fff0ed; }
.record-card:nth-last-child(-n+2) { border-bottom-color: transparent; }
.record-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.room-heading { display: flex; align-items: center; gap: 7px; min-width: 0; }
.room-heading strong { font-size: 14px; letter-spacing: -.02em; }
.room-label { color: #92a19b; font-size: 10px; }
.answer-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 6px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.answer-yes, .answer-no { color: inherit; background: transparent; }
.vacancy-pill { color: #687970; border: 1px solid rgba(104,121,112,.28); border-radius: 999px; padding: 1px 6px; font-size: 9px; white-space: nowrap; }
.record-main { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; }
.name-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--ink); text-align: left; font-size: 11px; line-height: 1.35; }
.name-summary > span { overflow-wrap: anywhere; }
.name-summary i { margin-right: 4px; color: #82918a; font-size: 9px; font-style: normal; }
.name-summary:hover { text-decoration: underline; text-decoration-color: #97aaa1; text-underline-offset: 2px; }
.print-people { display: none; }
.person-line { display: grid; grid-template-columns: 38px minmax(90px, .9fr) minmax(120px, 1.1fr); align-items: start; gap: 8px; font-size: 12px; line-height: 1.5; }
.person-role { color: #899791; font-size: 10px; padding-top: 1px; }
.person-name { overflow-wrap: anywhere; }
.person-phone { color: #425a52; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.person-phone a { text-decoration: none; }
.person-phone a:hover { color: var(--green); text-decoration: underline; }
.empty-value { color: #a0aca6; font-size: 11px; }
.edit-button { border: 0; padding: 3px 2px 3px 8px; background: transparent; color: var(--green); font-size: 10px; font-weight: 700; white-space: nowrap; }
.edit-button:hover { color: #0e4f3d; }
.empty-state { padding: 56px 24px; border: 1px dashed #cfdad4; border-radius: 15px; text-align: center; background: rgba(255,255,255,.65); }
.empty-state h3 { margin: 0 0 7px; font-size: 17px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; }
.empty-icon { display: inline-grid; place-items: center; width: 38px; height: 38px; margin-bottom: 11px; border-radius: 12px; color: var(--green); background: var(--green-soft); font-size: 20px; }
.footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 26px; color: #8c9a94; font-size: 10px; }
.edit-dialog { width: min(620px, calc(100% - 28px)); max-height: min(90vh, 850px); padding: 0; border: 0; border-radius: 17px; color: var(--ink); box-shadow: 0 24px 90px rgba(16, 42, 35, .24); }
.edit-dialog::backdrop { background: rgba(19, 42, 36, .44); backdrop-filter: blur(2px); }
.edit-dialog form { padding: 24px; }
#edit-dialog { height: min(660px, calc(100dvh - 32px)); overflow: hidden; }
#edit-dialog[open] { display: flex; flex-direction: column; }
#edit-dialog form { display: flex; flex: 1; flex-direction: column; min-height: 0; overflow: hidden; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.dialog-heading h2 { margin: 6px 0 0; font-size: 20px; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: #f1f5f3; color: #52645c; font-size: 23px; line-height: 1; }
.identity-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; flex: 0 0 auto; }
.status-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; flex: 0 0 auto; }
.notes-field { display: flex; flex: 1 1 auto; min-height: 0; margin-top: 12px; }
#edit-dialog .notes-field textarea { flex: 1 1 auto; min-height: 96px; resize: none; overflow-y: auto; }
.form-hint { color: var(--muted); font-size: 11px; line-height: 1.4; margin: 7px 0 0; flex: 0 0 auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 10px; flex: 0 0 auto; }
.details-content { padding: 24px; }
.details-body { display: grid; gap: 10px; }
.details-body .person-line { grid-template-columns: 45px minmax(90px, 1fr) minmax(120px, 1fr); padding: 9px 10px; border-radius: 9px; background: #f6f8f7; }
.details-notes { padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.details-notes h3 { margin: 0 0 8px; color: #657770; font-size: 11px; }
.details-notes p { margin: 0; font-size: 12px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.details-vacancy { margin: 0; color: #687970; font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10; max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 999px; background: #193e37; color: #fff; box-shadow: 0 10px 30px rgba(16, 42, 35, .22); font-size: 12px; }

@media (max-width: 760px) {
  .topbar { min-height: 64px; height: auto; padding: 9px 14px; gap: 10px; }
  .brand { gap: 8px; min-width: 0; }
  .brand-mark { flex: 0 0 auto; width: 38px; height: 38px; }
  .brand strong { font-size: 14px; }
  .brand small { font-size: 10px; }
  .account-tools { flex: 0 0 auto; gap: 6px; }
  .account-tools .local-badge { gap: 5px; padding: 7px 8px; font-size: 10px; }
  .account-tools .button { min-height: 44px; padding: 7px 10px; }
  main { width: calc(100% - 28px); padding: 24px 0 30px; }
  .page-intro { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 17px; }
  h1 { font-size: 27px; }
  .page-intro p { max-width: 500px; font-size: 12px; line-height: 1.6; }
  #print-button { width: 100%; min-height: 44px; }
  .filter-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 11px; gap: 9px; }
  .search-field { grid-column: 1 / -1; }
  .field input, .field select, .field textarea { min-height: 48px; font-size: 16px; }
  .filter-panel .field select { padding-right: 36px; background-position: right 12px center; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0 23px; }
  .summary-card { min-width: 0; min-height: 60px; gap: 5px; padding: 9px 10px; }
  .summary-card span { min-width: 0; gap: 5px; font-size: 10px; white-space: nowrap; }
  .summary-card strong { flex: 0 0 auto; font-size: 20px; }
  .results-heading h2 { font-size: 17px; }
  .results-heading { align-items: flex-start; gap: 8px; margin-bottom: 12px; }
  .result-count { padding: 7px 9px; font-size: 11px; }
  .results { gap: 12px; }
  .record-grid { grid-template-columns: 1fr; padding: 0; }
  .record-card, .record-card:nth-last-child(-n+2) { border-bottom: 1px solid #edf1ef; }
  .record-card:last-child { border-bottom-color: transparent; }
  .record-card { padding: 7px 12px; }
  .record-topline { gap: 6px; }
  .room-heading { gap: 5px; }
  .room-heading strong { font-size: 14px; }
  .answer-pill { font-size: 10px; }
  .record-main { min-height: 44px; gap: 4px; }
  .name-summary { flex: 1 1 auto; min-height: 44px; padding: 5px 4px; gap: 4px 8px; font-size: 12px; }
  .name-summary i { font-size: 10px; }
  .edit-button { flex: 0 0 auto; min-width: 44px; min-height: 44px; padding: 7px 5px; font-size: 12px; }
  .person-line { grid-template-columns: 38px minmax(0, 1fr); gap: 4px 7px; font-size: 13px; }
  .person-phone { grid-column: 2; }
  .building-group-heading { padding: 11px 12px; }
  .footer { flex-direction: column; gap: 5px; line-height: 1.5; }
  .edit-dialog { width: calc(100% - 24px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; border-radius: 16px; }
  #edit-dialog { height: min(660px, calc(100vh - 24px)); height: min(660px, calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom))); overflow: hidden; }
  #edit-dialog form { height: 100%; padding: 14px; }
  #edit-dialog .identity-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  #edit-dialog .status-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 10px; }
  #edit-dialog .notes-field { margin-top: 10px; }
  #edit-dialog .notes-field textarea { min-height: 84px; }
  #edit-dialog .form-hint { font-size: 10px; }
  #edit-dialog .dialog-actions { position: static; padding: 0; margin-top: 8px; }
  .dialog-heading { margin-bottom: 15px; }
  .dialog-heading h2 { font-size: 18px; }
  .icon-button { flex: 0 0 auto; width: 42px; height: 42px; }
  .status-fields .field select { padding-right: 36px; }
  .details-content { padding: 18px 14px; }
  .details-body .person-line { grid-template-columns: 38px minmax(0, 1fr); padding: 9px; }
  .details-body .person-phone { grid-column: 2; }
}

@media (max-height: 680px) {
  #edit-dialog .form-hint { display: none; }
  #edit-dialog .dialog-heading { margin-bottom: 9px; }
  #edit-dialog .notes-field { margin-top: 8px; }
  #edit-dialog .notes-field textarea { min-height: 64px; }
  #edit-dialog .dialog-actions { margin-top: 6px; }
}

@media (max-width: 400px) {
  .filter-panel { grid-template-columns: 1fr; }
  .search-field { grid-column: auto; }
}

@media (max-width: 380px) {
  .topbar { padding-right: 10px; padding-left: 10px; }
  .brand { gap: 6px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 11px; font-size: 18px; }
  .brand strong { font-size: 13px; }
  .brand small { display: none; }
  .account-tools .local-badge { padding: 6px 7px; }
  .account-tools .button { padding: 6px 8px; font-size: 12px; }
  .summary-card { padding: 8px; }
  .summary-card span { font-size: 9px; }
  .summary-card strong { font-size: 18px; }
}

@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body { background: #fff; color: #111; }
  .topbar, .page-intro, .filter-panel, .summary, .footer, .edit-dialog, .toast, .edit-button { display: none !important; }
  main { width: 100%; margin: 0; padding: 0; }
  .results-heading { margin: 0 0 8px; }
  .results-heading h2 { font-size: 16px; margin: 3px 0; }
  .results-heading .eyebrow, .results-heading .muted { font-size: 9px; }
  .result-count { background: none; color: #333; padding: 0; font-size: 10px; }
  .results { display: block; }
  .building-group { overflow: visible; border: 0; border-radius: 0; box-shadow: none; margin-bottom: 8px; break-inside: auto; }
  .building-group + .building-group { break-before: page; page-break-before: always; }
  .building-group-heading { padding: 5px 7px; border: 0; background: #eef3f0 !important; break-after: avoid; }
  .building-group-heading h3 { font-size: 11px; }
  .building-group-heading span { font-size: 9px; }
  .record-grid { display: block; columns: 3; column-gap: 5mm; column-fill: auto; padding: 0 2mm; }
  .record-card, .record-card:nth-last-child(-n+2), .record-card:last-child { display: inline-block; width: 100%; vertical-align: top; margin: 0 0 2px; border-bottom: .4pt solid #d8dfdc; padding: 5px 2px; break-inside: avoid; page-break-inside: avoid; }
  .record-card.record-yes { border-left: 2pt solid #29936d; background: #e8f5ee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .record-card.record-no { border-left: 2pt solid #d05b4f; background: #fff0ed !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .record-topline { margin: 0 0 4px; }
  .room-heading strong { font-size: 11px; }
  .room-label, .person-role, .answer-pill, .vacancy-pill { font-size: 8px; }
  .answer-pill { padding: 2px 4px; }
  .answer-pill.answer-yes { color: #176b4a; background: #e5f4eb !important; border: .5pt solid #72ad8d; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .answer-pill.answer-no { color: #a52d24; background: #fde7e3 !important; border: .5pt solid #d9867d; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .record-main { display: none; }
  .print-people { display: grid; gap: 2px; }
  .person-line { grid-template-columns: 25px minmax(0, 1fr); gap: 2px 4px; font-size: 8px; line-height: 1.25; }
  .person-role { font-size: 7px; }
  .person-phone { grid-column: 2; overflow-wrap: anywhere; }
  .person-phone a { color: inherit; text-decoration: none; }
  .empty-value { font-size: 8px; }
}
