:root {
  --forest: #164d38;
  --forest-dark: #0d3527;
  --green: #218a5d;
  --green-bright: #36a66f;
  --green-soft: #e5f4eb;
  --mint: #f1f8f4;
  --ink: #193129;
  --muted: #65766f;
  --line: #d8e2dd;
  --surface: #ffffff;
  --canvas: #f3f6f4;
  --coral: #c85f4a;
  --gold: #c7932d;
  --shadow: 0 8px 24px rgba(24, 62, 47, 0.07);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

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

button,
a { -webkit-tap-highlight-color: transparent; }

a { color: inherit; text-decoration: none; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 258px;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  color: #fff;
  background: var(--forest-dark);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 0 7px 18px;
  border-bottom: 1px solid rgba(255,255,255,.14);
}

.brand-mark {
  width: 45px;
  height: 45px;
  flex: 0 0 45px;
  display: grid;
  place-items: center;
  color: var(--forest);
  background: #fff;
  border-radius: 50%;
  font-weight: 800;
}

.brand strong,
.brand small,
.sidebar-user strong,
.sidebar-user small,
.top-profile strong,
.top-profile small,
.print-brand strong,
.print-brand small { display: block; }

.brand strong { font-size: 15px; }
.brand small { margin-top: 2px; color: #bed4ca; font-size: 11px; }

.main-nav {
  flex: 1;
  padding-top: 18px;
  overflow-y: auto;
}

.nav-label {
  margin: 20px 12px 7px;
  color: #8fb1a3;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 43px;
  margin: 3px 0;
  padding: 0 12px;
  color: #e8f2ed;
  border-radius: 7px;
  font-weight: 600;
}

.nav-link:hover { background: rgba(255,255,255,.09); }

.nav-link.active {
  color: #fff;
  background: var(--green);
  box-shadow: inset 3px 0 0 #92dfb4;
}

.nav-icon {
  width: 25px;
  height: 25px;
  flex: 0 0 25px;
  display: grid;
  place-items: center;
  color: #c6e1d5;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 6px;
  font-size: 9px;
  font-weight: 800;
}

.nav-link.active .nav-icon { color: #fff; border-color: rgba(255,255,255,.5); }

.nav-parent {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 4px;
}

.submenu-toggle {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255,255,255,.08);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.submenu-toggle span {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .18s ease;
}

.submenu-toggle[aria-expanded="true"] span { transform: rotate(225deg) translate(-1px, -1px); }

.submenu { display: none; }
.submenu.open { display: block; }
.sub-link { min-height: 37px; margin-left: 35px; padding-left: 9px; font-size: 13px; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 17px 7px 2px;
  border-top: 1px solid rgba(255,255,255,.14);
}
.sidebar-user-copy { min-width: 0; flex: 1; }
.sidebar-user-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { margin: 0; }
.logout-form button { min-width: 38px; height: 31px; padding: 0 7px; color: #d9e9e1; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); border-radius: 6px; cursor: pointer; font-size: 10px; }

.user-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--forest);
  background: #d9f1e4;
  border-radius: 50%;
  font-weight: 800;
}

.sidebar-user small { color: #a9c5b9; font-size: 11px; }

.app-shell { min-height: 100vh; margin-left: 258px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-content: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}

.icon-button span { width: 17px; height: 2px; background: var(--forest); }
.menu-button { display: none; }

.global-search {
  width: min(500px, 46vw);
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.search-symbol {
  width: 14px;
  height: 14px;
  position: relative;
  border: 2px solid #71837b;
  border-radius: 50%;
}

.search-symbol::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 2px;
  background: #71837b;
  transform: rotate(45deg);
}

.global-search input { width: 100%; border: 0; outline: 0; background: transparent; }

.top-profile {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
}

.top-profile small { color: var(--muted); font-size: 11px; }
.online-dot { width: 9px; height: 9px; background: #37a96f; border-radius: 50%; box-shadow: 0 0 0 4px #e3f3e9; }

.page-content { max-width: 1600px; min-height: calc(100vh - 68px); padding: 28px 30px 48px; margin: 0 auto; }

.alert {
  margin-bottom: 18px;
  padding: 12px 15px;
  background: #fff;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.alert.success { color: #176f4b; border-left-color: var(--green); }
.alert.error { color: #a34436; border-left-color: var(--coral); }

.confirm-open { overflow: hidden; }
.confirm-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; }
.confirm-modal[hidden] { display: none; }
.confirm-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(7, 28, 21, .58); backdrop-filter: blur(2px); cursor: default; }
.confirm-dialog { position: relative; width: min(440px, 100%); display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 14px; padding: 24px; background: #fff; border: 1px solid #d9e5de; border-radius: 8px; box-shadow: 0 24px 70px rgba(7, 34, 25, .28); }
.confirm-symbol { width: 48px; height: 48px; display: grid; place-items: center; color: #a34436; background: #fff0ed; border: 1px solid #efc9c1; border-radius: 50%; font-size: 24px; font-weight: 800; }
.confirm-copy h2 { margin: 3px 0 7px; font-size: 20px; }
.confirm-copy > p:last-child { margin: 0; color: var(--muted); line-height: 1.55; }
.confirm-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; padding-top: 7px; }
.confirm-button { color: #fff; background: #b34d3d; border-color: #b34d3d; }
.confirm-button:hover { background: #983f32; }
.confirm-button:disabled { cursor: wait; opacity: .7; }

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 22px;
}

.page-heading.compact { align-items: center; }
.page-heading h1 { margin: 2px 0 5px; font-size: 28px; line-height: 1.2; letter-spacing: 0; }
.page-heading p:not(.eyebrow) { max-width: 760px; margin: 0; color: var(--muted); }
.eyebrow { margin: 0; color: var(--green); font-size: 11px; font-weight: 800; text-transform: uppercase; }

.heading-actions,
.form-actions,
.filter-bar,
.panel-heading,
.report-heading,
.danger-zone { display: flex; align-items: center; }

.heading-actions { gap: 9px; }

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.button.primary { color: #fff; background: var(--green); border-color: var(--green); }
.button.primary:hover { background: #18764e; }
.button.secondary { color: var(--forest); background: #fff; border-color: var(--line); }
.button.secondary:hover { border-color: #9eb7aa; background: var(--mint); }
.button.danger { color: #aa4938; background: #fff; border-color: #e8b7ae; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 16px;
}

.metric {
  min-height: 125px;
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--green);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric:nth-child(3) { border-top-color: #2c8d8d; }
.metric:nth-child(4) { border-top-color: var(--coral); }
.metric:nth-child(5) { border-top-color: var(--gold); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 11px 0 3px; font-size: 28px; }
.metric small { font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr); gap: 16px; }

.panel,
.form-section,
.record-header-card,
.patient-banner,
.print-record,
.summary-strip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel { padding: 18px; }
.panel-heading { justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.panel-heading h2, .report-heading h2 { margin: 2px 0 0; font-size: 17px; }
.text-link, .record-link, .row-actions a { color: var(--green); font-weight: 700; }
.text-link:hover, .record-link:hover, .row-actions a:hover { text-decoration: underline; }

.quick-links { display: grid; gap: 8px; }
.quick-links a {
  min-height: 66px;
  display: grid;
  grid-template-columns: 37px minmax(0, 1fr) 15px;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.quick-links a:hover { background: var(--mint); border-color: #abc9ba; }
.quick-links strong, .quick-links small { display: block; }
.quick-links small { margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.3; }
.quick-links b { color: var(--green); }
.quick-icon { width: 36px; height: 36px; display: grid; place-items: center; color: var(--forest); background: var(--green-soft); border-radius: 7px; font-size: 10px; font-weight: 800; }
.compact-links a { min-height: 54px; }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th, .data-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table th { color: #5a6d64; background: #f3f7f5; font-size: 10px; text-transform: uppercase; }
.data-table tbody tr:hover { background: #fbfdfc; }
.empty-cell { padding: 34px !important; color: var(--muted); text-align: center !important; }
.actions-column { width: 108px; }
.row-actions { display: flex; gap: 12px; }
.row-actions form { margin: 0; }
.text-action { padding: 0; border: 0; color: var(--green); background: transparent; font: inherit; font-weight: 700; cursor: pointer; }
.text-action:hover { text-decoration: underline; }
.danger-text { color: #aa4938; }
.muted-copy { color: var(--muted); font-size: 11px; }
.mono { font-family: Consolas, monospace; font-size: 12px; }

.status { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.status.completed { color: #176f4b; background: #dff3e8; }
.status.draft { color: #8d6513; background: #faefd4; }

.filter-bar { justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.inline-search { width: min(560px, 100%); display: flex; gap: 8px; }
.inline-search input { flex: 1; }
.record-count { color: var(--muted); font-size: 12px; font-weight: 700; }

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd8d2;
  border-radius: 6px;
  outline: 0;
}

textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(33,138,93,.12); }

.form-section { margin-bottom: 14px; padding: 18px; }
.section-heading { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 16px; }
.section-number { width: 31px; height: 31px; flex: 0 0 31px; display: grid; place-items: center; color: var(--green); background: var(--green-soft); border-radius: 6px; font-size: 11px; font-weight: 800; }
.section-heading h2 { margin: 0; font-size: 15px; }
.section-heading p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }

.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.span-1 { grid-column: span 1; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 6px; color: #43584e; font-size: 11px; font-weight: 700; }
.field label b { color: var(--coral); }
.linked-field label::after {
  content: "Read only";
  float: right;
  padding: 2px 6px;
  color: #536a5f;
  background: #e3ebe7;
  border: 1px solid #c7d5ce;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}
.linked-field input[readonly],
.linked-field textarea[readonly],
.linked-field select:disabled {
  color: #52635b;
  background: #eef3f0;
  border-color: #c3d1ca;
  box-shadow: inset 3px 0 0 #789686;
  cursor: not-allowed;
  opacity: 1;
}
.linked-field input[readonly]:focus,
.linked-field textarea[readonly]:focus,
.linked-field select:disabled:focus {
  border-color: #c3d1ca;
  box-shadow: inset 3px 0 0 #789686;
}
.field-error { display: block; margin-top: 4px; color: #b64d3c; font-size: 11px; }
.validation-summary { margin-bottom: 14px; padding: 11px 14px; color: #a34436; background: #fff3f0; border: 1px solid #efc9c1; border-radius: 7px; }
.validation-summary-valid { display: none; }
.validation-summary ul { margin: 5px 0 0; padding-left: 18px; }

.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #edf4f0; }
.error-shell { width: min(560px, 100%); padding: 34px; background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--green); border-radius: 8px; box-shadow: var(--shadow); }
.error-code { display: block; margin-bottom: 18px; color: var(--green); font-size: 42px; font-weight: 800; line-height: 1; }
.error-shell h1 { margin: 5px 0 10px; font-size: 27px; }
.error-shell > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.error-reference { padding: 9px 11px; background: #f3f7f5; border: 1px solid var(--line); border-radius: 6px; font-family: Consolas, monospace; font-size: 11px; }
.error-shell .heading-actions { margin-top: 22px; }

.record-header-card { display: flex; align-items: center; gap: 15px; margin-bottom: 14px; padding: 16px 18px; }
.record-head-fields { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.patient-avatar { width: 62px; height: 62px; flex: 0 0 62px; display: grid; place-items: center; color: #fff; background: var(--green); border-radius: 50%; font-size: 21px; font-weight: 800; }
.patient-avatar.small { width: 48px; height: 48px; flex-basis: 48px; font-size: 14px; }

.choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.choice { min-height: 34px; display: flex !important; align-items: center; gap: 7px; margin: 0 !important; padding: 6px 8px; background: #f9fbfa; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.choice input { width: 15px; height: 15px; min-height: 0; accent-color: var(--green); }
.choice span { font-weight: 500; }

.progress-notes-section { overflow: hidden; }
.progress-badge { color: #fff; background: var(--green); }
.progress-notes-table { width: 100%; min-width: 980px; border-collapse: collapse; table-layout: fixed; }
.progress-notes-table th,
.progress-notes-table td { padding: 8px; border: 1px solid var(--line); vertical-align: top; }
.progress-notes-table th { color: #53675d; background: #f1f6f3; font-size: 10px; text-align: left; text-transform: uppercase; }
.progress-notes-table th:nth-child(1) { width: 170px; }
.progress-notes-table th:nth-child(2) { width: 170px; }
.progress-notes-table th:nth-child(3) { width: auto; }
.progress-notes-table th:nth-child(4) { width: 165px; }
.progress-notes-table th:nth-child(5) { width: 135px; }
.progress-notes-table th:nth-child(6) { width: 62px; text-align: center; }
.progress-notes-table input,
.progress-notes-table select { min-height: 35px; padding: 6px 8px; }
.progress-notes-table textarea { min-height: 64px; padding: 6px 8px; }
.progress-row.is-hidden { display: none; }
.table-icon { width: 34px; height: 34px; display: grid; place-items: center; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-weight: 800; }
.table-icon.danger-icon { color: var(--coral); border-color: #e8c1b9; }
.add-progress-button { margin-top: 10px; }
.psychologist-notes { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.psychologist-notes textarea { min-height: 130px; }
.character-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; text-align: right; }
.empty-progress { margin: 0; padding: 20px; color: var(--muted); background: #f8faf9; border: 1px dashed var(--line); text-align: center; }
.psychologist-note-view { margin-top: 16px; padding: 14px; background: #f8faf9; border: 1px solid var(--line); border-radius: 6px; }
.psychologist-note-view strong { color: var(--green); text-transform: uppercase; font-size: 11px; }
.psychologist-note-view p { margin: 7px 0 0; white-space: pre-wrap; }
.view-table th:nth-child(1) { width: 160px; }
.view-table th:nth-child(5) { width: 120px; }
.psych-tests-table { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
.psych-tests-table th,
.psych-tests-table td { padding: 8px; border: 1px solid var(--line); vertical-align: top; }
.psych-tests-table th { color: #53675d; background: #f1f6f3; font-size: 10px; text-align: left; text-transform: uppercase; }
.psych-tests-table th:nth-child(1) { width: 34%; }
.psych-tests-table th:nth-child(2) { width: auto; }
.psych-tests-table th:nth-child(3) { width: 62px; text-align: center; }
.psych-tests-table input { min-height: 38px; }
.psych-tests-table textarea { min-height: 76px; }
.psych-test-row.is-hidden { display: none; }
.add-psych-test-button { margin-top: 10px; }
.psych-tests-table.view-table th:first-child { width: 34%; }

.child-immunization-section,
.child-growth-section { overflow: hidden; }
.immunization-table { width: 100%; min-width: 960px; border-collapse: collapse; table-layout: fixed; }
.immunization-table th,
.immunization-table td { padding: 7px; border: 1px solid var(--line); text-align: center; vertical-align: middle; }
.immunization-table thead th { color: #40594c; background: #eaf2ee; font-size: 10px; line-height: 1.35; }
.immunization-table tbody th { width: 145px; color: var(--forest); background: #f6f9f7; text-align: left; font-size: 11px; }
.immunization-table input { min-width: 118px; min-height: 36px; padding: 5px 6px; }
.immunization-table .na-cell { color: #85978e; background: #e6ece9; font-size: 9px; font-weight: 800; }
.immunization-table.view-table td { font-size: 10px; }
.child-growth-table { width: 100%; min-width: 1120px; border-collapse: collapse; table-layout: fixed; }
.child-growth-table th,
.child-growth-table td { padding: 7px; border: 1px solid var(--line); vertical-align: top; }
.child-growth-table th { color: #53675d; background: #f1f6f3; font-size: 10px; text-align: left; text-transform: uppercase; }
.child-growth-table th:nth-child(1) { width: 140px; }
.child-growth-table th:nth-child(2) { width: 85px; }
.child-growth-table th:nth-child(3),
.child-growth-table th:nth-child(4),
.child-growth-table th:nth-child(5) { width: 105px; }
.child-growth-table th:nth-child(6),
.child-growth-table th:nth-child(7) { width: 210px; }
.child-growth-table th:nth-child(8) { width: 62px; text-align: center; }
.child-growth-table input { min-height: 35px; padding: 6px; }
.child-growth-table textarea { min-height: 58px; padding: 6px; }
.child-growth-row.is-hidden { display: none; }
.previous-consultations-section { overflow: hidden; }
.history-badge { color: #fff; background: #2c8d8d; }
.consultation-history-table { min-width: 900px; }
.consultation-history-table th:first-child { width: 120px; }
.consultation-history-table th:last-child { width: 70px; }
.archive-filters { width: min(720px, 100%); display: grid; grid-template-columns: 190px minmax(220px, 1fr) auto; gap: 8px; }
.compact-button { min-height: 32px; padding: 0 11px; color: #176f4b; background: #e4f4eb; border-color: #b9dcc9; }
.compact-button:hover { background: #d5eddf; }
.deleted-records-table { min-width: 1080px; }
.archive-actions { align-items: center; }
.audit-table { min-width: 760px; }
.audit-table th:first-child { width: 190px; }
.audit-table th:nth-child(2) { width: 105px; }
.audit-table th:nth-child(3) { width: 230px; }
.status.audit-created, .status.audit-restored { color: #176f4b; background: #dff3e8; }
.status.audit-updated { color: #285f76; background: #e0f0f5; }
.status.audit-deleted { color: #a34436; background: #fff0ed; }

.form-actions { justify-content: flex-end; gap: 9px; padding-top: 5px; }
.sticky-actions { position: sticky; bottom: 12px; z-index: 10; padding: 12px; background: rgba(243,246,244,.95); border: 1px solid var(--line); border-radius: 8px; }

.summary-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 15px; overflow: hidden; }
.summary-strip div { min-height: 80px; padding: 15px 17px; border-right: 1px solid var(--line); }
.summary-strip div:last-child { border-right: 0; }
.summary-strip span, .summary-strip strong { display: block; }
.summary-strip span { color: var(--muted); font-size: 11px; }
.summary-strip strong { margin-top: 7px; font-size: 18px; }

.patient-banner { display: flex; align-items: center; gap: 18px; padding: 20px; margin-bottom: 16px; }
.patient-main { min-width: 220px; }
.patient-main h2 { margin: 0 0 3px; font-size: 19px; }
.patient-main p { margin: 0; color: var(--muted); font-family: Consolas, monospace; }
.profile-facts { flex: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin: 0; }
.profile-facts div.wide { grid-column: span 2; }
.profile-facts dt, .detail-grid dt { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.profile-facts dd, .detail-grid dd { margin: 3px 0 0; font-weight: 600; }
.patient-records { align-items: start; }

.danger-zone { justify-content: space-between; gap: 18px; margin-top: 18px; padding: 15px 17px; background: #fffafa; border: 1px solid #ecd0ca; border-radius: 8px; }
.danger-zone p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.danger-zone form { margin: 0; }

.print-record { padding: 24px; }
.print-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid var(--forest); }
.print-brand { display: flex; align-items: center; gap: 10px; }
.print-brand small { color: var(--muted); }
.print-title { text-align: right; }
.print-title p { margin: 0; color: var(--green); font-family: Consolas, monospace; font-size: 12px; }
.print-title h1 { margin: 3px 0 0; font-size: 22px; }
.record-overview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.record-overview span, .record-overview strong { display: block; }
.record-overview > div > span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.record-overview > div > strong { margin-top: 4px; }
.detail-section { padding: 19px 0 4px; border-bottom: 1px solid var(--line); }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin: 0; }
.detail-grid > div { min-height: 52px; padding: 10px; background: #f8faf9; border-radius: 6px; }
.detail-grid dd { white-space: pre-wrap; font-weight: 500; }
.record-signature { display: grid; grid-template-columns: 1fr 1fr; gap: 80px; margin-top: 70px; }
.record-signature div { text-align: center; }
.record-signature span { display: block; border-top: 1px solid var(--ink); }
.record-signature strong, .record-signature small { display: block; }
.record-signature strong { margin-top: 5px; }
.record-signature small { color: var(--muted); }

.report-filters { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 20px; padding: 14px; background: #f6f9f7; border: 1px solid var(--line); border-radius: 7px; }
.report-filters .field { width: 220px; }
.report-filters .field.grow { flex: 1; width: auto; }
.report-heading { justify-content: space-between; margin-bottom: 13px; }

.sidebar-scrim { display: none; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #edf3ef; }
.login-shell { width: min(900px, 100%); min-height: 540px; display: grid; grid-template-columns: .9fr 1.1fr; overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 24px 60px rgba(13,53,39,.15); }
.login-brand-panel { display: flex; flex-direction: column; justify-content: center; padding: 48px; color: #fff; background: var(--forest-dark); }
.login-brand-panel .eyebrow { margin-top: 28px; color: #8ed7b0; }
.login-brand-panel h1 { margin: 8px 0 16px; font-size: 32px; line-height: 1.2; }
.login-brand-panel p:not(.eyebrow) { color: #c2d8ce; }
.login-brand-panel small { margin-top: auto; color: #9ab9ac; }
.login-brand-mark { width: 62px; height: 62px; display: grid; place-items: center; color: var(--forest); background: #fff; border-radius: 50%; font-size: 18px; font-weight: 800; }
.login-card { display: flex; flex-direction: column; justify-content: center; padding: 48px 56px; }
.login-card h2 { margin: 4px 0 5px; font-size: 25px; }
.login-card > div > p:not(.eyebrow), .login-help { color: var(--muted); }
.login-form { display: grid; gap: 15px; margin-top: 28px; }
.remember-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.remember-check input { width: 16px; height: 16px; min-height: 0; accent-color: var(--green); }
.login-button { width: 100%; margin-top: 3px; }
.login-help { margin: 25px 0 0; font-size: 11px; text-align: center; }

.permission-count { display: inline-flex; margin-right: 5px; padding: 3px 7px; color: #176f4b; background: #e4f4eb; border-radius: 999px; font-size: 10px; font-weight: 700; }
.permission-count.edit { color: #7c5a16; background: #f8edd3; }
.permission-table-wrap { overflow-x: auto; }
.permission-table { width: 100%; min-width: 620px; border-collapse: collapse; }
.permission-table th, .permission-table td { padding: 11px 12px; border: 1px solid var(--line); text-align: left; }
.permission-table th { color: #53675d; background: #f1f6f3; font-size: 10px; text-transform: uppercase; }
.permission-table th:nth-child(3), .permission-table th:nth-child(4), .permission-table td:nth-child(3), .permission-table td:nth-child(4) { width: 110px; text-align: center; }
.permission-check { display: inline-flex !important; align-items: center; gap: 7px; margin: 0 !important; cursor: pointer; }
.permission-check input { width: 16px; height: 16px; min-height: 0; accent-color: var(--green); }
.permission-check input:disabled { cursor: not-allowed; opacity: .65; }
.account-active { display: flex !important; align-items: center; gap: 10px; min-height: 52px; margin: 0 !important; padding: 9px 12px; background: var(--mint); border: 1px solid var(--line); border-radius: 6px; }
.account-active input { width: 17px; height: 17px; min-height: 0; accent-color: var(--green); }
.account-active span strong, .account-active span small { display: block; }
.account-active span small { color: var(--muted); font-weight: 400; }
.admin-permission-note { margin: 11px 0 0; color: var(--muted); font-size: 11px; }
.narrow-form { max-width: 720px; }
.access-denied { max-width: 620px; margin: 60px auto; padding: 38px; text-align: center; }
.access-denied h1 { margin: 12px 0 7px; }
.access-denied p { margin: 0 auto 20px; color: var(--muted); }
.access-mark { display: inline-grid; place-items: center; width: 70px; height: 50px; color: #a34d3d; background: #fff0ed; border-radius: 7px; font-size: 18px; font-weight: 800; }

@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-grid, .record-head-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3, .span-4 { grid-column: 1 / -1; }
  .choice-grid { grid-template-columns: repeat(3, 1fr); }
  .profile-facts { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  body.menu-open .sidebar { transform: translateX(0); }
  body.menu-open .sidebar-scrim { position: fixed; inset: 0; z-index: 25; display: block; background: rgba(8,30,22,.45); }
  .app-shell { margin-left: 0; }
  .menu-button { display: grid; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 22px 16px 38px; }
  .top-profile span:not(.online-dot) { display: none; }
  .global-search { width: 100%; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; flex-wrap: wrap; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .record-header-card, .patient-banner { align-items: flex-start; flex-direction: column; }
  .record-head-fields, .form-grid { width: 100%; }
  .profile-facts { width: 100%; }
  .choice-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-strip { grid-template-columns: repeat(2, 1fr); }
  .summary-strip div:nth-child(2) { border-right: 0; }
  .summary-strip div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .report-filters { align-items: stretch; flex-direction: column; }
  .report-filters .field { width: 100%; }
  .archive-filters { width: 100%; grid-template-columns: 1fr 1fr auto; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 250px; padding: 32px; }
  .login-brand-panel small { margin-top: 25px; }
  .login-card { padding: 35px 32px; }
}

@media (max-width: 560px) {
  .metric-grid, .form-grid, .record-head-fields, .profile-facts, .record-overview, .detail-grid { grid-template-columns: 1fr; }
  .span-1, .span-2, .span-3, .span-4, .profile-facts div.wide { grid-column: 1; }
  .choice-grid { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .inline-search { flex-direction: column; }
  .archive-filters { grid-template-columns: 1fr; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .button { flex: 1; }
  .print-header { align-items: flex-start; flex-direction: column; }
  .print-title { text-align: left; }
  .record-signature { grid-template-columns: 1fr; gap: 55px; }
  .danger-zone { align-items: stretch; flex-direction: column; }
}

@media print {
  body { color: #000; background: #fff; font-size: 11px; }
  .sidebar, .topbar, .no-print, .alert, .danger-zone, .sidebar-scrim { display: none !important; }
  .app-shell { margin: 0; }
  .page-content { max-width: none; min-height: 0; padding: 0; }
  .print-record, .panel { padding: 0; border: 0; box-shadow: none; }
  .print-record { display: block; }
  .data-table { min-width: 0; }
  .data-table th, .data-table td { padding: 6px; }
  .detail-grid > div { break-inside: avoid; background: #fff; border: 1px solid #ddd; }
  .progress-notes-table { min-width: 0; font-size: 9px; }
  .psych-tests-table { min-width: 0; font-size: 9px; }
  .immunization-table, .child-growth-table { min-width: 0; font-size: 8px; }
  .progress-notes-table th, .progress-notes-table td { padding: 4px; }
  .psych-tests-table th, .psych-tests-table td { padding: 4px; }
  .progress-notes-table th { width: auto !important; }
  .psych-tests-table th { width: auto !important; }
  .immunization-table th, .child-growth-table th { width: auto !important; }
  .progress-notes-table th:last-child, .progress-notes-table td:last-child, .add-progress-button { display: none; }
  .psych-tests-table th:last-child:nth-child(3), .psych-tests-table td:last-child:nth-child(3), .add-psych-test-button { display: none; }
  .child-growth-table th:last-child, .child-growth-table td:last-child, [data-add-child-growth] { display: none; }
  .button, a { color: #000 !important; }
}
