* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #fff4f5 0%, #ffffff 38%, #f8fafc 100%);
  color: #162033;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
.topbar {
  background: #a6192e;
  color: #fff;
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255,255,255,0.14);
  display: grid;
  place-items: center;
  font-weight: 900;
}
h1 {
  margin: 0;
  font-size: clamp(22px, 2.6vw, 34px);
  letter-spacing: -0.035em;
}
.subtitle {
  margin: 4px 0 0;
  color: #ffd5dc;
  font-size: 14px;
  line-height: 1.35;
}
.home-link {
  color: #a6192e;
  background: #fff;
  text-decoration: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 850;
  white-space: nowrap;
}
main {
  width: min(1320px, calc(100% - 28px));
  margin: 16px auto 34px;
  display: grid;
  gap: 14px;
}
.panel {
  background: #fff;
  border: 1px solid #d7e1ef;
  border-radius: 20px;
  box-shadow: 0 16px 42px rgba(20, 40, 70, 0.08);
  padding: 16px;
}
.section-title {
  color: #a6192e;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 10px;
}
.muted { color: #64748b; font-size: 14px; line-height: 1.5; }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.summary-card {
  background: #fbfdff;
  border: 1px solid #d7e1ef;
  border-radius: 16px;
  padding: 12px;
}
.summary-card strong {
  display: block;
  color: #a6192e;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.emr-form {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px;
  overflow: hidden;
}
.teal-bar {
  background: #b7e8e1;
  color: #071321;
  font-weight: 900;
  text-align: center;
  padding: 10px 12px;
  margin: 10px 0;
  border-radius: 2px;
}
.subbar {
  background: #b7e8e1;
  color: #071321;
  font-weight: 850;
  padding: 9px 12px;
  margin: 8px 0;
  width: min(560px, 100%);
}
.callout {
  background: #b7e8e1;
  color: #071321;
  font-weight: 850;
  padding: 10px 12px;
  margin: 8px 0 10px auto;
  width: min(560px, 100%);
}
.mini-head {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, .45fr);
  gap: 10px;
  background: #b7e8e1;
  color: #071321;
  font-weight: 900;
  padding: 10px 12px;
  margin: 10px 0 4px;
}
.calculation-result {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(260px, 1fr);
  gap: 12px;
  align-items: end;
  border: 2px solid #a6192e;
  border-radius: 12px;
  background: #fff7f8;
  padding: 12px;
  margin: 12px 0;
}
.calculation-result label {
  display: block;
  color: #a6192e;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.calculation-result input {
  color: #a6192e;
  font-weight: 900;
  background: #fff;
}
.calculation-result .auto-total {
  font-size: 30px;
  min-height: 50px;
}
.patient-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 12px;
}
.emr-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 6px 0;
}
.emr-row.full-row {
  grid-template-columns: 230px minmax(0, 1fr);
  grid-column: 1 / -1;
}
.emr-row.two-col {
  grid-template-columns: 190px minmax(180px, 1fr) 150px minmax(180px, 1fr);
}
.emr-row label,
.score-row label {
  font-weight: 650;
  line-height: 1.35;
}
input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid #c8cdd5;
  border-radius: 5px;
  background: #fff;
  color: #071321;
  font: inherit;
  padding: 7px 9px;
}
select { background: #f4f4f5; }
textarea { resize: vertical; min-height: 92px; }
.score-grid {
  display: grid;
  gap: 7px;
}
.score-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(150px, .42fr) minmax(160px, .55fr);
  gap: 10px;
  align-items: center;
  padding: 4px 0;
}
.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 18px;
  padding: 8px 0 10px;
}
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.35;
}
.check-row input {
  width: 15px;
  min-height: 15px;
  margin-top: 2px;
}
.pupil-panel {
  display: grid;
  gap: 12px;
}
.pupil-ref {
  background: #f8d3d6;
  border: 1px solid #e6b8be;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: end;
}
.pupil-ref span {
  display: grid;
  gap: 5px;
  justify-items: center;
  min-width: 56px;
  font-weight: 800;
}
.pupil-ref i {
  display: block;
  border-radius: 50%;
  background: #1f2937;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}
button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: #a6192e;
  color: #fff;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}
button.secondary {
  color: #a6192e;
  background: #fff2f4;
  border: 1px solid #e5b7be;
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #10233f;
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.16s ease;
  pointer-events: none;
  font-weight: 800;
}
.toast.show { opacity: 1; transform: translateY(0); }
@media print {
  body { background: #fff; }
  .topbar, .actions, .home-link, .summary-grid { display: none; }
  main { width: 100%; margin: 0; }
  .panel { box-shadow: none; border: 0; padding: 0; }
  .emr-form { border: 0; }
}
@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .summary-grid,
  .patient-grid,
  .check-grid,
  .calculation-result { grid-template-columns: 1fr; }
  .score-row,
  .emr-row,
  .emr-row.full-row,
  .emr-row.two-col,
  .mini-head { grid-template-columns: 1fr; }
}
