:root {
  --bg: #f3f7fb;
  --panel: #ffffff;
  --ink: #102133;
  --muted: #64748b;
  --line: #dbe5ef;
  --blue: #1463ff;
  --blue-soft: #e8f0ff;
  --green: #1f9d67;
  --green-soft: #e7f7ee;
  --orange: #c96f16;
  --orange-soft: #fff0df;
  --red: #c23b45;
  --red-soft: #ffe7ea;
  --purple: #7c3aed;
  --purple-soft: #f0e8ff;
  --teal: #088b8b;
  --teal-soft: #e2f7f7;
  --gray-soft: #eef2f7;
  --shadow: 0 18px 45px rgba(21, 44, 72, 0.10);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(20, 99, 255, 0.14), transparent 34rem),
    linear-gradient(180deg, #eef5ff 0%, var(--bg) 24rem);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, select, input { font: inherit; }
button { cursor: pointer; }

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding: 2.5rem clamp(1rem, 4vw, 3rem) 1.25rem;
}

.eyebrow {
  margin: 0 0 .6rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .75rem;
  color: var(--blue);
  font-weight: 800;
}

h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 4rem); line-height: .95; letter-spacing: -.05em; }
h2 { font-size: 1.05rem; letter-spacing: -.02em; }
h3 { font-size: .95rem; }

.hero-copy {
  max-width: 58rem;
  color: #40546d;
  font-size: 1.05rem;
  line-height: 1.5;
  margin: 1rem 0 0;
}

.hero-card {
  min-width: min(100%, 27rem);
  display: flex;
  gap: .9rem;
  align-items: flex-start;
  background: rgba(255, 255, 255, .82);
  border: 1px solid rgba(219, 229, 239, .9);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.hero-card p { margin: .2rem 0 0; color: var(--muted); font-size: .85rem; line-height: 1.4; }

.status-dot {
  width: .72rem;
  height: .72rem;
  border-radius: 99px;
  margin-top: .28rem;
  background: var(--muted);
  flex: 0 0 auto;
}
.status-dot.good { background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.status-dot.warning { background: var(--orange); box-shadow: 0 0 0 5px var(--orange-soft); }
.status-dot.bad { background: var(--red); box-shadow: 0 0 0 5px var(--red-soft); }

main { padding: 0 clamp(1rem, 4vw, 3rem) 2rem; }
.panel {
  min-width: 0;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(21, 44, 72, 0.06);
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
}
.control-group { display: grid; gap: .35rem; }
.control-group.grow { flex: 1; }
.control-group.compact { min-width: 21rem; }
label { color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
select, input {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: .68rem .75rem;
  outline: none;
}
select:focus, input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
select[multiple] { width: 100%; padding: .4rem; }
select[multiple] option { padding: .35rem .45rem; border-radius: 8px; }

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: .62rem .9rem;
  font-weight: 750;
}
button:hover { border-color: #b7c6d8; background: #f8fbff; }

.layout { display: grid; grid-template-columns: 20rem minmax(0, 1fr); gap: 1rem; align-items: start; min-width: 0; }
.filters { position: sticky; top: 1rem; padding: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; overflow-x: hidden; min-width: 0; }
.filter-header p, .section-title-row p { margin: .3rem 0 0; color: var(--muted); font-size: .88rem; line-height: 1.4; }
.filter-block { margin-top: 1.05rem; min-width: 0; }
.filter-label-row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .4rem; }
.muted { color: var(--muted); font-size: .78rem; }
.empty-note { margin: .45rem 0 0; color: var(--orange); font-size: .82rem; }
.mini-actions { display: flex; gap: .45rem; margin-top: .5rem; }
.mini-actions button { padding: .38rem .62rem; font-size: .78rem; }

.category-filters { display: grid; gap: .4rem; margin-top: .55rem; min-width: 0; max-width: 100%; }
.category-check {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: .5rem;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: .42rem .5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  color: #40546d;
  font-size: .84rem;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: none;
}
.category-check input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--blue); }
.category-check span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: normal; }
.category-swatch { width: .65rem; height: .65rem; border-radius: 999px; flex: 0 0 auto; display: inline-block; background: currentColor; border: 1px solid currentColor; }
.category-swatch.school_day { color: var(--green); }
.category-swatch.district_holiday { color: var(--orange); }
.category-swatch.federal_holiday { color: var(--blue); }
.category-swatch.competitor_closed { color: var(--red); }
.category-swatch.foss_no_lessons { color: var(--purple); }
.category-swatch.session_marker { color: var(--teal); }
.category-swatch.quarter_marker { color: #8b5e00; }
.category-swatch.note { color: var(--muted); }

.dashboard-main { display: grid; gap: 1rem; min-width: 0; }
.metrics-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .75rem; }
.metric-card { padding: .9rem; border-radius: 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .92); }
.metric-value { font-size: 1.55rem; font-weight: 900; letter-spacing: -.04em; }
.metric-label { color: var(--muted); font-size: .78rem; margin-top: .2rem; }
.metric-card.warning { background: var(--orange-soft); border-color: #ffd0a0; }
.metric-card.good { background: var(--green-soft); border-color: #bfe7cf; }
.metric-card.empty { background: var(--gray-soft); }

.section-title-row { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: 1rem 1rem .75rem; }
.coverage-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; padding: 0 1rem 1rem; }
.coverage-card { border: 1px solid var(--line); border-radius: 16px; padding: .85rem; background: #fbfdff; }
.coverage-card strong { display: block; font-size: .9rem; }
.coverage-card p { margin: .35rem 0 0; color: var(--muted); font-size: .78rem; line-height: 1.35; }
.status-pill, .pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border-radius: 999px;
  padding: .28rem .55rem;
  font-size: .75rem;
  font-weight: 850;
  border: 1px solid var(--line);
  background: #fff;
  white-space: nowrap;
}
.status-pill.complete { color: var(--green); background: var(--green-soft); border-color: #bfe7cf; }
.status-pill.partial { color: var(--orange); background: var(--orange-soft); border-color: #ffd0a0; }
.status-pill.derived { color: var(--purple); background: var(--purple-soft); border-color: #d8c6ff; }
.status-pill.unknown { color: var(--red); background: var(--red-soft); border-color: #ffc4cb; }
.coverage-details { border-top: 1px solid var(--line); padding: 1rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.coverage-details.hidden { display: none; }
.detail-list { border: 1px solid var(--line); border-radius: 16px; padding: .85rem; background: #fbfdff; min-width: 0; }
.detail-list ul { margin: .6rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: .84rem; line-height: 1.42; }

.advisory-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 1rem; padding: 0 1rem 1rem; }
.advisory-card { border: 1px solid var(--line); border-radius: 16px; padding: .9rem; background: #fbfdff; }
.advisory-card ul { margin: .65rem 0 0; padding-left: 1.1rem; color: #40546d; line-height: 1.45; font-size: .9rem; }
.month-risk { display: grid; gap: .42rem; margin-top: .7rem; }
.risk-row { display: grid; grid-template-columns: 4.8rem 1fr 2.7rem; gap: .55rem; align-items: center; font-size: .85rem; }
.risk-bar { height: .55rem; background: var(--gray-soft); border-radius: 999px; overflow: hidden; }
.risk-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--orange)); border-radius: inherit; }

.legend { display: flex; flex-wrap: wrap; gap: .4rem .5rem; min-width: 0; overflow: hidden; padding: 0 1rem 1rem; }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; min-width: 0; max-width: 100%; color: #40546d; font-size: .78rem; line-height: 1.2; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .28rem .5rem; white-space: normal; }
.legend-item > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.legend .category-swatch, .legend .status-dot { width: .55rem; height: .55rem; margin-top: 0; box-shadow: none; }

.calendar-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; padding: 0 1rem 1rem; }
.month-card { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; background: #fff; min-width: 0; }
.month-header { display: flex; align-items: center; justify-content: space-between; padding: .75rem .85rem; background: #f7faff; border-bottom: 1px solid var(--line); }
.month-header strong { font-size: 1rem; }
.month-header span { color: var(--muted); font-size: .78rem; }
.weekdays, .days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays div { padding: .42rem .2rem; text-align: center; color: var(--muted); font-size: .67rem; font-weight: 850; border-bottom: 1px solid var(--line); }
.day { min-height: 7.5rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: .32rem; background: #fff; position: relative; overflow: hidden; }
.day:nth-child(7n) { border-right: 0; }
.day.outside { background: #f7f9fc; color: #a5b4c5; }
.day-number { font-weight: 850; font-size: .76rem; display: flex; justify-content: space-between; align-items: center; }
.day.today .day-number { color: var(--blue); }
.day.high-impact { background: linear-gradient(180deg, #fff, var(--orange-soft)); }
.day.conflict { box-shadow: inset 0 0 0 2px rgba(194, 59, 69, .45); }
.day-events { display: grid; gap: .16rem; margin-top: .25rem; min-width: 0; }
.event-chip { display: block; width: 100%; max-width: 100%; min-width: 0; border: 0; border-left: 3px solid currentColor; border-radius: 7px; padding: .16rem .24rem; text-align: left; font-size: .7rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--gray-soft); cursor: help; }
.event-chip.school_day { color: var(--green); background: var(--green-soft); }
.event-chip.district_holiday { color: var(--orange); background: var(--orange-soft); }
.event-chip.federal_holiday { color: var(--blue); background: var(--blue-soft); }
.event-chip.competitor_closed { color: var(--red); background: var(--red-soft); }
.event-chip.competitor_closed.confidence-derived { color: var(--purple); background: var(--purple-soft); border-left-style: dashed; }
.event-chip.competitor_closed.confidence-confirmed { border-left-style: solid; }
.event-chip.foss_no_lessons { color: var(--purple); background: var(--purple-soft); }
.event-chip.session_marker { color: var(--teal); background: var(--teal-soft); }
.event-chip.quarter_marker { color: #8b5e00; background: #fff7d6; }
.event-chip.note { color: var(--muted); background: var(--gray-soft); }
.more-chip { display: block; min-width: 0; color: var(--muted); font-size: .72rem; font-weight: 750; padding-left: .25rem; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more-chip:hover, .more-chip:focus { color: var(--blue); text-decoration: underline; }

.event-feed { padding: 0 1rem 1rem; display: grid; gap: .55rem; }
.feed-item { border: 1px solid var(--line); border-radius: 14px; padding: .75rem; background: #fbfdff; display: grid; grid-template-columns: 7rem 1fr auto; gap: .75rem; align-items: start; }
.feed-date { font-weight: 900; color: var(--blue); }
.feed-title { font-weight: 850; }
.feed-meta { color: var(--muted); font-size: .8rem; margin-top: .25rem; line-height: 1.35; }
.feed-note { color: #40546d; font-size: .82rem; margin-top: .35rem; }

.empty-state { border: 1px dashed #b9c8d9; border-radius: 16px; padding: 1rem; background: #fbfdff; color: var(--muted); }
code { background: #edf3fa; border-radius: 6px; padding: .12rem .28rem; }
footer { padding: 0 clamp(1rem, 4vw, 3rem) 2rem; color: var(--muted); font-size: .88rem; }

@media (max-width: 1280px) {
  .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .coverage-cards { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .calendar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .hero, .toolbar { flex-direction: column; align-items: stretch; }
  .control-group.compact { min-width: 0; }
  .layout { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; }
  .calendar-grid, .coverage-details, .advisory-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .metrics-grid, .coverage-cards { grid-template-columns: 1fr; }
  .feed-item { grid-template-columns: 1fr; }
  .day { min-height: 7.5rem; }
}
