:root {
  color-scheme: light;
  --ink: #1c2327;
  --muted: #68737a;
  --line: #d9e0df;
  --panel: #ffffff;
  --paper: #f6f5ef;
  --green: #2f6f57;
  --green-soft: #dfeee6;
  --blue: #2f5d7c;
  --blue-soft: #e4eef4;
  --gold: #9a6a21;
  --gold-soft: #f4ead7;
  --red: #9d3b35;
  --red-soft: #f1dfdc;
  --shadow: 0 18px 50px rgba(28, 35, 39, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(18px, 4vw, 54px);
  background: rgba(246, 245, 239, 0.92);
  border-bottom: 1px solid rgba(217, 224, 223, 0.8);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 800;
  font-size: 24px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}

.nav form {
  margin: 0;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-primary {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.button.needs-save {
  box-shadow: 0 0 0 3px rgba(154, 106, 33, 0.22);
}

.full {
  width: 100%;
}

main {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: clamp(24px, 5vw, 72px);
  align-items: end;
  min-height: 430px;
  padding: clamp(44px, 8vw, 96px) 0 34px;
}

.hero-copy h1,
.page-title h1,
.login-card h1 {
  margin: 0;
  font-size: clamp(48px, 10vw, 112px);
  line-height: 0.9;
  letter-spacing: 0;
}

.lede {
  max-width: 680px;
  color: #344047;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-actions,
.controls,
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-panel,
.login-card,
.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
}

.status-panel {
  padding: 22px;
}

.status-panel p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--green);
}

.status-dot.muted {
  background: var(--gold);
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 28px;
}

.quick-card {
  min-height: 112px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.quick-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.quick-card strong {
  display: block;
  margin-top: 12px;
  font-size: 20px;
}

.workspace,
.public-band {
  margin-bottom: 56px;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.section-heading,
.page-title,
.public-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-heading h2,
.public-band h2,
.agenda h3 {
  margin: 0;
}

.workspace[data-calendar-app] > .section-heading {
  position: sticky;
  top: 74px;
  z-index: 5;
  margin: -10px 0 0;
  padding: 10px 0 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.year-controls {
  align-items: center;
}

.year-input {
  width: 98px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 26px;
  line-height: 1;
}

select {
  min-height: 40px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}

.legend {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend .owner-dot {
  box-shadow: none;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0;
}

.summary-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}

.month-stack {
  display: grid;
  gap: 26px;
  margin-top: 22px;
}

.calendar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.calendar-year-marker {
  color: var(--ink);
  font-size: clamp(36px, 8vw, 72px);
  font-weight: 900;
  line-height: 0.95;
}

.month-view {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  scroll-margin-top: 96px;
}

.workspace[data-calendar-app] .month-view {
  scroll-margin-top: 178px;
}

.month-header,
.week-grid,
.day-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.month-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfbf8;
}

.month-header h3 {
  grid-column: 1 / -1;
  margin: 0 0 14px;
  font-size: 22px;
}

.week-grid {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.day-grid {
  min-height: 520px;
}

.day {
  min-height: 92px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.day:nth-child(7n) {
  border-right: 0;
}

.day.empty {
  background: #f7f7f3;
}

.day.adjacent-month {
  background: #f4f4ef;
}

.day-number {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.day-label {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.week-owner {
  display: inline-flex;
  max-width: 100%;
  margin-top: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #1c2327;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.owner-johnny {
  background: #4f81bd;
  color: #fff;
}

.owner-michael {
  background: #c0504d;
  color: #fff;
}

.owner-allan {
  background: #9bbb59;
  color: #111;
}

.owner-rental {
  background: #8064a2;
  color: #fff;
}

.day.occupied,
.day.rental {
  background: var(--red-soft);
}

.day.work {
  background: var(--gold-soft);
}

.day.private {
  background: var(--gold-soft);
}

.day.holiday {
  background: var(--blue-soft);
}

.day.owner-johnny {
  background: #4f81bd;
}

.day.owner-michael {
  background: #c0504d;
}

.day.owner-allan {
  background: #9bbb59;
}

.day.owner-rental {
  background: #8064a2;
}

.day.adjacent-month.owner-johnny {
  background: #dbe6f4;
}

.day.adjacent-month.owner-michael {
  background: #f0d6d4;
}

.day.adjacent-month.owner-allan {
  background: #e6efd3;
}

.day.adjacent-month.owner-rental {
  background: #e4ddec;
}

.day.owner-johnny .day-number,
.day.owner-michael .day-number,
.day.owner-rental .day-number,
.day.owner-johnny .day-label,
.day.owner-michael .day-label,
.day.owner-rental .day-label {
  color: #fff;
}

.day.owner-allan .day-number,
.day.owner-allan .day-label {
  color: #17210d;
}

.day.adjacent-month .day-number,
.day.adjacent-month .day-label {
  color: #7a8388;
}

.day.adjacent-month .week-owner {
  background: rgba(255, 255, 255, 0.52);
  color: #6e777d;
}

.day.today {
  outline: 3px solid var(--green);
  outline-offset: -3px;
}

.available {
  background: var(--green-soft);
}

.occupied {
  background: var(--red);
}

.work {
  background: var(--gold);
}

.private {
  background: var(--gold);
}

.holiday {
  background: var(--blue);
}

.owner-dot.owner-johnny {
  background: #4f81bd;
}

.owner-dot.owner-michael {
  background: #c0504d;
}

.owner-dot.owner-allan {
  background: #9bbb59;
}

.owner-dot.owner-rental {
  background: #8064a2;
}

.agenda {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.agenda-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.agenda-item {
  padding: 12px;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #f8f8f5;
}

.agenda-item.occupied,
.agenda-item.rental {
  border-left-color: var(--red);
}

.agenda-item.work {
  border-left-color: var(--gold);
}

.agenda-item.holiday {
  border-left-color: var(--blue);
}

.agenda-item time {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.agenda-item strong {
  display: block;
  margin-top: 4px;
}

.agenda-owner {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.page-title {
  padding: 46px 0 26px;
}

.page-title h1 {
  font-size: clamp(42px, 7vw, 76px);
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 78px);
  place-items: center;
}

.login-card {
  width: min(460px, 100%);
  padding: 28px;
}

.login-card h1 {
  font-size: clamp(34px, 7vw, 52px);
}

.login-card p {
  color: var(--muted);
  line-height: 1.5;
}

.login-card .button + .button {
  margin-top: 10px;
}

.notice {
  padding: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.admin-workspace {
  display: grid;
  gap: 22px;
}

.admin-status.error {
  color: var(--red);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
}

.admin-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-panel h3,
.admin-panel p {
  margin: 0;
}

.admin-panel p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.section-heading.compact {
  align-items: flex-start;
}

.field-grid,
.override-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.rule-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

.override-row {
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto;
}

.rule-row label,
.week-cell {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.rule-row input,
.rule-row select,
.week-cell select {
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.rule-row .wide-field {
  grid-column: span 2;
}

.week-panel {
  overflow: hidden;
}

.week-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.week-cell {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
}

@media (max-width: 880px) {
  .hero,
  .calendar-layout,
  .quick-grid,
  .summary-strip,
  .admin-grid,
  .rule-row,
  .override-row {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .page-title,
  .public-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .day-grid {
    min-height: 0;
  }

  .day {
    min-height: 78px;
    padding: 8px;
  }

  .day-label {
    font-size: 12px;
  }
}
