:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #253530;
  background: #f5f6f4;
  font-synthesis: none;
  line-height: 1.5;
  --muted: #68756f;
  --line: #dce2de;
  --accent: #355f50;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }
.page { max-width: 1040px; margin: 0 auto; padding: 48px 32px 28px; }
.page-header { margin-bottom: 28px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 650; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 8px 0 6px; font-size: clamp(26px, 4vw, 34px); font-weight: 600; letter-spacing: -.035em; line-height: 1.25; }
.subtitle { color: var(--muted); margin: 0; font-size: 15px; }
.records-panel { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 20px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: #edf0ec; }
/* WebKit may include native option text in the page's scrollable width. */
.records-select { flex: 1; min-width: 0; overflow: hidden; padding: 4px; margin: -4px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.count { display: inline-block; margin-left: 5px; color: var(--muted); font-size: 12px; font-weight: 500; }
input, select, textarea { display: block; width: 100%; min-width: 0; border: 1px solid #cbd5ce; border-radius: 7px; background: #fff; color: #253530; font-size: 16px; transition: border-color .15s, box-shadow .15s; }
input, select { min-height: 48px; padding: 11px 12px; }
input[type="date"] { appearance: none; -webkit-appearance: none; height: 48px; }
input::-webkit-date-and-time-value { text-align: left; min-height: 1.5em; }
select { padding-right: 28px; text-overflow: ellipsis; overflow: hidden; }
input::placeholder { color: #87918b; }
textarea { min-height: 112px; padding: 12px 14px; resize: vertical; line-height: 1.6; overflow-y: hidden; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: 2px solid #355f5026; outline-offset: 1px; }
button:focus-visible { outline: 3px solid #759989; outline-offset: 3px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 11px 16px; border: 1px solid transparent; border-radius: 7px; font-size: 14px; font-weight: 600; line-height: 1.45; transition: background .15s; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: #294b3f; }
.button-secondary { background: #fff; border-color: #cbd5ce; color: #355f50; }
.button-secondary:hover { background: #f5f8f5; }
.button-delete { background: transparent; color: #925349; }
.button-delete:hover:not(:disabled) { background: #f4e8e5; }
.button:disabled { opacity: .45; cursor: default; }
.form-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 24px #25353004; overflow: hidden; }
.card-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 30px; border-bottom: 1px solid #e9ede9; }
.form-mode { font-size: 13px; font-weight: 600; }
.save-status { color: var(--muted); font-size: 12px; text-align: right; }
.save-status[data-state="saved"] { color: var(--accent); }
.save-status[data-state="error"] { color: #9c392e; }
.form-section { padding: 28px 30px; }
h2 { display: flex; gap: 10px; align-items: center; font-size: 17px; font-weight: 600; margin: 0 0 24px; }
.section-number { color: #829088; font-size: 11px; font-weight: 500; border: 1px solid #e1e7e2; border-radius: 5px; padding: 3px 6px; }
.patient-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.name-field { grid-column: 1 / -1; }
.birth-date-row { display: flex; align-items: center; gap: 12px; }
.birth-date-row input { flex: 1; }
#patient-age { flex-shrink: 0; color: var(--muted); }
.consultation-section { border-top: 1px solid #e9ede9; padding-top: 26px; }
.consultation-section .field + .field { margin-top: 24px; }
.card-footer { display: flex; gap: 18px; align-items: center; justify-content: space-between; padding: 22px 30px; border-top: 1px solid #e9ede9; background: #fcfdfb; }
.card-footer p { color: var(--muted); font-size: 13px; margin: 0; }
.privacy-note { color: var(--muted); text-align: center; font-size: 12px; margin: 22px 0 0; line-height: 1.7; }
.notice { border: 1px solid #e4b5ac; background: #fff5f2; color: #843b30; padding: 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; }
#print-document { display: none; }
@media (max-width: 700px) {
  .page { padding: 28px 18px 24px; }
  .records-panel { flex-wrap: wrap; padding: 16px; gap: 10px; }
  .records-select { flex-basis: 100%; }
  .records-panel .button { flex: 1; }
  .card-heading, .form-section, .card-footer { padding-left: 20px; padding-right: 20px; }
  .card-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .save-status { text-align: left; }
  .card-footer { flex-direction: column-reverse; align-items: stretch; }
  .card-footer p { text-align: center; }
}
@media (max-width: 420px) {
  .page { padding-left: 12px; padding-right: 12px; }
  .patient-grid { grid-template-columns: 1fr; }
  .records-panel .button { flex-basis: 100%; }
  #new-entry { order: 1; }
  #delete-entry { order: 2; }
  .card-heading, .form-section, .card-footer { padding-left: 16px; padding-right: 16px; }
}
@media print {
  @page { size: A4; margin: 16mm; }
  :root, body { color: #000; background: #fff; }
  .page { max-width: none; margin: 0; padding: 0; }
  .page > :not(#print-document) { display: none !important; }
  #print-document { display: block; font-size: 11pt; line-height: 1.5; }
  #print-document h1 { text-align: center; font-size: 19pt; margin: 0 0 8mm; letter-spacing: 0; }
  .print-patient { padding-bottom: 5mm; border-bottom: 1px solid #aaa; margin-bottom: 6mm; }
  .print-patient p { margin: 0 0 2mm; overflow-wrap: anywhere; }
  .print-section { margin-bottom: 5mm; }
  #print-document h2 { display: block; font-size: 11pt; margin: 0 0 2mm; break-after: avoid; page-break-after: avoid; }
  .print-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; orphans: 3; widows: 3; }
}
