:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-muted: #f7f7f3;
  --ink: #17212b;
  --muted: #65707c;
  --line: #d9ded9;
  --line-strong: #b7c0ba;
  --default-cell: #ffffff;
  --default-weekend: #f3f5f1;
  --outside: #e4e6e2;
  --tax: #117e7c;
  --tax-soft: #d9f0ef;
  --blocked: #bb5d21;
  --blocked-soft: #f9dfca;
  --other: #6755a4;
  --other-soft: #e7e2f6;
  --accent: #245a85;
  --shadow: 0 18px 60px rgba(34, 43, 52, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 260px),
    var(--bg);
  color: var(--ink);
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 36px;
}

.calendar-panel,
.groups-panel {
  width: 100%;
}

.panel-heading h1,
.panel-heading h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2.4vw, 2.2rem);
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.group-card:hover {
  background: #eef3ef;
}

.groups-panel,
.calendar-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.groups-panel {
  margin-top: 14px;
  padding: 16px;
}

.panel-heading {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 14px;
}

.panel-heading.wide {
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px 0;
  margin-bottom: 12px;
}

.panel-heading h2 {
  font-size: 1.18rem;
}

.group-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.group-card {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.group-card.active {
  border-color: #1d6c89;
  background: #edf7f8;
  box-shadow: 0 0 0 2px rgba(29, 108, 137, 0.15);
}

.group-card-header {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.people-count {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef1f3;
  color: #34404c;
  font-size: 0.75rem;
  font-weight: 760;
  line-height: 1.1;
}

.chip.tax-chip {
  background: var(--tax-soft);
  color: #0b5e5c;
}

.calendar-panel {
  min-width: 0;
  overflow: hidden;
}

.impact-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.stat {
  display: grid;
  gap: 2px;
  min-width: 84px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.stat strong {
  font-size: 1.05rem;
  line-height: 1;
}

.stat span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 720;
  line-height: 1.1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 0 18px 14px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 680;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}

.legend-swatch.default {
  background: var(--default-cell);
}

.legend-swatch.tax {
  background: var(--tax-soft);
  border-color: rgba(17, 126, 124, 0.4);
}

.legend-swatch.blocked {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(187, 93, 33, 0.22) 0 6px,
      rgba(255, 255, 255, 0.4) 6px 12px
    ),
    var(--blocked-soft);
  border-color: rgba(187, 93, 33, 0.45);
}

.legend-swatch.other {
  background: var(--other-soft);
  border-color: rgba(103, 85, 164, 0.4);
}

.legend-swatch.outside {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(112, 120, 128, 0.18) 0 6px,
      rgba(255, 255, 255, 0.2) 6px 12px
    ),
    var(--outside);
}

.calendar-scroller {
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfbf8;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 148px repeat(42, 44px);
  min-width: 1996px;
}

.calendar-heading,
.month-heading,
.day-heading,
.day-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.calendar-heading,
.month-heading {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fbfbf8;
}

.calendar-heading {
  top: 0;
  min-height: 54px;
  padding: 11px 12px;
  border-bottom-color: var(--line-strong);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.day-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  min-height: 54px;
  background: #f1f4f0;
  border-bottom-color: var(--line-strong);
  color: #52606c;
  font-size: 0.72rem;
  font-weight: 830;
}

.day-heading.week-start {
  border-left: 2px solid var(--line-strong);
}

.month-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 0 12px;
  border-right-color: var(--line-strong);
}

.month-name {
  font-weight: 800;
}

.month-total {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.day-cell {
  position: relative;
  display: grid;
  grid-template-rows: 15px 1fr;
  align-items: center;
  justify-items: center;
  min-height: 54px;
  padding: 4px 3px 5px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--default-cell);
  color: var(--ink);
  cursor: pointer;
}

.day-cell.weekend {
  background: var(--default-weekend);
}

.day-cell.outside-month {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(112, 120, 128, 0.16) 0 6px,
      rgba(255, 255, 255, 0.18) 6px 12px
    ),
    var(--outside);
  color: #8a9297;
  cursor: default;
}

.day-cell.tax-effective {
  background: var(--tax-soft);
  box-shadow: inset 0 0 0 2px rgba(17, 126, 124, 0.32);
}

.day-cell.tax-blocked {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(187, 93, 33, 0.22) 0 6px,
      rgba(255, 255, 255, 0.4) 6px 12px
    ),
    var(--blocked-soft);
  box-shadow: inset 0 0 0 2px rgba(187, 93, 33, 0.28);
}

.day-cell.other-override {
  background: var(--other-soft);
  box-shadow: inset 0 0 0 2px rgba(103, 85, 164, 0.23);
}

.day-cell:focus-visible {
  outline: 3px solid rgba(36, 90, 133, 0.5);
  outline-offset: -3px;
}

.day-cell.selected {
  outline: 3px solid var(--accent);
  outline-offset: -4px;
}

.date-number {
  justify-self: start;
  padding-left: 2px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 780;
}

.hours {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  min-width: 32px;
  justify-content: center;
  font-size: 1.02rem;
  font-weight: 860;
  line-height: 1;
}

.hours small {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 760;
}

.source-dot {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
}

.tax-effective .source-dot {
  background: var(--tax);
}

.tax-blocked .source-dot {
  background: var(--blocked);
}

.other-override .source-dot {
  background: var(--other);
}

.details-panel {
  min-height: 74px;
  padding: 14px 18px 18px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.details-panel strong {
  color: var(--ink);
}

.details-panel .detail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.details-panel .detail-row + .detail-row {
  margin-top: 7px;
}

@media (max-width: 980px) {
  .group-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1520px);
    padding-top: 14px;
  }

  .panel-heading.wide {
    align-items: stretch;
    flex-direction: column;
  }

  .group-list {
    grid-template-columns: 1fr;
  }

  .impact-stats {
    justify-content: stretch;
  }

  .stat {
    flex: 1 1 110px;
  }
}
