.o_school_clinic_page {
  --ink: #111827;
  --muted: #6b7280;
  --line: #d8e2e7;
  --soft: #f6f9fb;
  --panel: #ffffff;
  --brand: #115e59;
  --brand-2: #0f766e;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b42318;
  --green: #15803d;
  --shadow: 0 14px 38px rgba(15, 23, 42, 0.1);
  min-height: calc(100vh - 80px);
  background: #f3f7f8;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.o_school_clinic_page * {
  box-sizing: border-box;
}

.o_school_clinic_page [hidden] {
  display: none !important;
}

.clinic-app {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: calc(100vh - 80px);
}

.clinic-sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #12233a 100%);
  color: #f8fafc;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.clinic-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.clinic-brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2dd4bf, #22c55e);
  display: grid;
  place-items: center;
  color: #052e2b;
  font-weight: 900;
}

.clinic-brand h1,
.clinic-topbar h2,
.modal-head h3 {
  margin: 0;
  letter-spacing: 0;
}

.clinic-brand h1 {
  font-size: 19px;
  line-height: 1.2;
}

.clinic-brand p,
.eyebrow,
.panel-header span,
.side-metrics span,
.case-meta,
.empty-state span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.clinic-brand p,
.side-metrics span {
  color: #aeb9c6;
}

.primary-action,
.secondary-action,
.icon-button,
.nav-action {
  border: 0;
  min-height: 40px;
  border-radius: 8px;
  font-weight: 850;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.primary-action {
  background: var(--brand-2);
  color: #fff;
  padding: 0 18px;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.22);
}

.secondary-action {
  background: #e8f3f2;
  color: var(--brand);
  padding: 0 16px;
}

.clinic-nav {
  display: grid;
  gap: 8px;
}

.nav-action {
  background: rgba(255, 255, 255, 0.08);
  color: #dbeafe;
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-align: left;
  padding: 0 14px;
}

.nav-action.is-active {
  background: #ffffff;
  color: #0f172a;
}

.sidebar-note {
  color: #aeb9c6;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.5;
}

.icon-button {
  width: 40px;
  background: #eef2f7;
  color: #0f172a;
}

.primary-action:hover,
.secondary-action:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-action:disabled,
.secondary-action:disabled,
.icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.side-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.side-metrics div {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px;
}

.side-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 23px;
}

.case-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.case-list-page {
  overflow: auto;
  padding: 0;
  margin-bottom: 12px;
}

.case-item {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
}

.case-item.is-selected {
  background: #ffffff;
  color: #0f172a;
}

.queue-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px auto;
  gap: 10px;
  margin-bottom: 12px;
}

.queue-toolbar select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 44px;
  padding: 0 10px;
  font: inherit;
  font-weight: 800;
}

.case-table {
  width: 100%;
  min-width: 760px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.case-table-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(160px, 1fr) 120px 120px 150px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #eef2f7;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.case-table-row:last-child {
  border-bottom: 0;
}

.case-table-row.is-header {
  min-height: 40px;
  background: #f8fafc;
  color: var(--muted);
  cursor: default;
  font-size: 12px;
  font-weight: 900;
}

.case-table-row.is-selected {
  background: #edf9f6;
  box-shadow: inset 3px 0 0 var(--brand-2);
}

.case-table-row strong,
.case-table-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pager-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.pager-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.case-item strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
}

.case-pill,
.risk-pill,
.stage-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  color: #334155;
  background: #e2e8f0;
}

.risk-routine { background: #e8f3f2; color: var(--brand); }
.risk-watch { background: #fff7ed; color: var(--amber); }
.risk-urgent { background: #fef3c7; color: #92400e; }
.risk-emergency { background: #fee2e2; color: var(--red); }

.clinic-workspace {
  padding: 24px;
  min-width: 0;
}

.clinic-topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.clinic-view {
  display: none;
}

.clinic-view.is-active {
  display: block;
}

.clinic-topbar h2 {
  font-size: 27px;
  line-height: 1.15;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.student-search {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.07);
  padding: 14px;
  margin-bottom: 16px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.search-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  min-height: 44px;
}

.search-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.search-box input,
.modal-card input,
.modal-card textarea,
.modal-card select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
}

.student-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.intake-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.student-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.student-card h3 {
  margin: 0;
  font-size: 16px;
}

.student-card dl,
.medical-list {
  margin: 0;
}

.student-card div,
.medical-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid #eef2f7;
}

.student-card dt,
.medical-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.student-card dd,
.medical-list dd {
  margin: 0;
  text-align: right;
  font-size: 13px;
  font-weight: 750;
}

.profile-edit-action {
  width: 100%;
  margin-top: 12px;
}

.contact-link {
  color: var(--brand);
  text-decoration: none;
}

.contact-link:hover {
  text-decoration: underline;
}

.case-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.case-panel,
.medical-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 360px;
  box-shadow: var(--shadow);
}

.case-panel {
  padding: 20px;
}

.medical-panel {
  padding: 16px;
  align-self: start;
  position: sticky;
  top: 16px;
}

.empty-state {
  min-height: 300px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  gap: 8px;
}

.case-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.case-header h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.stage-track {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.stage-step {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 6px;
  font-size: 12px;
  font-weight: 900;
  color: #64748b;
}

.stage-step.is-done,
.stage-step.is-current {
  background: #ecfdf5;
  border-color: #86efac;
  color: var(--green);
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.case-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}

.case-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  margin-bottom: 6px;
}

.case-field strong,
.case-field p {
  margin: 0;
  font-size: 14px;
}

.clinical-update {
  margin-top: 16px;
  border: 1px solid #c9e8e3;
  border-radius: 8px;
  background: #f3fbf9;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.section-head strong {
  display: block;
  font-size: 15px;
}

.section-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.vitals-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.clinical-notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.vitals-grid label,
.clinical-notes label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.vitals-grid input,
.vitals-grid select,
.clinical-notes textarea {
  width: 100%;
  border: 1px solid #c9e8e3;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
  outline: 0;
  font: inherit;
}

.clinical-notes textarea {
  resize: vertical;
}

.clinical-check {
  grid-template-columns: 18px minmax(0, 1fr) !important;
  align-content: center;
  color: var(--ink) !important;
  font-size: 13px !important;
}

.case-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.timeline {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-entry {
  border-left: 3px solid var(--brand-2);
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
}

.timeline-entry strong {
  display: block;
  font-size: 13px;
}

.timeline-entry span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}

.panel-header strong {
  font-size: 14px;
  text-align: right;
}

.medical-alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.alert-box {
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-weight: 800;
  background: #eef2ff;
  color: #3730a3;
}

.alert-box.is-risk {
  background: #fee2e2;
  color: var(--red);
}

.clinic-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  place-items: center;
  padding: 20px;
  z-index: 9999;
}

.clinic-modal.is-open {
  display: grid;
}

.modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card-wide {
  width: min(980px, 100%);
}

.selected-student-card {
  border: 1px solid #99f6e4;
  border-radius: 8px;
  background: #f0fdfa;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.selected-student-card strong {
  font-size: 15px;
}

.selected-student-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.selected-student-card div {
  background: #fff;
  border: 1px solid #ccfbf1;
  border-radius: 8px;
  padding: 8px;
}

.selected-student-card dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.selected-student-card dd {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.modal-progress {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.modal-progress span {
  min-height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.modal-progress span.is-active {
  background: #ecfdf5;
  border-color: #86efac;
  color: var(--green);
}

.modal-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.step-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.step-title strong {
  font-size: 14px;
}

.step-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-align: right;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.modal-card input,
.modal-card textarea,
.modal-card select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-height: 42px;
  background: #fff;
}

.modal-card textarea {
  resize: vertical;
}

.check-row {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  color: var(--ink) !important;
  font-size: 14px !important;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  min-width: 240px;
  max-width: 360px;
  background: #0f172a;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 10000;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .clinic-app {
    grid-template-columns: 1fr;
  }

  .clinic-sidebar {
    position: static;
  }

  .case-layout {
    grid-template-columns: 1fr;
  }

  .medical-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .clinic-workspace {
    padding: 14px;
  }

  .search-row,
  .queue-toolbar,
  .case-grid,
  .vitals-grid,
  .clinical-notes,
  .stage-track,
  .modal-grid,
  .modal-progress,
  .selected-student-card dl {
    grid-template-columns: 1fr;
  }

  .case-table-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  .case-table-row.is-header {
    display: none;
  }

  .case-header,
  .clinic-topbar,
  .step-title {
    flex-direction: column;
    align-items: stretch;
  }

  .step-title span {
    text-align: left;
  }
}
