/* RESCUE portal visual system. Functional styles remain in index.html. */
:root {
  --bg: #f2f4f3;
  --surface: #fff;
  --surface-soft: #f7f9f8;
  --surface-strong: #fff;
  --field-bg: #fff;
  --field-disabled: #eef1f0;
  --ink: #17211f;
  --muted: #53635f;
  --line: #dce3df;
  --line-strong: #b9c7c1;
  --brand: #b92432;
  --brand-dark: #971c29;
  --brand-soft: #fbecee;
  --teal: #086e69;
  --teal-soft: #e3f4f0;
  --amber: #8b5700;
  --amber-soft: #fff2d6;
  --green: #176b45;
  --green-soft: #e3f4e9;
  --charcoal: #252d2a;
  --neutral-badge-bg: #edf1ef;
  --calendar-outside: #f4f6f5;
  --code-bg: #1c2522;
  --topbar-bg: #fff;
  --sidebar: #202a27;
  --sidebar-ink: #f6faf8;
  --sidebar-muted: #c1d0c9;
  --danger: #ad2835;
  --shadow: 0 18px 50px rgba(21, 36, 29, .16);
  --radius: 6px;
}

html[data-theme="dark"] {
  --bg: #1b201e;
  --surface: #292f2c;
  --surface-soft: #323a35;
  --surface-strong: #242b27;
  --field-bg: #202824;
  --field-disabled: #303b35;
  --ink: #f1f5f2;
  --muted: #b5c5bd;
  --line: #47544c;
  --line-strong: #65786a;
  --brand: #c53a47;
  --brand-dark: #ad2835;
  --brand-soft: #42292c;
  --teal: #71d6c7;
  --teal-soft: #1e4440;
  --amber: #ffd080;
  --amber-soft: #493b25;
  --green: #85d7a6;
  --green-soft: #254333;
  --charcoal: #354039;
  --neutral-badge-bg: #38443d;
  --calendar-outside: #202824;
  --code-bg: #131a16;
  --topbar-bg: #242b27;
  --sidebar: #141b18;
  --sidebar-muted: #bdcfc3;
  --danger: #ff7580;
  --shadow: 0 18px 50px rgba(0, 0, 0, .32);
}

body { line-height: 1.45; }
.material-choice { min-width: 0; }
.material-choice .checkline { min-width: 0; }
.inventory-scroll { overflow-x: auto; }
.inventory-table { width: 100%; border-collapse: collapse; text-align: left; }
.inventory-table th, .inventory-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.inventory-table th { color: var(--muted); font-size: 12px; }
.inventory-table tr:last-child td { border-bottom: 0; }
.inventory-table td:last-child { width: 45%; }
.stock-low { color: var(--danger); }
.stock-detail { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.inventory-details summary { cursor: pointer; color: var(--teal); font-weight: 700; }
.inventory-controls { display: grid; gap: 12px; margin-top: 12px; }
.inventory-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.inventory-form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.inventory-form label.checkline { display: inline-flex; align-items: center; }
.inventory-form input, .inventory-form select { min-height: 35px; max-width: 180px; padding: 7px 9px; color: var(--ink); background: var(--field-bg); border: 1px solid var(--line-strong); border-radius: 5px; }
.inventory-form input:focus, .inventory-form select:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.inventory-form input[type="checkbox"] { min-height: auto; }
.inventory-form input[type="number"] { width: 118px; }
.inventory-history { margin-top: 10px; color: var(--muted); font-size: 12px; }
@media (max-width: 720px) { .inventory-table td:last-child { min-width: 250px; } }
button, input, select, textarea { letter-spacing: 0; }
button:focus-visible, a:focus-visible, summary:focus-visible,
.day-cell:focus-visible, .medical-record-card:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}
::selection { background: var(--teal-soft); color: var(--ink); }

.app-shell { grid-template-columns: 252px minmax(0, 1fr); }
.sidebar { padding: 18px 12px 14px; overflow-y: auto; scrollbar-width: thin; }
.sidebar-header { gap: 10px; padding: 5px 12px 21px; margin-bottom: 16px; border-bottom-color: rgba(255,255,255,.13); }
.sidebar .brand-mark { width: 43px; height: 43px; }
.sidebar-title strong { font-size: 16px; font-weight: 800; }
.sidebar-title span { font-size: 12px; }
.nav-list { gap: 3px; }
.nav-button { min-height: 42px; border-radius: 5px; padding: 9px 11px; font-size: 13px; font-weight: 650; color: var(--sidebar-muted); }
.nav-button svg { width: 18px; height: 18px; flex: none; }
.nav-button:hover { color: #fff; background: rgba(255,255,255,.09); }
.nav-button.active { color: #fff; background: rgba(255,255,255,.12); box-shadow: inset 3px 0 0 var(--brand); }
.nav-button.parent-current { background: rgba(255,255,255,.06); }
.nav-button.has-chat-unread { position: relative; padding-right: 44px; }
.nav-chat-unread-bubble {
  position: absolute;
  top: 4px;
  right: 8px;
  display: grid;
  place-items: center;
  min-width: 23px;
  height: 23px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.nav-sublist { margin-left: 19px; padding-left: 9px; }
.nav-sublist .nav-button { min-height: 36px; font-weight: 600; }
.sidebar-footer { gap: 11px; padding: 16px 8px 0; border-top-color: rgba(255,255,255,.13); }
.sidebar-footer .btn { justify-content: flex-start; color: var(--sidebar-ink); }
.user-mini { padding: 0; }

.topbar { min-height: 68px; padding: 12px 28px; backdrop-filter: none; }
.topbar h2 { font-size: 20px; font-weight: 750; }
.topbar-meta { font-size: 12px; }
.topbar-actions { gap: 15px; }
.content { max-width: 1560px; padding: 26px 30px 54px; }
.view { gap: 27px; }
.grid { gap: 25px; }
.grid.two { grid-template-columns: minmax(0, 1.1fr) minmax(290px, .9fr); }
.view > *, .grid > *, .section, .section-body, .form-grid, .form-grid > * { min-width: 0; }

.section { background: transparent; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
.section-header { min-height: 64px; padding: 0 0 13px; background: transparent; border-bottom: 1px solid var(--line-strong); }
.section-header h3, .section-title h3 { font-size: 16px; font-weight: 750; }
.section-header p, .section-title p { margin-top: 3px; font-size: 12px; }
.section-body { padding: 14px 0 0; }
.section > .section-body:only-child { padding-top: 0; }
.section-body .cards { gap: 0; }
.section-body .item-card { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 13px 2px; }
.section-body .item-card:first-child { padding-top: 4px; }
.section-body .item-card:last-child { border-bottom: 0; }
.section-body .medical-record-card:hover { box-shadow: none; background: var(--surface-soft); transform: none; }
.section-body .medical-record-card.expanded { border: 1px solid var(--teal); border-radius: 6px; padding: 13px; box-shadow: none; background: var(--surface); }
.record-card-mobile-actions { display: none; }
.calendar-month-actions { flex-wrap: nowrap; }
.empty { padding: 18px 16px; border: 1px solid var(--line); background: var(--surface-soft); font-size: 13px; }

.stat-grid { gap: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.stat { min-height: 94px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; padding: 15px 19px; }
.stat:last-child { border-right: 0; }
.stat span { font-size: 12px; font-weight: 650; }
.stat strong { margin-top: 7px; font-size: 29px; font-weight: 750; }

.dashboard-view > .grid.two {
  gap: 0;
  border: 1px solid var(--line-strong);
  border-top: 2px solid var(--teal);
  border-radius: 5px;
  background: var(--surface);
  overflow: hidden;
}
.dashboard-view > .grid.two:last-child { border-top-color: var(--brand); }
.dashboard-view > .grid.two > :nth-child(2) { border-left: 1px solid var(--line); }
.dashboard-view > .grid.two > .grid { display: block; }
.dashboard-view .section-header {
  min-height: 72px;
  padding: 14px 16px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}
.dashboard-view .section-title h3 { font-size: 16px; }
.dashboard-view .section-body { padding: 10px 16px 16px; }
.dashboard-view .section-body .item-card {
  padding: 12px 2px;
  border-bottom-color: var(--line);
}
.dashboard-view .section-body .item-card:first-child { padding-top: 4px; }
.dashboard-view .section-body .item-card:last-child { border-bottom: 0; }
.dashboard-view .section-body .empty {
  border: 0;
  background: transparent;
  padding: 12px 2px;
}

.view:not(.dashboard-view) > .section,
.view:not(.dashboard-view) > .grid.two > .section {
  border: 1px solid var(--line-strong);
  border-top: 2px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  overflow: hidden;
}
.view:not(.dashboard-view) > .section > .section-header,
.view:not(.dashboard-view) > .grid.two > .section > .section-header {
  min-height: 70px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}
.view:not(.dashboard-view) > .section > .section-header:last-child { border-bottom: 0; }
.view:not(.dashboard-view) > .section > .section-body,
.view:not(.dashboard-view) > .grid.two > .section > .section-body { padding: 16px 18px 19px; }
.view:not(.dashboard-view) > .section > .section-body:only-child { padding-top: 18px; }
.view:not(.dashboard-view) > .section .section-body > .empty,
.view:not(.dashboard-view) > .grid.two > .section .section-body > .empty {
  border: 0;
  background: transparent;
  padding: 12px 0;
}
.view:not(.dashboard-view) > .section .table-wrap { border: 0; border-radius: 0; }
.view:not(.dashboard-view) .records-report-controls {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 0 0 16px;
}
.todo-view > .section:nth-of-type(2) { border-top-color: var(--teal); }
.todo-view > .grid.two > .section:last-child { border-top-color: var(--green); }
.todo-view .section-body .item-card {
  padding: 16px 2px;
  border-bottom-color: var(--line-strong);
}
.todo-view .section-body .item-card:first-child { padding-top: 4px; }
.todo-view .section-body .item-card:last-child { border-bottom: 0; }

.btn { min-height: 38px; border-radius: 5px; padding: 8px 12px; font-size: 13px; font-weight: 700; transition: background .16s ease, border-color .16s ease, color .16s ease; }
.btn:hover { transform: none; }
.btn.primary { color: #fff; }
html[data-theme="dark"] .btn.danger { background: #ad2835; border-color: #ad2835; color: #fff; }
.btn.secondary { background: var(--surface); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-soft); border-color: var(--teal); }
.btn.ghost:hover { background: rgba(255,255,255,.08); }
.btn.icon-only { width: 38px; min-width: 38px; }
.badge { border-radius: 4px; min-height: 22px; padding: 3px 7px; font-weight: 700; font-size: 11px; }
.badge.red { color: var(--brand-dark); }
html[data-theme="dark"] .badge.red { color: #ff9198; }
.badge.critical { box-shadow: none; }
.urgent-strip { border-radius: 5px; background: var(--brand); box-shadow: none; }
.urgent-strip-icon { border-radius: 5px; }
html[data-theme="light"] .urgent-strip .btn.secondary { color: #111; }

.field { gap: 5px; }
.field label { font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea,
.toolbar select, .search, .multi-select summary {
  border-radius: 5px; border-color: var(--line-strong); box-shadow: none;
}
.field input:focus, .field select:focus, .field textarea:focus,
.multi-select[open] summary { box-shadow: 0 0 0 3px var(--teal-soft); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--teal); }
.form-grid { gap: 12px 16px; }
.medical-qualification-field { min-width: 0; margin: 0 0 15px; padding: 0; border: 0; }
.medical-qualification-field legend { margin-bottom: 8px; color: var(--ink); font-size: 12px; font-weight: 700; }
.medical-qualification-list { display: grid; grid-template-columns: repeat(2, max-content); gap: 2px 14px; }
.medical-qualification-list .checkline { min-height: 26px; gap: 6px; font-size: 12px; white-space: nowrap; }
.medical-qualification-list input[type="checkbox"] { flex: none; width: 16px; height: 16px; min-height: 16px; margin: 0; padding: 0; }
.member-role-table .medical-qualification-list { grid-template-columns: max-content; }
.member-role-table { min-width: 1480px; table-layout: fixed; }
.member-role-table th:nth-child(1) { width: 145px; }
.member-role-table th:nth-child(2) { width: 125px; }
.member-role-table th:nth-child(3) { width: 150px; }
.member-role-table th:nth-child(4) { width: 165px; }
.member-role-table th:nth-child(5) { width: 145px; }
.member-role-table th:nth-child(6) { width: 185px; }
.member-role-table th:nth-child(7) { width: 100px; }
.member-role-table th:nth-child(8) { width: 375px; }
.member-role-table th:nth-child(9) { width: 90px; }
.member-role-table .permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.member-role-table .checkline input[type="checkbox"] { flex: none; }
.personnel-role-details, .member-contact-details { display: grid; gap: 3px; }
.toolbar { gap: 10px; }
.search:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.table-wrap { border-radius: 5px; }
.table-wrap { max-width: 100%; }
th, td { padding: 11px 12px; }
th { font-weight: 750; letter-spacing: 0; }
tbody tr:hover { background: var(--surface-soft); }
.item-card, .record-detail-item, .calendar-event-detail-item,
.calendar-registration-panel, .calendar-records-panel, .calendar-record-row,
.records-report-controls, .record-stat-card, .record-stat-panel, .todo-insight,
.todo-comment, .multi-select-panel, .calendar-event-compact { border-radius: 5px; }
.item-card h4 { font-size: 14px; }
.item-card p { font-size: 13px; }
.record-stat-card strong { font-size: 25px; }
.notice-box { border-radius: 5px; font-size: 14px; }
.sync-error { background: var(--brand-soft); color: var(--ink); }

.calendar-head h3 { font-size: 18px; }
.calendar-head h3 { white-space: nowrap; }
.calendar-head { flex-wrap: wrap; }
.calendar-month-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.calendar-head .btn { width: auto; flex: none; }
.calendar-grid { gap: 5px; }
.weekday { min-height: 33px; font-size: 11px; }
.day-cell { min-height: 98px; border-radius: 4px; padding: 7px; }
.day-cell:hover { border-color: var(--teal); background: var(--surface-soft); }
.day-cell.selected-day { box-shadow: inset 0 0 0 1px var(--teal); }
.day-event-count, .calendar-day-mobile-layer { display: none; }
.day-event { border-radius: 3px; }
.day-event:hover { background: var(--teal); color: var(--surface); }
.calendar-modal { border-radius: 6px; }
.calendar-confirm {
  box-sizing: border-box; width: min(420px, calc(100% - 32px)); margin: auto;
  padding: 20px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 6px; box-shadow: var(--shadow);
}
.calendar-confirm::backdrop { background: rgba(5, 10, 16, .62); }
.calendar-confirm h3 { margin: 0 0 8px; font-size: 18px; }
.calendar-confirm strong { color: var(--teal); overflow-wrap: anywhere; }
.calendar-confirm p { color: var(--muted); margin: 8px 0 18px; }
.calendar-confirm .row-actions { justify-content: flex-end; }
.calendar-modal .item-card { border-radius: 0; }
.calendar-event-detail-topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: start;
  gap: 12px;
  margin: -14px -14px 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.calendar-event-detail-topbar > div { min-width: 0; }
.calendar-modal .calendar-event-detail-topbar { padding-inline-end: 6px; }
.calendar-event-detail-close { width: 40px; height: 40px; min-width: 40px; background: var(--surface-soft); }
.calendar-event-detail-actions { justify-content: flex-start; }
.billing-heading, .billing-heading .row-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.billing-heading { justify-content: space-between; }
.billing-heading h2 { margin: 0; font-size: 22px; }
.billing-heading span, .billing-row small, .billing-figures dt { color: var(--muted); }
.billing-heading .field { margin: 0; font-size: 12px; }
.billing-heading :is(input[type="month"], .btn) { height: 42px; }
.billing-view .billing-totals { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); }
.billing-totals .stat strong { font-size: 22px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.billing-totals .stat:last-child { background: var(--teal-soft); color: var(--teal); }
.billing-row + .billing-row { border-top: 1px solid var(--line); }
.billing-event-row + .billing-event-row { border-top: 1px solid var(--line); }
.billing-event-row { position: relative; }
.billing-event-row > button { position: absolute; top: 7px; left: 8px; z-index: 1; width: 40px; height: 40px; }
.billing-event-row > button + details > summary { padding-inline-start: 58px; grid-template-columns: minmax(0,1fr) auto 18px; }
.billing-event-row > button + details > summary > svg:first-child { display: none; }
.billing-row summary {
  display: grid; grid-template-columns: 18px minmax(0,1fr) auto 18px; gap: 12px;
  align-items: center; min-height: 54px; padding: 10px 18px; cursor: pointer; list-style: none;
}
.billing-row summary::-webkit-details-marker { display: none; }
.billing-row summary:hover, .billing-row[open] summary { background: var(--surface-soft); }
.billing-row summary svg { width: 18px; height: 18px; color: var(--teal); }
.billing-row summary strong, .billing-row summary small { display: block; overflow-wrap: anywhere; }
.billing-row summary b, .billing-table td:last-child { font-variant-numeric: tabular-nums; }
.billing-row[open] .billing-chevron { transform: rotate(180deg); }
.billing-breakdown { padding: 12px 18px 18px; border-inline-start: 3px solid var(--teal); }
.billing-figures + form { margin-top: 16px; }
.billing-figures { display: flex; gap: 12px 32px; flex-wrap: wrap; margin: 0; }
.billing-figures dd { margin: 3px 0 0; font-weight: 700; }
.billing-figures + table, .billing-breakdown button { margin-top: 12px; }
.billing-view .billing-table { min-width: 0; width: 100%; }
.billing-table td { overflow-wrap: anywhere; white-space: normal; }
.billing-table :is(td,th):last-child { text-align: right; }
@media (max-width: 720px) {
  .billing-view .billing-totals { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .billing-row summary { padding-inline: 10px; gap: 8px; grid-template-columns: minmax(0,1fr) minmax(0,auto) 16px; }
  .billing-row summary > svg:first-child { display: none; }
  .billing-row summary b { overflow-wrap: anywhere; text-align: right; }
  .billing-breakdown { padding-inline: 10px; }
}
.event-section { min-width: 0; border-block-start: 1px solid var(--line); }
.event-section > summary {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 8px 10px; cursor: pointer; list-style: none; color: var(--ink);
  background: var(--surface-soft);
}
.event-section > summary::-webkit-details-marker { display: none; }
.event-section > summary:hover, .event-section[open] > summary { background: var(--teal-soft); }
.event-section > summary svg { flex: none; width: 18px; height: 18px; color: var(--teal); }
.event-section strong { overflow-wrap: anywhere; }
.event-section .event-price { margin-left: auto; font-variant-numeric: tabular-nums; }
.event-section .section-chevron { margin-left: auto; }
.event-section .event-price + .section-chevron { margin-left: 0; }
.event-section[open] .section-chevron { transform: rotate(180deg); }
.event-section > form { padding: 14px 10px 4px; }
.event-section .field { min-width: 0; font-weight: 600; }
.event-section select { width: 100%; min-width: 0; }
@media (max-width: 600px) {
  .event-section > form { grid-template-columns: minmax(0, 1fr); }
  .event-section .form-actions { grid-column: 1 / -1; }
  .event-section .form-actions .btn { width: 100%; }
}
.record-mobile-backdrop { display: none; }
.dashboard-chat-tab, .dashboard-chat-panel { border-radius: 8px; }

.login-screen { grid-template-columns: minmax(360px, 430px) minmax(0, 1fr); }
.login-panel { padding: 56px; box-shadow: 1px 0 0 var(--line); z-index: 1; }
.login-brand { margin-bottom: 54px; }
.login-panel h1 { font-size: 33px; font-weight: 780; }
.login-panel p { margin-bottom: 24px; font-size: 14px; }
.login-card { border: 0; border-radius: 0; padding: 0; box-shadow: none; }
.login-card .btn.primary { width: 100%; min-height: 43px; }
.password-setup-backdrop { z-index: 120; padding: 16px; }
.password-setup-dialog {
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 26px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.password-setup-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.password-setup-heading .btn { width: auto; flex: 0 0 auto; }
.password-setup-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); }
.password-setup-icon svg { width: 20px; height: 20px; }
.password-setup-dialog h1 { margin: 0 0 7px; font-size: 22px; }
.password-setup-dialog > p { margin: 0 0 21px; color: var(--muted); font-size: 13px; }
.password-setup-form { display: grid; gap: 16px; }
.password-setup-form .field { display: grid; gap: 6px; }
.password-setup-form .field input { width: 100%; }
.password-setup-form .field small { color: var(--muted); font-size: 12px; }
.password-setup-form .btn.primary { width: 100%; min-height: 44px; }
.password-setup-form .password-setup-error { margin: 0; }
.temporary-password-field { display: grid; gap: 7px; margin-bottom: 18px; }
.temporary-password-field input { width: 100%; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.temporary-password-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
@media (max-width: 480px) { .password-setup-dialog { padding: 20px; } }
.login-visual { background-position: center; }
.login-theme-toggle { box-shadow: none; }

@media (max-width: 1100px) {
  .grid.two, .calendar-shell { grid-template-columns: 1fr; }
  .dashboard-view > .grid.two > :nth-child(2) { border-left: 0; border-top: 1px solid var(--line); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .member-table-wrap, .personnel-table-wrap { overflow-x: visible; }
  .member-role-table, .personnel-table { display: block; width: 100%; min-width: 0; table-layout: auto; }
  .member-role-table thead, .personnel-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .member-role-table tbody, .personnel-table tbody { display: grid; gap: 12px; }
  .member-role-table tr, .personnel-table tr { display: block; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
  .member-role-table td, .personnel-table td { display: grid; grid-template-columns: minmax(0, 130px) minmax(0, 1fr); align-items: start; gap: 8px; min-width: 0; padding: 10px 12px; overflow-wrap: anywhere; }
  .member-role-table td:first-child, .personnel-table td:first-child { display: block; padding: 12px; background: var(--surface-soft); }
  .member-role-table td:last-child, .personnel-table td:last-child { border-bottom: 0; }
  .member-role-table td:not(:first-child)::before, .personnel-table td:not(:first-child)::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 700; }
  .member-role-table td > *, .personnel-table td > * { min-width: 0; }
  .member-role-table td > select { width: 100%; }
  .member-role-table .permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  body:has(.calendar-day-mobile-layer) { overflow: hidden; }
  body:has(.record-mobile-backdrop) { overflow: hidden; }
  .medical-record-card .record-card-header-actions { display: none; }
  .record-card-mobile-actions { display: grid; gap: 8px; padding-top: 4px; }
  .record-card-mobile-actions .record-card-open {
    width: min(100%, 340px);
    min-height: 40px;
    justify-content: center;
    border-color: var(--teal);
    color: var(--teal);
  }
  .record-card-mobile-tools { justify-content: flex-start; gap: 6px; }
  .record-mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 12px;
  }
  .record-mobile-scrim { position: absolute; inset: 0; background: rgba(5, 10, 16, .62); }
  .record-mobile-dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(720px, 100%);
    max-height: calc(100dvh - 24px);
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  .record-mobile-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
  }
  .record-mobile-header > div { min-width: 0; }
  .record-mobile-header h3 { margin: 0 0 3px; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
  .record-mobile-header span { color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
  .record-mobile-header .btn { width: 40px; height: 40px; flex: 0 0 40px; }
  .record-mobile-body { min-height: 0; overflow-y: auto; padding: 16px; }
  .record-mobile-footer { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
  .record-mobile-footer .btn { flex: 1 1 100px; width: auto; }
  .day-cell .day-event, .day-cell > .badge, .day-cell .calendar-day-popover { display: none; }
  .day-event-count {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: var(--teal-soft);
    color: var(--teal);
    font-size: 11px;
    font-weight: 800;
  }
  .calendar-day-mobile-layer {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    padding: 16px;
  }
  .calendar-day-mobile-scrim { position: absolute; inset: 0; background: rgba(5, 10, 16, .62); }
  .calendar-day-mobile-dialog {
    position: relative;
    width: min(480px, 100%);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow);
    padding: 16px;
  }
  .calendar-day-mobile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
  .calendar-day-mobile-head h3 { margin: 0; font-size: 18px; line-height: 1.3; }
  .calendar-day-mobile-head span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
  .calendar-day-mobile-head .btn { flex: 0 0 38px; }
  .calendar-day-mobile-events { display: grid; gap: 0; margin-bottom: 16px; }
  .calendar-day-mobile-event {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
    width: 100%;
    padding: 12px 0;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
  }
  .calendar-day-mobile-event:hover { background: var(--surface-soft); }
  .calendar-day-mobile-event strong { min-width: 0; font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
  .calendar-day-mobile-time { color: var(--teal); font-size: 12px; font-weight: 800; }
  .calendar-day-mobile-actions { display: flex; align-items: center; gap: 4px; color: var(--muted); }
  .calendar-day-mobile-actions svg { width: 15px; height: 15px; flex: 0 0 15px; }
  .calendar-day-mobile-event .badge { margin: 0; }
  .dashboard-chat-drawer { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { width: min(292px, 84vw); }
  .topbar { min-height: 60px; padding: 10px 16px; }
  .topbar h2 { font-size: 18px; }
  .content { padding: 21px 16px 36px; }
  .view, .grid { gap: 22px; }
  .todo-insights { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .todo-insight { position: relative; min-height: 88px; padding: 12px; align-items: flex-start; }
  .todo-insight > div { min-width: 0; padding-right: 24px; }
  .todo-insight span { display: block; overflow-wrap: break-word; line-height: 1.2; }
  .todo-insight svg { position: absolute; top: 12px; right: 12px; width: 18px; height: 18px; }
  .view:not(.dashboard-view) > .section > .section-body,
  .view:not(.dashboard-view) > .grid.two > .section > .section-body { padding: 14px 15px 17px; }
  .view:not(.dashboard-view) > .section > .section-header,
  .view:not(.dashboard-view) > .grid.two > .section > .section-header { padding: 13px 15px; }
  .login-screen { display: block; }
  .login-panel { padding: 28px; box-shadow: none; }
  .login-visual { display: none; }
}
@media (min-width: 541px) and (max-width: 820px) {
  .record-card-mobile-actions { display: flex; align-items: center; justify-content: space-between; }
  .record-card-mobile-actions .record-card-open { width: auto; flex: 1 1 220px; max-width: 340px; }
  .record-card-mobile-tools { flex: 0 0 auto; justify-content: flex-end; }
}
@media (max-width: 540px) {
  .member-role-table td, .personnel-table td { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .member-role-table .permission-grid { grid-template-columns: minmax(0, 1fr); }
  .record-card-mobile-actions .record-card-open { width: 100%; }
  .topbar-actions { gap: 5px; }
  .section-header { align-items: flex-start; }
  .section-header .btn { width: auto; }
  .section-body { padding-top: 12px; }
  .stat { min-height: 79px; padding: 12px; }
  .stat strong { font-size: 24px; }
  .stat span { font-size: 11px; }
  .calendar-grid { gap: 3px; }
  .day-cell { min-height: 69px; padding: 4px; }
  .day-event { padding: 3px 4px; font-size: 10px; }
  .login-panel { padding: 22px; }
  .login-brand { margin-bottom: 40px; }
  .login-panel h1 { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
