:root {
  color-scheme: light;
  --bg: #f4f8fc;
  --surface: #ffffff;
  --panel: #eaf3fb;
  --ink: #102033;
  --muted: #5d6f82;
  --line: #d6e4f1;
  --accent: #1d6fb8;
  --accent-strong: #155a96;
  --danger: #a43a3a;
  --warning: #8a5b12;
  --radius: 8px;
  --shadow: 0 10px 28px rgba(16, 32, 51, 0.08);
  font-family: Avenir, "Avenir Next", Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100svh; }

.login-wrap {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--surface);
}

.login-visual {
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(135deg, rgba(29, 111, 184, 0.90), rgba(21, 90, 150, 0.78)),
    url("data:image/svg+xml,%3Csvg width='900' height='900' viewBox='0 0 900 900' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.28'%3E%3Cpath d='M44 150h812M44 300h812M44 450h812M44 600h812M44 750h812M150 44v812M300 44v812M450 44v812M600 44v812M750 44v812'/%3E%3Ccircle cx='454' cy='448' r='188'/%3E%3Cpath d='M454 260v376M266 448h376' stroke-width='28' stroke-linecap='round'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  color: white;
}

.brand { font-size: 14px; font-weight: 800; letter-spacing: 0; }
.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}
.brand-lockup,
.form-logo-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-lockup small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}
.brand-lockup-invert .brand,
.brand-lockup-invert small {
  color: #fff;
}
.brand-lockup-invert .logo-mark {
  box-shadow: 0 0 0 3px rgba(255,255,255,.9);
}
.form-logo-header {
  margin-bottom: 14px;
  color: var(--ink);
  font-weight: 900;
}
.form-logo-header.compact {
  margin-bottom: 10px;
}
.form-logo-header .logo-mark {
  width: 34px;
  height: 34px;
}
.login-visual h1 { max-width: 620px; margin: 0; font-size: clamp(42px, 6vw, 78px); line-height: 0.96; letter-spacing: 0; }
.login-visual p { max-width: 520px; margin: 22px 0 0; font-size: 18px; line-height: 1.5; color: rgba(255,255,255,.86); }

.login-panel {
  display: grid;
  align-content: center;
  padding: 48px min(8vw, 96px);
}

.login-form { max-width: 440px; width: 100%; }
.login-form h2 { margin: 0 0 8px; font-size: 28px; }
.login-form .muted { margin: 0 0 28px; }

.public-intake-shell {
  background: #f4f8fc;
}
.public-intake {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(280px, .72fr) minmax(320px, 1.28fr);
}
.public-intake-header {
  padding: 42px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(29, 111, 184, .95), rgba(21, 90, 150, .84)),
    url("data:image/svg+xml,%3Csvg width='700' height='700' viewBox='0 0 700 700' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23fff' stroke-opacity='.2'%3E%3Cpath d='M40 120h620M40 250h620M40 380h620M40 510h620M120 40v620M250 40v620M380 40v620M510 40v620'/%3E%3Ccircle cx='350' cy='350' r='160'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
}
.public-intake-header h1 {
  margin: 120px 0 16px;
  max-width: 560px;
  font-size: 48px;
  line-height: 1;
  letter-spacing: 0;
}
.public-intake-header p {
  max-width: 520px;
  margin: 0;
  color: rgba(255,255,255,.88);
  font-size: 17px;
  line-height: 1.5;
}
.public-intake-body {
  padding: 34px;
  align-self: start;
}
.public-intake-form {
  max-width: 860px;
  box-shadow: none;
}
.public-intake-form h2 {
  margin: 0 0 16px;
  font-size: 22px;
}
.privacy-notice {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
  margin: 8px 0 16px;
}
.privacy-notice summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--ink);
}
.privacy-notice p {
  margin: 12px 0;
  color: #22364d;
  line-height: 1.55;
}
.privacy-notice small {
  color: var(--muted);
  font-weight: 800;
}
.check-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  align-items: start;
  margin: 12px 0 18px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
.check-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}
.hp-field {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.form-status {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 800;
}
.success,
.form-status.success {
  color: #11693f;
  background: #eaf8f0;
  border: 1px solid #bfe8cf;
  border-radius: var(--radius);
  padding: 10px 12px;
}

.field { display: grid; gap: 8px; margin-bottom: 16px; }
label { color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(29, 111, 184, .14); }

.button-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.btn {
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
}
.btn:hover { background: var(--accent-strong); }
.btn.secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.mini { min-height: 30px; padding: 0 10px; font-size: 12px; }
.icon-btn { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; }

.layout {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 260px minmax(320px, 420px) 1fr;
}
.app-layout-v1 {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--bg);
}
.topbar {
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(220px, 300px) 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}
.topbar .nav-item {
  width: auto;
  min-height: 38px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 12px;
  white-space: nowrap;
}
.topbar .nav-item:hover,
.topbar .nav-item.active {
  background: var(--panel);
  border-left-color: transparent;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: end;
  min-width: 0;
}
.topbar-user span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.main-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
}
.main-shell.full-workspace {
  grid-template-columns: 1fr;
}
.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #f8fbff;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.sidebar h1 { margin: 0; font-size: 20px; line-height: 1.1; }
.user-block { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); }
.user-block strong { display: block; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.45; }
.nav-list { display: grid; gap: 8px; }
.nav-item { border-left: 3px solid var(--accent); padding: 9px 0 9px 12px; font-weight: 800; }

.patient-list {
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: calc(100svh - 68px);
}
.list-header { padding: 20px; border-bottom: 1px solid var(--line); display: grid; gap: 12px; }
.list-header h2 { margin: 0; font-size: 18px; }
.patients { overflow: auto; }
.patient-row {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 15px 20px;
}
.patient-row:hover, .patient-row.active { background: var(--panel); }
.patient-row strong { display: block; margin-bottom: 5px; }

.workspace { padding: 22px; min-width: 0; }
.workspace-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.workspace-header h2 { margin: 0 0 4px; font-size: 24px; }
.status-pill { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; background: #dbeeff; color: #155a96; font-size: 12px; font-weight: 900; }
.danger-pill { background: #fee2e2; color: #991b1b; margin-left: 6px; }

.content-grid { display: grid; grid-template-columns: minmax(280px, .78fr) minmax(380px, 1.22fr); gap: 18px; margin-top: 18px; align-items: start; }
.overview-grid {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}
.full-span {
  grid-column: 1 / -1;
}
.patient-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  margin: 16px 0;
  padding-bottom: 8px;
}
.patient-tab {
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}
.patient-tab:hover,
.patient-tab.active {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}
.patient-tab-panel {
  min-width: 0;
}
.section { padding: 0; }
.section + .section { margin-top: 18px; }
.section h3 { margin: 0 0 10px; font-size: 15px; }
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detail { border-top: 1px solid var(--line); padding-top: 8px; min-width: 0; }
.detail span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; margin-bottom: 3px; }
.detail strong { overflow-wrap: anywhere; font-size: 13px; }

.encounter { border-top: 1px solid var(--line); padding: 16px 0; }
.encounter:first-of-type { border-top: 0; padding-top: 0; }
.encounter h4 { margin: 0 0 6px; font-size: 15px; }
.encounter p { margin: 8px 0; color: #22364d; line-height: 1.5; }

.dental-chart-section {
  border-top: 2px solid var(--line);
  padding-top: 18px;
}
.tooth-chart {
  display: grid;
  grid-template-columns: repeat(16, minmax(34px, 1fr));
  gap: 7px;
  margin: 12px 0 16px;
  align-items: end;
}
.tooth-row-label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.tooth-button {
  position: relative;
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 58px;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
.tooth-button:hover,
.tooth-button.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(29, 111, 184, .12);
}
.tooth-button.has-note {
  background: #f3f8fd;
}
.tooth-shape {
  width: 22px;
  height: 26px;
  border: 2px solid #9eb8ce;
  border-radius: 45% 45% 55% 55%;
  background: linear-gradient(#fff, #eef6fd);
}
.tooth-button strong {
  font-size: 12px;
  line-height: 1;
}
.tooth-button small {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}
.dental-note-form textarea {
  min-height: 82px;
}
.dental-note-list {
  display: grid;
  gap: 8px;
}
.dental-note-list h4 {
  margin: 0;
  font-size: 14px;
}
.dental-note {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.dental-note strong,
.dental-note span {
  display: block;
}
.dental-note p {
  margin: 7px 0 0;
  color: #22364d;
  line-height: 1.45;
}

.form-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-section-title { margin: 8px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink); font-size: 15px; }

.audit-list { display: grid; gap: 10px; }
.audit-item { border-top: 1px solid var(--line); padding-top: 10px; }
.audit-item strong { display: block; font-size: 13px; }
.error { color: var(--danger); font-size: 14px; margin-top: 12px; }
.notice { color: var(--warning); background: #fff7df; border: 1px solid #f0dc9e; padding: 12px; border-radius: var(--radius); font-size: 14px; }
.empty { padding: 28px 0; color: var(--muted); }

@media (max-width: 1050px) {
  .layout { grid-template-columns: 220px 340px 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 1fr; align-items: stretch; }
  .topbar-user { justify-content: space-between; }
  .main-shell { grid-template-columns: minmax(280px, 330px) minmax(0, 1fr); }
  .overview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-visual { min-height: 38svh; padding: 34px; }
  .layout { grid-template-columns: 1fr; }
  .main-shell { grid-template-columns: 1fr; }
  .sidebar, .patient-list { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .patients { max-height: 320px; }
  .workspace { padding: 20px; }
  .workspace-header, .button-row { align-items: stretch; }
  .workspace-header { flex-direction: column; }
  .form-grid, .details { grid-template-columns: 1fr; }
  .tooth-chart { grid-template-columns: repeat(8, minmax(34px, 1fr)); }
  .patient-list { min-height: auto; }
  .top-nav { padding-bottom: 2px; }
}

input[readonly] { background: #f3f8fd; color: var(--muted); cursor: not-allowed; }
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 42px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.billing-section { border-top: 2px solid var(--line); padding-top: 22px; }
.folio-toolbar {
  display: grid;
  grid-template-columns: minmax(190px, 260px) 1fr;
  gap: 12px;
  align-items: end;
  margin: 12px 0 16px;
}
.folio-create-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.billing-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0 16px; }
.billing-summary div { background: #f3f8fd; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.billing-summary span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; margin-bottom: 4px; }
.billing-summary strong { font-size: 16px; }
.compact-form { margin-bottom: 18px; }
.billing-list { display: grid; gap: 10px; }
.billing-record { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; border-top: 1px solid var(--line); padding: 14px 0; }
.billing-record h4 { margin: 0 0 5px; font-size: 15px; }
.billing-record p { margin: 8px 0 0; color: #22364d; line-height: 1.45; }
.billing-record > strong { white-space: nowrap; }
.billing-record.payment > strong, .billing-record.adjustment > strong { color: #155a96; }
.billing-record.void {
  opacity: .68;
}
.billing-record.void h4,
.billing-record.void p {
  text-decoration: line-through;
}
.billing-record-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}
.billing-record-actions > strong {
  white-space: nowrap;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.intake-filter-section {
  margin-top: 18px;
}
.intake-list {
  display: grid;
  gap: 14px;
}
.intake-record {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
.intake-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}
.intake-title-row h3 {
  margin: 0;
}

.calendar-controls {
  margin-top: 18px;
}
.calendar-request-list,
.calendar-grid {
  display: grid;
  gap: 12px;
}
.calendar-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.month-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.calendar-weekday {
  padding: 10px;
  background: #eef5fb;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.calendar-weekday:nth-child(7) {
  border-right: 0;
}
.calendar-cell {
  min-height: 128px;
  padding: 8px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: #fff;
}
.calendar-cell:nth-child(7n) {
  border-right: 0;
}
.calendar-cell.muted-month {
  background: #f7fafd;
  color: var(--muted);
}
.calendar-cell.today {
  box-shadow: inset 0 0 0 2px rgba(29,111,184,.35);
}
.calendar-date {
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 6px;
}
.calendar-events {
  display: grid;
  gap: 5px;
}
.calendar-event {
  width: 100%;
  border: 0;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 6px 7px;
  background: #eaf3fb;
  color: var(--ink);
  text-align: left;
  display: grid;
  gap: 2px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.calendar-event:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(16,32,51,.12);
}
.calendar-event span {
  font-size: 11px;
  font-weight: 900;
}
.calendar-event strong {
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-event.status-requested {
  border-left-color: var(--warning);
  background: #fff3d8;
}
.calendar-event.status-scheduled {
  border-left-color: var(--accent);
  background: #e8f3ff;
}
.calendar-event.status-completed {
  border-left-color: #2f7d4d;
  background: #e8f7ee;
}
.calendar-event.status-cancelled,
.calendar-event.status-missed {
  border-left-color: var(--danger);
  background: #fdecec;
}
.calendar-day {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.calendar-day h4 {
  margin: 0 0 10px;
}
.calendar-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: 10px;
}
.calendar-item.status-requested {
  border-left-color: var(--warning);
  background: #fffaf0;
}
.calendar-item.status-completed {
  border-left-color: #2f7d4d;
}
.calendar-item.status-cancelled,
.calendar-item.status-missed {
  border-left-color: var(--danger);
  opacity: .78;
}
.calendar-item-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.calendar-item p {
  margin: 8px 0 0;
  color: #22364d;
  line-height: 1.45;
}
.compact-actions {
  gap: 6px;
}
.compact-actions .btn {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16,32,51,.42);
}
.appointment-modal {
  width: min(760px, 100%);
  max-height: calc(100svh - 40px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.modal-actions {
  margin-top: 16px;
}

@media (max-width: 820px) {
  .billing-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .folio-toolbar,
  .folio-create-form { grid-template-columns: 1fr; }
  .billing-record { flex-direction: column; }
  .calendar-item-title { align-items: flex-start; flex-direction: column; }
  .month-calendar {
    grid-template-columns: 1fr;
  }
  .calendar-weekday {
    display: none;
  }
  .calendar-cell {
    min-height: auto;
    border-right: 0;
  }
  .calendar-cell.muted-month:empty {
    display: none;
  }
  .public-intake { grid-template-columns: 1fr; }
  .public-intake-header { padding: 30px; }
  .public-intake-header h1 { margin-top: 54px; font-size: 36px; }
  .public-intake-body { padding: 20px; }
}

.sidebar-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pin-btn { min-height: 34px; padding: 0 10px; font-size: 12px; white-space: nowrap; }
.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  padding: 9px 0 9px 12px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nav-item:hover, .nav-item.active { background: var(--panel); border-left-color: var(--accent); }
.nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.sidebar.unpinned { width: 78px; padding: 18px 12px; align-items: center; }
.sidebar.unpinned .brand,
.sidebar.unpinned .logo-mark,
.sidebar.unpinned .brand-lockup small,
.sidebar.unpinned h1,
.sidebar.unpinned .sidebar-copy,
.sidebar.unpinned .notice,
.sidebar.unpinned .user-block .muted,
.sidebar.unpinned .user-block strong { display: none; }
.sidebar.unpinned .sidebar-top { justify-content: center; }
.sidebar.unpinned .pin-btn { width: 54px; padding: 0; }
.sidebar.unpinned .nav-item { font-size: 0; padding: 12px 0; text-align: center; border-left: 0; border-radius: var(--radius); }
.sidebar.unpinned .nav-item::first-letter { font-size: 0; }
.sidebar.unpinned .nav-item[data-module="records"]::after { content: "Px"; font-size: 13px; font-weight: 900; }
.sidebar.unpinned .nav-item[data-module="billing"]::after { content: "₱"; font-size: 18px; font-weight: 900; }
.sidebar.unpinned .user-block { width: 100%; padding-top: 12px; }
.sidebar.unpinned .user-block .btn { width: 100%; padding: 0; font-size: 0; }
.sidebar.unpinned .user-block .btn::after { content: "Out"; font-size: 12px; }
.layout:has(.sidebar.unpinned) { grid-template-columns: 78px minmax(320px, 420px) 1fr; }

.audit-toggle {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  text-align: left;
  color: var(--ink);
}
.audit-toggle strong { display: block; font-size: 15px; }
.audit-toggle small { display: block; color: var(--muted); margin-top: 2px; font-weight: 600; }
.audit-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.audit-controls .full { grid-column: 1 / -1; }
.audit-list.compact { margin-top: 8px; max-height: 220px; overflow: auto; border-top: 1px solid var(--line); }

@media (max-width: 1050px) {
  .layout:has(.sidebar.unpinned) { grid-template-columns: 78px 340px 1fr; }
}

@media (max-width: 820px) {
  .sidebar.unpinned { width: auto; }
  .layout:has(.sidebar.unpinned) { grid-template-columns: 1fr; }
  .audit-controls { grid-template-columns: 1fr; }
}

.report-filter-section .form-grid {
  align-items: end;
}

.report-summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.report-summary-cards > div {
  border: 1px solid #d8e7ff;
  border-radius: 8px;
  padding: 10px;
  background: #f7fbff;
}

.report-summary-cards span {
  display: block;
  color: #58708f;
  font-size: 12px;
  margin-bottom: 4px;
}

.report-summary-cards strong {
  font-size: 16px;
  color: #0f3e78;
}

.report-table-wrap {
  overflow: auto;
  border: 1px solid #d8e7ff;
  border-radius: 16px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 12px;
}

.report-table th,
.report-table td {
  text-align: left;
  padding: 8px 9px;
  border-bottom: 1px solid #e6eef8;
  vertical-align: top;
}

.report-table th {
  background: #eef6ff;
  color: #0f3e78;
  font-weight: 700;
}

.report-patient-card {
  border: 1px solid #d8e7ff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fff;
}

.report-patient-card h4,
.report-patient-card h5 {
  margin: 0 0 10px;
}

.compact-details {
  margin-bottom: 12px;
}

.mini-record {
  border-left: 3px solid #1f6fd1;
  background: #f7fbff;
  padding: 8px 10px;
  border-radius: 8px;
  margin: 6px 0;
}

.mini-record strong,
.mini-record span {
  display: block;
}

.small-empty {
  padding: 10px;
}

@media (max-width: 900px) {
  .report-summary-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.global-alerts { display: grid; gap: 10px; margin-bottom: 16px; }
.critical-alert { padding: 12px 14px; border-radius: 14px; background: #fee2e2; color: #7f1d1d; font-weight: 800; border: 1px solid #fecaca; letter-spacing: .04em; }
.verification-alert { padding: 12px 14px; border-radius: 14px; background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.btn.mini { padding: 7px 10px; font-size: 12px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check-field { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #dbeafe; background: #f8fbff; border-radius: 12px; font-weight: 700; color: #12315f; }
.check-field input { width: 18px; height: 18px; accent-color: #1d4ed8; }
.compact-vitals { margin-top: 16px; }
.vital-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
.vital-card { --vital-accent: #1d4ed8; border: 1px solid #dbeafe; border-left: 4px solid var(--vital-accent); border-radius: 8px; padding: 8px 9px; background: #f8fbff; color: var(--vital-accent); min-height: 58px; display: grid; align-content: center; gap: 3px; }
.vital-card.empty { color: #94a3b8; border-left-color: #cbd5e1; background: #f8fafc; }
.vital-card span { color: #58708f; font-size: 11px; font-weight: 800; }
.vital-card strong { color: #0f3e78; font-size: 13px; white-space: nowrap; }
.vital-card:not(.empty) strong { color: var(--vital-accent); }
.field small.muted { display: block; margin-top: 6px; line-height: 1.4; }
@media (max-width: 760px) { .checkbox-grid { grid-template-columns: 1fr; } }

.section-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-header-row h3,
.section-header-row p {
  margin-top: 0;
}

.required-mark {
  color: #b91c1c;
  font-weight: 800;
  margin-left: 0.25rem;
}

.form-help {
  margin: 0 0 1rem;
  color: #475569;
  font-size: 0.92rem;
}

.form-panel.compact-form {
  margin-top: 0.75rem;
  border: 1px solid #dbeafe;
  background: #f8fbff;
}

.patient-summary-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.detail-disclosure {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.detail-disclosure summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 10px;
}

.detail-disclosure:not([open]) {
  padding-bottom: 4px;
}

.other-address-input[hidden] {
  display: none;
}

@media (max-width: 760px) {
  .section-header-row {
    flex-direction: column;
  }
  .section-header-row .btn {
    width: 100%;
  }
}

.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.print-header {
  display: none;
}

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

@media print {
  body {
    background: #fff;
  }
  .sidebar,
  .topbar,
  .patient-list,
  .patient-tabs,
  .workspace-header,
  .no-print,
  .error,
  .success {
    display: none !important;
  }
  .layout {
    display: block;
  }
  .workspace {
    padding: 0;
    overflow: visible;
  }
  .section,
  .printable-report {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
  }
  .print-header {
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #0f3e78;
    margin-bottom: 10px;
    padding-bottom: 8px;
  }
  .print-logo {
    width: 42px;
    height: 42px;
  }
  .print-header h2 { margin: 0 0 4px; font-size: 16px; }
  .print-header div { display: grid; gap: 2px; font-size: 10px; color: #334155; }
  .printable-report h3 { margin: 0 0 8px; font-size: 13px; }
  .report-summary-cards { gap: 6px; margin-bottom: 8px; }
  .report-summary-cards > div { padding: 6px; border-radius: 0; }
  .report-summary-cards span { font-size: 9px; margin-bottom: 1px; }
  .report-summary-cards strong { font-size: 12px; }
  .report-table {
    font-size: 9px;
    min-width: 0;
  }
  .report-table th,
  .report-table td {
    border: 1px solid #cbd5e1;
    padding: 4px 5px;
  }
  .report-patient-card { padding: 8px; border-radius: 0; margin-bottom: 8px; break-inside: avoid; }
  .mini-record { padding: 5px 6px; border-radius: 0; margin: 4px 0; }
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}
.role-card,
.user-record {
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 16px;
  background: #ffffff;
  padding: 0.9rem;
}
.role-card strong,
.user-record h4 {
  display: block;
  margin-bottom: 0.35rem;
}
.user-list {
  display: grid;
  gap: 0.75rem;
}
.user-record {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}
.user-record.inactive {
  opacity: 0.62;
}
