:root {
  --ink: #18243a;
  --ink-soft: #516178;
  --ink-faint: #78869a;
  --page: #f4f7fb;
  --surface: #ffffff;
  --surface-muted: #f8faff;
  --line: #dce4ef;
  --line-strong: #c8d5e5;
  --blue: #3867d6;
  --blue-dark: #294fae;
  --blue-soft: #eaf0ff;
  --green: #167456;
  --green-soft: #e7f7f0;
  --red: #bd3d4d;
  --shadow: 0 14px 34px rgba(31, 54, 88, 0.09);
  --shadow-small: 0 5px 14px rgba(31, 54, 88, 0.08);
  --radius: 14px;
  --radius-small: 9px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 0%, rgba(188, 211, 255, 0.6), transparent 31rem),
    linear-gradient(180deg, #f8faff 0, var(--page) 42rem);
  font-family: "DM Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button { border: 0; }
a { color: var(--blue-dark); }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(56, 103, 214, 0.32);
  outline-offset: 2px;
}

.sr-only {
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  position: absolute;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  min-height: 66px;
  border-bottom: 1px solid rgba(200, 213, 229, 0.78);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(12px);
}

.topbar-inner,
.app-shell,
.site-footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar-inner {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 8px;
  background: var(--blue);
  font-size: 0.86rem;
}

.tool-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-muted);
}

.tool-nav a {
  padding: 5px 9px;
  color: var(--ink-soft);
  border-radius: 7px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.tool-nav a:hover { color: var(--ink); background: #fff; }
.tool-nav a.is-active { color: var(--blue-dark); background: var(--blue-soft); }
.privacy-note { color: var(--ink-faint); font-size: 0.73rem; }

.app-shell { padding: 18px 0 28px; }

.order-app {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.64);
  box-shadow: var(--shadow-small);
}

.order-heading,
.results-heading,
.support-strip,
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.order-heading { margin-bottom: 14px; }
.eyebrow { margin: 0 0 3px; color: var(--blue); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
.order-heading h1 { margin: 0; font-size: 1.45rem; line-height: 1.15; letter-spacing: -0.035em; }
.school-year-badge { padding: 5px 9px; color: var(--ink-soft); border-radius: 999px; background: #f1f4f8; font-size: 0.7rem; font-weight: 700; }

.order-layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.control-column { display: grid; gap: 11px; }

.panel,
.results-panel,
.schedule-note {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.panel { padding: 14px; }
.compact-panel { padding-bottom: 15px; }
.panel-heading { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 11px; }
.step-number { width: 23px; height: 23px; flex: 0 0 23px; display: grid; place-items: center; margin-top: 1px; color: var(--blue-dark); border-radius: 50%; background: var(--blue-soft); font-size: 0.75rem; font-weight: 700; }
.panel h2 { margin: 0 0 2px; font-size: 0.94rem; letter-spacing: -0.015em; }
.panel-heading p,
.field-note { margin: 0; color: var(--ink-soft); font-size: 0.76rem; line-height: 1.4; }

textarea,
input,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font-size: 0.82rem;
}

textarea { min-height: 154px; resize: vertical; line-height: 1.45; }
textarea::placeholder,
input::placeholder { color: #9aa6b6; }
.import-roster-button { width: 100%; margin-top: 8px; font-size: 0.74rem; }
select:invalid { color: var(--ink-faint); }
select[aria-invalid="true"] { border-color: #d87884; box-shadow: 0 0 0 3px rgba(189, 61, 77, 0.1); }
.field-label { display: block; margin: 0 0 5px; color: var(--ink-soft); font-size: 0.72rem; font-weight: 700; }
.field-status { min-height: 17px; margin: 7px 0 0; color: var(--ink-faint); font-size: 0.72rem; }
.role-builder { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.role-builder-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px; color: var(--ink-soft); font-size: 0.72rem; font-weight: 700; }
.role-builder-heading small { color: var(--ink-faint); font-size: 0.65rem; font-weight: 600; }
.role-fields { display: grid; gap: 6px; margin-top: 8px; }
.role-field { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 7px; }
.role-number { width: 24px; height: 24px; display: grid; place-items: center; color: var(--blue-dark); border-radius: 7px; background: var(--blue-soft); font-size: 0.68rem; font-weight: 700; }
.role-field input { min-height: 34px; padding: 6px 9px; font-size: 0.76rem; }
.rotation-option { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; padding: 8px 9px; color: var(--ink-soft); border: 1px solid var(--line); border-radius: 8px; background: var(--surface-muted); cursor: pointer; }
.rotation-option input { width: 16px; min-width: 16px; min-height: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--blue); }
.rotation-option strong { display: block; color: var(--ink); font-size: 0.74rem; }
.rotation-option small { display: block; margin-top: 1px; color: var(--ink-faint); font-size: 0.68rem; line-height: 1.35; }
.holiday-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.extra-weeks-label { margin-top: 10px; }
.field-note { margin-top: 4px; }

.holiday-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  margin-top: 11px;
  padding: 9px 10px;
  color: var(--green);
  border: 1px solid #c9eadc;
  border-radius: 9px;
  background: var(--green-soft);
  font-size: 0.69rem;
}
.holiday-summary strong { grid-column: 1 / -1; color: #115a44; font-size: 0.71rem; }

.primary-button,
.secondary-button {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
}
.primary-button { color: #fff; background: var(--blue); box-shadow: 0 6px 12px rgba(56, 103, 214, 0.2); }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { color: var(--ink-soft); border: 1px solid var(--line-strong); background: #fff; }
.secondary-button:hover:not(:disabled) { color: var(--ink); border-color: #9fb2cb; background: #f8faff; }
.secondary-button:disabled { cursor: not-allowed; opacity: 0.5; }
.form-message { min-height: 18px; margin: -3px 2px 0; color: var(--red); font-size: 0.73rem; }

.results-panel { min-height: 704px; padding: 15px; }
.results-heading { align-items: flex-start; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.results-heading h2 { margin: 0 0 3px; font-size: 1.05rem; letter-spacing: -0.02em; }
.results-heading p:not(.eyebrow) { margin: 0; color: var(--ink-soft); font-size: 0.74rem; }
.results-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.output-area { margin-top: 12px; overflow-x: auto; }
.empty-state { min-height: 610px; display: grid; place-content: center; justify-items: center; padding: 30px; color: var(--ink-faint); text-align: center; }
.empty-state > span { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 10px; color: var(--blue-dark); border-radius: 12px; background: var(--blue-soft); font-weight: 700; }
.empty-state strong { color: var(--ink-soft); font-size: 0.88rem; }
.empty-state p { max-width: 320px; margin: 4px 0 0; font-size: 0.76rem; }

.order-table { width: 100%; min-width: 560px; border-collapse: separate; border-spacing: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; font-size: 0.8rem; }
.order-table th { padding: 8px 10px; color: var(--ink-soft); border-bottom: 1px solid var(--line); background: var(--surface-muted); font-size: 0.68rem; letter-spacing: 0.045em; text-align: left; text-transform: uppercase; }
.order-table th:first-child { width: 108px; }
.order-table th:not(:first-child) { min-width: 118px; }
.order-table td { padding: 8px 10px; border-bottom: 1px solid #e8edf4; vertical-align: middle; }
.order-table tbody tr:last-child td { border-bottom: 0; }
.order-table tbody tr:nth-child(even) { background: #fafcff; }
.week-cell { display: flex; align-items: baseline; gap: 6px; }
.week-cell strong { font-size: 0.8rem; }
.week-cell span { color: var(--ink-faint); font-size: 0.65rem; }
.student-cell { font-weight: 600; }

.schedule-note { margin-top: 12px; padding: 10px 12px; }
.schedule-note strong { display: block; margin-bottom: 2px; font-size: 0.74rem; }
.schedule-note p { margin: 0; color: var(--ink-soft); font-size: 0.72rem; }

.support-strip { justify-content: flex-end; min-height: 58px; padding: 7px 2px 0; }
.support-strip p { margin: 0; color: var(--ink-faint); font-size: 0.72rem; }
.vipps-link { color: #7a4b00; font-size: 0.74rem; font-weight: 700; }
.qr-code { width: 82px; height: 82px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }

.site-footer { padding: 0 0 24px; color: var(--ink-faint); font-size: 0.75rem; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--ink-faint); }

.toast-msg {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(390px, calc(100% - 44px));
  padding: 10px 13px;
  color: #fff;
  border-radius: 9px;
  background: #243952;
  box-shadow: 0 10px 22px rgba(28, 48, 73, 0.22);
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast-msg.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .topbar-inner { flex-wrap: wrap; padding: 9px 0; }
  .tool-nav { order: 3; width: 100%; }
  .tool-nav a { flex: 1; text-align: center; }
  .order-layout { grid-template-columns: 292px minmax(0, 1fr); }
  .results-heading { display: grid; }
  .results-actions { justify-content: flex-start; }
}

@media (max-width: 720px) {
  .topbar-inner,
  .app-shell,
  .site-footer { width: min(100% - 24px, 1180px); }
  .privacy-note { display: none; }
  .order-app { padding: 12px; }
  .order-layout { grid-template-columns: 1fr; }
  .results-panel { min-height: 430px; }
  .empty-state { min-height: 330px; }
  .support-strip { align-items: flex-start; flex-direction: column; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; }
  body * { visibility: hidden !important; }
  .results-panel,
  .results-panel * { visibility: visible !important; }
  .results-panel { position: absolute; inset: 0; min-height: 0; padding: 0; border: 0; box-shadow: none; }
  .results-actions { display: none !important; }
  .results-heading { padding-bottom: 8px; }
  .output-area { margin-top: 9px; }
  .order-table { min-width: 0 !important; }
  .order-table th,
  .order-table td { padding: 5px 8px; }
}
