:root {
  --ink: #172033;
  --muted: #667085;
  --line: #dfe5ee;
  --soft: #f5f7fb;
  --paper: #ffffff;
  --navy: #172554;
  --navy-2: #253b80;
  --accent: #f97316;
  --accent-dark: #d95d0b;
  --success: #15803d;
  --danger: #c4322d;
  --radius: 18px;
  --shadow: 0 14px 38px rgba(23, 32, 51, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: #f8fafc; font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled, fieldset:disabled button { cursor: not-allowed; opacity: .55; }
input, select { width: 100%; min-height: 44px; border: 1px solid #cfd7e4; border-radius: 10px; background: var(--paper); color: var(--ink); padding: 9px 11px; outline: none; transition: border .18s, box-shadow .18s; }
input:focus, select:focus { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(37, 59, 128, .12); }
label { display: grid; gap: 7px; color: #344054; font-size: 13px; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 690px; margin-bottom: 12px; font-size: clamp(32px, 5vw, 56px); line-height: 1.04; letter-spacing: -.045em; }
h2 { margin-bottom: 8px; font-size: clamp(26px, 3.2vw, 36px); line-height: 1.13; letter-spacing: -.025em; }
h3 { margin-bottom: 0; font-size: 19px; line-height: 1.25; }
.hidden { display: none !important; }
.skip-link { position: fixed; z-index: 100; left: 12px; top: -80px; padding: 10px 14px; background: var(--ink); color: white; border-radius: 8px; }
.skip-link:focus { top: 12px; }

.app-header { position: sticky; z-index: 50; top: 0; border-bottom: 1px solid rgba(223,229,238,.9); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); }
.header-inner { width: min(1480px, calc(100% - 40px)); min-height: 72px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--navy); color: white; font-weight: 900; box-shadow: inset 0 -4px 0 rgba(0,0,0,.12); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: -.01em; }
.brand small { color: var(--muted); font-size: 11px; }
.header-actions, .toolbar-actions, .result-actions, .form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.save-status { color: var(--success); font-size: 12px; font-weight: 700; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.app-shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto 80px; }
.hero { min-height: 260px; display: flex; align-items: center; justify-content: space-between; gap: 40px; padding: 48px 4px 38px; }
.hero p { max-width: 690px; margin-bottom: 0; color: var(--muted); font-size: 17px; }
.hero-model { min-width: 420px; display: flex; align-items: stretch; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.hero-model div { min-width: 105px; padding: 15px 12px; text-align: center; }
.hero-model span, .hero-model b { display: block; }
.hero-model span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.hero-model b { margin-top: 3px; color: var(--navy); font-size: 27px; }
.hero-model i { align-self: center; color: #aab3c2; font-style: normal; }
.eyebrow { display: block; margin-bottom: 6px; color: var(--accent-dark); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .11em; }

.tabs { position: sticky; z-index: 40; top: 72px; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.96); box-shadow: 0 8px 28px rgba(23,32,51,.06); }
.tab-button { min-height: 48px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 800; }
.tab-button span { width: 24px; height: 24px; display: inline-grid; place-items: center; margin-right: 8px; border: 1px solid #ccd5e3; border-radius: 50%; font-size: 11px; }
.tab-button b { display: inline-grid; min-width: 20px; height: 20px; place-items: center; margin-left: 5px; padding: 0 5px; border-radius: 99px; background: #e6eaf2; font-size: 10px; }
.tab-button.active { background: var(--navy); color: white; }
.tab-button.active span { border-color: rgba(255,255,255,.45); }
.tab-button.active b { background: rgba(255,255,255,.16); }
.tab-panel { display: none; padding-top: 42px; }
.tab-panel.active { display: block; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.section-heading p { margin-bottom: 0; color: var(--muted); }
.count-pill { flex: 0 0 auto; padding: 7px 12px; border: 1px solid #dbe1eb; border-radius: 99px; background: white; color: var(--navy); font-size: 12px; font-weight: 900; }

.button { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 10px; padding: 9px 15px; font-weight: 800; transition: transform .15s, background .15s, border .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button.primary { background: var(--accent); color: #26160c; box-shadow: 0 7px 15px rgba(249,115,22,.2); }
.button.primary:hover { background: #ff852b; }
.button.secondary { background: var(--navy); color: white; }
.button.ghost { border-color: #d7deea; background: white; color: #344054; }
.button.ghost:hover { border-color: #aeb8c8; background: #f8fafc; }
.button.danger-text { background: transparent; color: var(--danger); }
.button.small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.button.large { min-height: 50px; padding-inline: 24px; }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 24px; box-shadow: 0 8px 26px rgba(23,32,51,.04); }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 21px; }
.two-column-layout { display: grid; grid-template-columns: minmax(300px, 390px) 1fr; align-items: start; gap: 24px; }
.alternatives-layout { grid-template-columns: minmax(380px, 450px) 1fr; }
.sticky-card { position: sticky; top: 148px; display: grid; gap: 17px; }
.field-row { display: grid; grid-template-columns: 1fr 105px; gap: 12px; }
.color-field { position: relative; }
.color-field input { padding: 4px; }
.color-field span { position: absolute; right: 7px; bottom: 9px; padding: 2px 5px; border-radius: 5px; background: rgba(255,255,255,.86); color: #344054; font-size: 9px; }
.form-errors { padding: 10px 12px; border: 1px solid #fecaca; border-radius: 9px; background: #fff1f2; color: #9f1239; font-size: 12px; font-weight: 650; }
.form-errors ul { margin: 0; padding-left: 18px; }
.table-card { padding: 0; overflow: hidden; }
.table-card .card-heading { padding: 24px 24px 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-top: 1px solid #e8edf4; text-align: left; vertical-align: middle; }
th { background: #f8fafc; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
td code { padding: 4px 8px; border-radius: 7px; background: #eef2ff; color: var(--navy-2); font-family: inherit; font-weight: 900; }
.actions-column { width: 180px; }
.table-actions { display: flex; gap: 4px; }
.section-footer { display: flex; justify-content: flex-end; margin-top: 25px; }
.section-footer.split { justify-content: space-between; }
.stack { display: grid; gap: 18px; }

.empty-state { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 25px; color: var(--muted); text-align: center; }
.empty-state strong { color: #344054; font-size: 16px; }
.empty-state.compact { min-height: 140px; border: 1px dashed #cbd5e1; border-radius: var(--radius); background: white; }
.empty-state.large { min-height: 320px; border: 1px dashed #cbd5e1; border-radius: var(--radius); background: white; }
.empty-state .button { margin-top: 14px; }
.concept-note, .locked-banner { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; padding: 15px 18px; border: 1px solid #cbd7f7; border-radius: 14px; background: #eef4ff; }
.concept-note p, .locked-banner span { display: block; margin: 2px 0 0; color: #58657c; font-size: 13px; }
.concept-icon { width: 29px; height: 29px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--navy-2); color: white; font-weight: 900; }
.locked-banner { justify-content: space-between; margin: 0 0 20px; border-color: #bbf7d0; background: #f0fdf4; }

.session-builder { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.session-builder legend { padding: 0 6px; color: var(--navy); font-size: 12px; font-weight: 900; }
.session-inputs { display: grid; grid-template-columns: 1.1fr 1fr 1fr auto; align-items: end; gap: 8px; }
.draft-sessions { display: grid; gap: 7px; margin-top: 12px; }
.draft-session { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 9px; background: var(--soft); font-size: 12px; }
.draft-session b { color: var(--navy); }
.draft-session button { width: 26px; height: 26px; border: 0; border-radius: 7px; background: white; color: var(--danger); }
.alternative-group { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.alternative-group-heading { margin-bottom: 15px; }
.alternative-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.alternative-card { position: relative; display: grid; grid-template-columns: 6px 1fr; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.alternative-card-content { padding: 14px; }
.alternative-card-heading { display: flex; justify-content: space-between; gap: 10px; }
.alternative-card-heading strong, .alternative-card-heading span { display: block; }
.alternative-card-heading span { color: var(--muted); font-size: 11px; }
.color-dot { width: 17px; height: 17px; flex: 0 0 auto; border: 2px solid white; border-radius: 50%; box-shadow: 0 0 0 1px #cad3e0; }
.session-summary { display: grid; gap: 4px; margin: 12px 0; padding: 0; list-style: none; color: var(--muted); font-size: 12px; }
.session-summary b { color: #344054; }
.card-actions { display: flex; flex-wrap: wrap; gap: 3px; padding-top: 8px; border-top: 1px solid #edf0f5; }
.schedule-preview-card { margin-top: 24px; }
.helper-text { color: var(--muted); font-size: 11px; }

.availability-matrix { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; outline: none; }
.availability-matrix:focus { box-shadow: 0 0 0 3px rgba(37, 59, 128, .12); }
.availability-table { min-width: 1120px; table-layout: fixed; }
.availability-table th, .availability-table td { border-top: 1px solid var(--line); border-left: 1px solid var(--line); padding: 10px; }
.availability-table thead th { height: 48px; border-top: 0; background: #f7f9fc; text-align: center; }
.availability-table th:first-child, .availability-table td:first-child { width: 250px; border-left: 0; }
.availability-table thead th:first-child { position: sticky; z-index: 4; left: 0; text-align: left; }
.alternative-row-heading { position: sticky; z-index: 3; left: 0; background: white; text-align: left; box-shadow: 5px 0 12px rgba(23,32,51,.04); }
.alternative-row-heading > span:last-child, .alternative-row-heading strong, .alternative-row-heading small { display: block; }
.alternative-row-heading { padding-left: 17px !important; }
.alternative-row-heading .row-color { position: absolute; inset: 9px auto 9px 6px; width: 5px; border-radius: 99px; }
.alternative-row-heading strong { color: var(--navy); font-size: 13px; }
.alternative-row-heading small { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.availability-cell { height: 68px; background: white; vertical-align: middle; }
.availability-cell.empty-cell { color: #c7ced9; text-align: center; }
.availability-sessions { display: grid; gap: 6px; }
.availability-session { min-height: 43px; display: flex; flex-direction: column; justify-content: center; overflow: hidden; padding: 7px 9px; border: 1px solid rgba(0,0,0,.08); border-radius: 8px; box-shadow: 0 3px 8px rgba(23,32,51,.1); line-height: 1.15; }
.availability-session strong, .availability-session span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.availability-session strong { font-size: 12px; }
.availability-session span { margin-top: 3px; font-size: 10px; font-weight: 750; }

.schedule-scroll { width: 100%; overflow-x: auto; padding-bottom: 6px; }
.weekly-schedule { min-width: 860px; display: grid; grid-template-columns: 72px repeat(7, minmax(110px,1fr)); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; background: white; }
.schedule-corner, .schedule-day-heading { height: 50px; display: grid; place-items: center; border-bottom: 1px solid var(--line); background: #f7f9fc; color: #475467; font-size: 11px; font-weight: 900; text-transform: uppercase; }
.schedule-day-heading { border-left: 1px solid var(--line); }
.time-axis { position: relative; background: #f7f9fc; }
.time-label { position: absolute; right: 10px; transform: translateY(-50%); color: #667085; font-size: 10px; font-variant-numeric: tabular-nums; }
.schedule-day-column { position: relative; border-left: 1px solid var(--line); background: repeating-linear-gradient(to bottom, #fff 0, #fff calc(10% - 1px), #edf1f6 10%); }
.schedule-block { position: absolute; z-index: 2; min-height: 25px; overflow: hidden; padding: 7px 8px; border: 1px solid rgba(0,0,0,.08); border-radius: 8px; box-shadow: 0 4px 10px rgba(23,32,51,.12); line-height: 1.16; }
.schedule-block strong, .schedule-block span, .schedule-block small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-block strong { font-size: 13px; }
.schedule-block span { margin-top: 3px; font-size: 10px; font-weight: 750; }
.schedule-block small { margin-top: 4px; font-size: 9px; opacity: .75; }

.summary-grid, .stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 20px; }
.summary-card, .stat-card { padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.summary-card strong, .summary-card span, .stat-card strong, .stat-card span { display: block; }
.summary-card strong, .stat-card strong { color: var(--navy); font-size: 24px; line-height: 1.1; }
.summary-card span, .stat-card span { margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 750; }
.summary-card small { display: block; margin-top: 8px; color: var(--muted); }
.filter-card { margin-bottom: 22px; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.range-controls { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin: 19px 0; padding-top: 16px; border-top: 1px solid var(--line); }
.range-controls > span { align-self: center; margin-right: 4px; color: var(--navy); font-weight: 900; }
.range-controls label { display: flex; align-items: center; gap: 7px; }
.range-controls input { width: 125px; }
.result-empty { border: 1px dashed #f2b8b5; border-radius: var(--radius); background: #fff7f7; }
.result-view { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.result-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 15px; }
.metric-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 15px; }
.metric-pills span { padding: 6px 10px; border-radius: 99px; background: #f0f3f8; color: #475467; font-size: 11px; font-weight: 800; }
.result-actions { justify-content: center; margin-top: 19px; }

.favorite-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.favorite-card { padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.favorite-card.selected { border-color: var(--navy-2); box-shadow: 0 0 0 2px rgba(37,59,128,.12); }
.favorite-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.favorite-card-heading label { display: flex; grid-template-columns: auto 1fr; align-items: center; }
.favorite-card-heading input { width: 18px; min-height: 18px; }
.favorite-card .course-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 13px 0; }
.course-chip { padding: 5px 8px; border-radius: 7px; font-size: 10px; font-weight: 900; }
.comparison-area { margin-top: 24px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: #eef2f8; }
.comparison-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.comparison-item { min-width: 0; padding: 14px; border-radius: 13px; background: white; }
.comparison-item .weekly-schedule { min-width: 720px; transform-origin: top left; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: 360px; padding: 13px 17px; border-radius: 11px; background: var(--ink); color: white; box-shadow: 0 14px 35px rgba(0,0,0,.22); opacity: 0; pointer-events: none; transform: translateY(12px); transition: .22s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #9f1d1d; }

@media (max-width: 1050px) {
  .header-inner { align-items: flex-start; padding: 14px 0; }
  .header-actions { justify-content: flex-end; }
  .save-status { display: none; }
  .tabs { top: 89px; }
  .hero { align-items: flex-start; }
  .hero-model { min-width: 340px; }
  .two-column-layout, .alternatives-layout { grid-template-columns: 1fr; }
  .sticky-card { position: static; }
  .favorite-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .app-header { position: static; }
  .header-inner, .app-shell { width: min(100% - 24px, 1480px); }
  .header-inner { flex-direction: column; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .header-actions .button { flex: 1 1 auto; }
  .hero { min-height: 0; flex-direction: column; padding: 34px 0 28px; }
  .hero-model { width: 100%; min-width: 0; }
  .hero-model div { min-width: 0; flex: 1; padding-inline: 5px; }
  .hero-model span { font-size: 8px; }
  .tabs { top: 0; overflow-x: auto; grid-template-columns: repeat(4, minmax(145px,1fr)); }
  .tab-button { font-size: 12px; }
  .tab-panel { padding-top: 30px; }
  .section-heading { flex-direction: column; gap: 12px; }
  .section-heading .count-pill { align-self: flex-start; }
  .card { padding: 18px; }
  .field-row, .filter-grid, .summary-grid, .stats-grid, .alternative-card-grid, .favorite-grid, .comparison-grid { grid-template-columns: 1fr; }
  .session-inputs { grid-template-columns: 1fr 1fr; }
  .session-inputs label:first-child { grid-column: 1 / -1; }
  .session-inputs .button { align-self: end; }
  .concept-note, .locked-banner { align-items: flex-start; flex-wrap: wrap; }
  .result-toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .button { flex: 1; }
  .section-footer.split { gap: 10px; }
  .availability-table { min-width: 980px; }
  .availability-table th:first-child, .availability-table td:first-child { width: 205px; }
}

@media print {
  body { background: white; }
  .app-header, .hero, .tabs, .locked-banner, .section-heading, .summary-grid, .filter-card, .stats-grid, .result-toolbar .toolbar-actions, .result-actions, #tab-courses, #tab-alternatives, #tab-favorites { display: none !important; }
  .app-shell { width: 100%; margin: 0; }
  #tab-generator, #generation-output, #result-view { display: block !important; padding: 0; border: 0; box-shadow: none; }
  .result-toolbar { display: block; }
  .schedule-scroll { overflow: visible; }
  .weekly-schedule { min-width: 0; }
}
