:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #586174;
  --line: #dce1e8;
  --primary: #1558a6;
  --primary-dark: #0f417c;
  --surface: #fff;
  --canvas: #f5f7fa;
  --success: #166534;
  --warning: #8a4b08;
  --danger: #a31b1b;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.htmx-indicator { opacity: 0; visibility: hidden; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; visibility: visible; transition: opacity 200ms ease-in; }

body { margin: 0; background: var(--canvas); color: var(--ink); }
.site-header, main, .site-messages { width: min(100% - 1.25rem, 68rem); margin-inline: auto; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding-block: .85rem; }
.site-header nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .65rem; }
main { box-sizing: border-box; padding: 1rem; background: var(--surface); border-radius: .75rem; box-shadow: 0 2px 12px #17203312; }
a { color: var(--primary); }
label { display: block; font-weight: 650; margin-bottom: .35rem; }
input, select, button { box-sizing: border-box; min-height: 2.75rem; font: inherit; border-radius: .45rem; }
input, select { width: 100%; border: 1px solid #8c96a8; padding: .6rem .7rem; }
button, .button { border: 0; background: var(--primary); color: #fff; padding: .7rem 1rem; text-decoration: none; cursor: pointer; display: inline-block; text-align: center; box-sizing: border-box; border-radius: .45rem; }
button:hover, .button:hover { background: var(--primary-dark); color: #fff; }
button:disabled, input:disabled { cursor: not-allowed; opacity: .68; }
.secondary { background: #586174; }
.inline { display: inline; }
.inline button { width: auto; min-height: auto; padding: .45rem .75rem; }
.actions { display: flex; flex-wrap: wrap; gap: .65rem; margin-block: 1rem; }
.actions > * { flex: 1 1 10rem; }
.field { margin-bottom: 1rem; }
.helptext, small { color: var(--muted); font-size: .9rem; }
.errorlist { color: var(--danger); padding-left: 1.25rem; }
.status { display: inline-block; border-radius: 1rem; padding: .25rem .65rem; background: #fff2c2; font-weight: 650; }
.message { margin-bottom: .65rem; padding: .7rem; background: #e2f4e8; border-radius: .45rem; }
.message--error { background: #fde8e8; color: #7f1d1d; }
.child-list { list-style: none; padding: 0; }
.child-list li { border-top: 1px solid var(--line); padding-block: 1rem; }

.eyebrow { margin: 0 0 .2rem; color: var(--primary); font-size: .78rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.order-heading { display: flex; flex-direction: column; gap: .8rem; margin-bottom: 1rem; }
.order-heading h1 { margin: .15rem 0; font-size: clamp(1.55rem, 5vw, 2.2rem); }
.child-context { margin: 0; color: var(--muted); }
.back-link { display: inline-block; margin-bottom: .8rem; }
.week-chip { align-self: flex-start; display: grid; gap: .15rem; padding: .65rem .8rem; background: #eef5ff; border: 1px solid #b8d2f1; border-radius: .65rem; }
.week-chip span { color: var(--primary-dark); font-size: .82rem; font-weight: 700; }
.child-switcher { display: flex; gap: .45rem; overflow-x: auto; margin: 0 -.25rem 1rem; padding: .25rem; }
.child-switcher a { flex: 0 0 auto; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 2rem; text-decoration: none; }
.child-switcher a[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: #fff; }

.save-status { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .55rem; margin-bottom: 1rem; padding: .72rem .8rem; border-radius: .55rem; font-weight: 700; }
.save-status__icon { flex: 0 0 .7rem; width: .7rem; height: .7rem; margin-top: .32rem; border-radius: 50%; background: currentColor; }
.save-status__text { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.save-status__retry { max-width: calc(100% - 1.25rem); margin-left: 1.25rem; white-space: normal; }
.save-status--saved { color: var(--success); background: #eaf7ee; }
.save-status--saving { color: #1d4ed8; background: #eaf1ff; }
.save-status--unsaved, .save-status--conflict { color: var(--danger); background: #fdecec; }
.save-status--closed { color: var(--muted); background: #eef0f3; }
.autosave-hint { margin: 0 0 .45rem; color: var(--muted); }
.notice { margin-bottom: 1rem; padding: .8rem; background: #eef5ff; border-left: .25rem solid var(--primary); border-radius: .35rem; }
.notice p { margin: .35rem 0 0; }
.notice--closed { background: #fff4dc; border-color: #b56a10; }

.day-section, .weekly-section { margin-block: 1.15rem; border: 1px solid var(--line); border-radius: .7rem; overflow: hidden; }
.day-section > header, .weekly-section > header { padding: .8rem; background: #f7f9fc; border-bottom: 1px solid var(--line); }
.day-section > header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.day-section h2, .history-detail .day-section h3, .weekly-section h2 { margin: 0; font-size: 1.15rem; }
.day-section time { color: var(--muted); font-weight: 650; }
.empty-day { margin: 0; padding: .8rem; color: var(--muted); }
.order-line-form { display: grid; gap: .75rem; padding: .8rem; border-top: 1px solid var(--line); min-width: 0; }
.order-line-form:first-child { border-top: 0; }
.meal-copy, .weekly-item-heading { display: block; min-width: 0; }
.meal-copy strong, .weekly-item-heading strong { display: block; overflow-wrap: anywhere; }
.meal-quantity-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: .65rem; min-width: 0; }
.meal-quantity-block { min-width: 0; }
.meal-quantity-block label { color: var(--muted); font-size: .88rem; }
.quantity-stepper { display: grid; grid-template-columns: 2.75rem minmax(3.5rem, 1fr) 2.75rem; align-items: stretch; gap: .25rem; }
.quantity-stepper input { min-width: 0; padding-inline: .35rem; text-align: center; }
.quantity-stepper__button { min-width: 2.75rem; min-height: 2.75rem; padding: 0; border: 1px solid var(--primary); background: #eef5ff; color: var(--primary-dark); font-size: 1.45rem; font-weight: 800; line-height: 1; }
.quantity-stepper__button:hover { background: #dcecff; color: var(--primary-dark); }
.quantity-stepper__button:focus-visible { outline: .2rem solid #ffbf47; outline-offset: .1rem; }
.quantity-stepper input:focus-visible, .meal-quantity-block label:has(+ .quantity-stepper input:focus-visible) { outline: .2rem solid #ffbf47; outline-offset: .1rem; }
.line-price { margin: 0; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.weekly-section > header p:last-child { margin: .4rem 0 0; color: var(--muted); }
.weekly-extra-form { display: block; }
.weekly-item-heading { margin-bottom: .75rem; }
.weekly-day-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: .65rem; min-width: 0; }
.weekly-day-field { min-width: 0; padding: .7rem; border: 1px solid var(--line); border-radius: .55rem; background: #f7f9fc; }
.weekly-day-field h3 { margin: 0 0 .55rem; font-size: 1rem; }


.order-totals { position: sticky; z-index: 5; bottom: 0; display: flex; flex-direction: column; gap: .65rem; margin: 1rem -1rem -1rem; padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom)); background: #102a4d; color: #fff; box-shadow: 0 -4px 16px #1720332b; }
.order-totals div, .order-totals strong { display: grid; gap: .15rem; }
.order-totals small { color: #dce8f8; }
.order-totals strong { font-size: 1.25rem; }
.order-totals strong span { font-size: .76rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; }
.order-totals strong .order-payment-instructions { font-size: .86rem; line-height: 1.35; text-transform: none; letter-spacing: normal; overflow-wrap: anywhere; }

.order-child-list { list-style: none; margin: 1rem 0; padding: 0; border: 1px solid var(--line); border-radius: .7rem; overflow: hidden; }
.order-child-list li + li { border-top: 1px solid var(--line); }
.child-choice { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; text-decoration: none; }
.child-choice:hover { background: #f4f8fd; }
.child-choice span:first-child { display: grid; gap: .25rem; }
.composition-list { list-style: none; margin: 1rem 0; padding: 0; border: 1px solid var(--line); border-radius: .7rem; overflow: hidden; }
.composition-list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .7rem; padding: .8rem 1rem; }
.composition-list li + li { border-top: 1px solid var(--line); }
.composition-list li > span:first-child { display: grid; gap: .2rem; }
.composition-list small { color: var(--muted); }
.summary-list { display: grid; gap: .4rem; padding: 1rem; background: #eef5ff; border-radius: .7rem; }
.summary-list div { display: flex; justify-content: space-between; gap: 1rem; }
.summary-list dt, .summary-list dd { margin: 0; }
.summary-list div:last-child { font-size: 1.15rem; font-weight: 800; }
.repeat-preview input[type="checkbox"] { width: auto; min-height: auto; margin-right: .4rem; }
.history-detail .split-composition-list > li, .repeat-preview .split-composition-list > li { align-items: flex-start; }
.history-detail .split-composition-list > li > span, .repeat-preview .split-composition-list > li > span { min-width: 0; overflow-wrap: anywhere; }
.meal-split { font-weight: 700; overflow-wrap: anywhere; }
.weekday-splits, .repeat-warning-list { margin: .45rem 0 0; padding-left: 1.2rem; }
.weekday-splits li, .repeat-warning-list li { display: list-item; padding: .15rem 0; overflow-wrap: anywhere; }
.history-provenance { overflow-wrap: anywhere; }

.representative-dashboard { display: grid; min-width: 0; gap: 1.25rem; }
.representative-dashboard section { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: .75rem; }
.representative-dashboard .operations-heading, .representative-dashboard .section-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .65rem 1rem; }
.representative-dashboard .operations-heading h1, .representative-dashboard .section-heading h2 { margin: .15rem 0; }
.representative-dashboard .operations-links { display: flex; flex-wrap: wrap; gap: .55rem; }
.representative-dashboard .metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: .65rem; margin: 1rem 0; }
.representative-dashboard .metric-grid div { padding: .8rem; background: #f3f7fc; border-radius: .6rem; }
.representative-dashboard .metric-grid dt { color: var(--muted); font-size: .88rem; }
.representative-dashboard .metric-grid dd { margin: .2rem 0 0; font-size: 1.6rem; font-weight: 800; }
.representative-dashboard .menu-slot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .65rem; padding: 0; list-style: none; }
.representative-dashboard .menu-slot-grid li { display: grid; align-content: start; gap: .45rem; min-height: 7rem; padding: .85rem; border: 1px solid var(--line); border-radius: .6rem; }
.representative-dashboard .status--muted { background: #eef0f3; color: var(--muted); }
.representative-dashboard .status--success { background: #eaf7ee; color: var(--success); }
.representative-dashboard .status--danger { background: #fdecec; color: var(--danger); }
.representative-dashboard .responsive-table { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: .55rem; }
.representative-dashboard .responsive-table:focus-visible { outline: .2rem solid #ffbf47; outline-offset: .15rem; }
.representative-dashboard table { width: 100%; min-width: 44rem; border-collapse: collapse; }
.representative-dashboard caption { padding: .65rem; color: var(--muted); text-align: left; }
.representative-dashboard th, .representative-dashboard td { padding: .7rem; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.representative-dashboard thead th { background: #f7f9fc; border-top: 0; }
.representative-dashboard code { overflow-wrap: anywhere; }
.representative-dashboard .empty-state { padding: .85rem; color: var(--muted); background: #f7f9fc; border-radius: .55rem; }
.representative-dashboard .empty-state p:first-child { margin-top: 0; }
.representative-dashboard .empty-state p:last-child { margin-bottom: 0; }

@media (min-width: 38rem) {
  main { padding: 2rem; }
  .order-heading { flex-direction: row; align-items: flex-end; justify-content: space-between; }
  .meal-quantity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-totals { flex-direction: row; align-items: end; justify-content: space-between; margin: 1.25rem -2rem -2rem; padding-inline: 2rem; }
  .order-totals strong { text-align: right; }
}
