:root {
  color-scheme: light;
  font: 16px/1.45 system-ui, sans-serif;
  color: #1e293b;
  background: white;
  --ink: #001c41;
  --edge: #ccd7e3;
  --muted: #4b6075;
  --focus: #0079a8;
}

* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 56rem; margin: 0 auto; padding: 14px 20px 24px; }
.stack, .pair, .visit-date { display: grid; min-width: 0; }
.stack { gap: 16px; }
.pair { grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 16px; }
.actions, .calendar-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
fieldset { min-width: 0; margin: 0; padding: 12px 20px 20px; border: 1px solid var(--edge); border-radius: 10px; }
legend { max-width: 100%; padding: 0 .35em; color: var(--ink); font-size: 1.08rem; font-weight: 700; }
label, .visit-date { gap: 6px; }
label { display: grid; min-width: 0; align-content: start; color: var(--ink); font-size: .9375rem; font-weight: 600; }
input:not([type=checkbox]):not([type=hidden]), select, textarea, .date-trigger {
  width: 100%; min-width: 0; min-height: 44px; padding: 9px 12px;
  border: 1px solid #8190a3; border-radius: 6px;
  color: #1e293b; background: white; font: 400 1rem/1.4 system-ui,sans-serif;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; }
button {
  justify-self: start; min-height: 42px; padding: 8px 14px; border: 1px solid var(--edge); border-radius: 6px;
  color: var(--ink); background: white; font: 600 .9375rem/1.35 system-ui,sans-serif; cursor: pointer;
}
button:disabled { color: #718091; cursor: default; }
button[type=submit] { padding: 10px 20px; background: #001c41; color: white; border-color: #001c41; }
button[type=submit]:disabled { opacity: .65; }
:is(input, select, textarea, button, a):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.provider-list { gap: 18px; }
fieldset.provider { padding: 2px 0 0; border: 0; border-radius: 0; }
.provider legend { width: 100%; padding: 0 0 5px; font-size: 1rem; }
.service-list { border: 1px solid var(--edge); border-radius: 7px; }
.service + .service { border-top: 1px solid #e1e7ee; }
.check {
  display: grid; grid-template-columns: 20px minmax(0,1fr); align-content: center; align-items: center;
  gap: 11px; min-height: 44px; margin: 0; cursor: pointer; text-align: left;
}
.service .check { padding: 9px 12px; font-weight: 500; }
.check input[type=checkbox] {
  appearance: auto; width: 20px; height: 20px; padding: 0; margin: 0;
  justify-self: start; align-self: center; accent-color: var(--ink); cursor: pointer;
}
.check span { min-width: 0; overflow-wrap: anywhere; }
.service:has(input[data-select-service]:checked) { background: #f2f8fc; }
.service:first-child { border-radius: 6px 6px 0 0; }
.service:last-child { border-radius: 0 0 6px 6px; }
.service:only-child { border-radius: 6px; }
.service-details { padding: 3px 12px 16px 43px; }
.actions:empty { display: none; }

.date-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; }
.date-trigger [data-date-text] { color: var(--muted); }
.date-trigger.has-date [data-date-text] { color: var(--ink); font-variant-numeric: tabular-nums; }
.date-trigger[aria-expanded=true] { border-color: var(--focus); }
.date-trigger[aria-invalid=true] { border-color: #9d2222; }
.date-icon {
  position: relative; display: inline-block; flex: 0 0 18px; height: 16px; margin: 1px 1px 0;
  border: 1.6px solid #365371; border-radius: 3px; background: linear-gradient(#365371,#365371) left 0 top 3px / 100% 1px no-repeat;
}
.date-icon::before, .date-icon::after {
  position: absolute; top: -4px; width: 2px; height: 5px; background: #365371; content: '';
}
.date-icon::before { left: 3px; }
.date-icon::after { right: 3px; }

.calendar {
  width: 100%; max-width: 24rem; min-width: 0; padding: 10px;
  background: white; border: 1px solid #b7c7d7; border-radius: 8px; color: var(--ink);
}
.calendar-navigation { display: grid; grid-template-columns: 36px minmax(0,1.5fr) minmax(0,1fr) 36px; align-items: center; gap: 4px; }
.calendar-navigation select { min-height: 38px; padding: 5px 2px; font-weight: 600; color: var(--ink); }
.calendar-navigation button { width: 36px; min-height: 38px; padding: 0; font-size: 1.5rem; font-weight: 500; }
.calendar-grid { width: 100%; table-layout: fixed; border-spacing: 0; margin: 8px 0; }
.calendar-grid th, .calendar-grid td { padding: 0; text-align: center; }
.calendar-grid th { height: 28px; font-size: .75rem; color: var(--muted); font-weight: 600; }
.calendar-grid button { width: 100%; min-height: 38px; padding: 2px 0; border: 1px solid transparent; font-weight: 500; font-variant-numeric: tabular-nums; }
.calendar-grid button:disabled { color: #798797; }
.calendar-grid [aria-current=date] { border-color: #6b849a; }
.calendar-grid [aria-selected=true] button { background: var(--ink); color: white; }
.calendar-grid button:focus-visible { position: relative; z-index: 1; outline-offset: -2px; }
.calendar-footer { justify-content: flex-end; border-top: 1px solid var(--edge); padding-top: 6px; }
.calendar-footer button { border: 0; min-height: 36px; padding: 4px 7px; color: #075878; }
.calendar-footer [data-clear] { margin-right: auto; }
@media (hover:hover) {
  .check:hover, button[type=button]:not(:disabled):hover { background-color: #e8f3fa; }
  .calendar-grid [aria-selected=true] button:not(:disabled):hover { background-color: #103b5c; }
}

.small { margin: 0; font-size: .875rem; color: var(--muted); }
a { color: #006287; }
.trap, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#error, .date-error { color: #942121; margin: 0; font-size: .9375rem; }
#error:empty, .date-error:empty { display: none; }
#success { padding: 20px; border: 1px solid var(--edge); border-radius: 8px; }
h2 { margin: 0 0 10px; color: var(--ink); }
[hidden] { display: none !important; }

@media (max-width: 680px) {
  main { padding: 10px 8px 20px; }
  .pair { grid-template-columns: minmax(0,1fr); gap: 12px; }
  fieldset { padding: 10px 12px 16px; }
  .service-details { padding-left: 12px; }
}
