:root {
  --ink: #17201c;
  --muted: #657169;
  --line: #d9dfdb;
  --paper: #f7f5ef;
  --surface: #ffffff;
  --sea: #1e7782;
  --pine: #2f5d50;
  --terracotta: #bd6243;
  --gold: #d8a44a;
  --plum: #7a5268;
  --danger: #c83e3e;
  --shadow: 0 18px 48px rgba(18, 32, 27, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.hero {
  width: min(1540px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 22px;
}

.hero-content {
  color: var(--ink);
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: currentColor;
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1;
  letter-spacing: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 410px);
  gap: 24px;
  width: min(1540px, calc(100% - 36px));
  margin: 24px auto;
  align-items: start;
}

.planning-panel,
.panel-block {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.planning-panel {
  min-width: 0;
  padding: 22px;
}

.toolbar,
.panel-heading,
.events-inner > div:first-child {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

h2 {
  margin: 0;
  font-size: 1.24rem;
  line-height: 1.15;
}

.section-kicker {
  color: var(--sea);
}

.month-controls {
  display: grid;
  grid-template-columns: 42px minmax(190px, auto) 42px;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: #f5f7f5;
  color: var(--ink);
  border-radius: 8px;
  font-size: 1.5rem;
  line-height: 1;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.legend i,
.event-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.unit-whole { background: var(--pine); }
.unit-large { background: var(--sea); }
.unit-small { background: var(--terracotta); }
.unit-conflict { background: var(--danger); }

.calendar-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.month-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfcfb;
}

.month-title {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  text-transform: capitalize;
}

.weekdays,
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays span {
  padding: 9px 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-align: center;
}

.month-weeks {
  display: grid;
}

.week-row {
  position: relative;
  min-height: 136px;
  border-top: 1px solid #e9eeea;
}

.day {
  position: relative;
  min-height: 136px;
  padding: 8px;
  border-left: 1px solid #e9eeea;
  background: #fff;
  min-width: 0;
}

.day:nth-child(7n + 1) {
  border-left: 0;
}

.day.is-outside {
  color: #b6bdb8;
  background: #f7f8f6;
}

.day-number {
  display: block;
  font-weight: 760;
  font-size: 0.86rem;
}

.week-bars {
  position: absolute;
  inset: 30px 0 10px;
  pointer-events: none;
}

.reservation-bar {
  position: absolute;
  top: calc(var(--lane) * 24px);
  height: 20px;
  display: flex;
  align-items: center;
  min-width: 18px;
  border-radius: 999px;
  color: #fff;
  padding: 0 8px;
  box-shadow: 0 5px 12px rgba(23, 32, 28, 0.14);
  overflow: hidden;
}

.reservation-bar span {
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 820;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.reservation-bar.continues-before {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.reservation-bar.continues-after {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.reservation-bar.unit-whole,
.event-dot.unit-whole { background: var(--pine); }
.reservation-bar.unit-large,
.event-dot.unit-large { background: var(--sea); }
.reservation-bar.unit-small,
.event-dot.unit-small { background: var(--terracotta); }
.reservation-bar.unit-conflict,
.event-dot.unit-conflict { background: var(--danger); }

.reservation-bar.is-blocked {
  outline: 2px solid rgba(23, 32, 28, 0.28);
  outline-offset: -2px;
  background-image: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.28) 0,
    rgba(255, 255, 255, 0.28) 5px,
    transparent 5px,
    transparent 10px
  );
}

.side-panel {
  display: grid;
  gap: 18px;
}

.panel-block {
  border-radius: 8px;
  padding: 18px;
}

.stacked-form {
  display: grid;
  gap: 13px;
  margin-top: 16px;
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
  min-width: 0;
}

.platform-field {
  display: grid;
  gap: 9px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.platform-field legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 650;
}

.checkbox-label input {
  width: 16px;
  min-height: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--pine);
}

.option-toggle {
  width: fit-content;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--sea);
  box-shadow: 0 0 0 3px rgba(30, 119, 130, 0.16);
}

textarea {
  min-height: 92px;
  line-height: 1.4;
  resize: vertical;
}

.date-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-width: 0;
}

.primary-button,
.ghost-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid transparent;
  background: var(--pine);
  color: #fff;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.sync-status {
  margin: 0;
  border-radius: 7px;
  padding: 9px 10px;
  background: #f5f7f5;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.sync-status[data-status="ready"] {
  background: rgba(47, 93, 80, 0.1);
  color: var(--pine);
}

.sync-status[data-status="warning"] {
  background: rgba(216, 164, 74, 0.16);
  color: #7a571b;
}

.sync-status[data-status="error"] {
  background: rgba(200, 62, 62, 0.12);
  color: var(--danger);
}

.events-band {
  border-top: 1px solid var(--line);
  background: #fff;
}

.events-inner {
  width: min(1540px, calc(100% - 36px));
  margin: 0 auto;
  padding: 26px 0 34px;
}

.event-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.event-item {
  position: relative;
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fbfcfb;
  overflow: hidden;
}

.event-item header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-weight: 800;
}

.event-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.9rem;
}

.reservation-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.unit-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: #fff;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.unit-badge i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
}

.unit-badge.unit-whole i { color: var(--pine); }
.unit-badge.unit-large i { color: var(--sea); }
.unit-badge.unit-small i { color: var(--terracotta); }
.unit-badge.unit-conflict i { color: var(--danger); }

.type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(23, 32, 28, 0.18);
  border-radius: 999px;
  padding: 4px 9px;
  background: #f0f2ef;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
}

.platform-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.platform-tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
}

.event-item .reservation-comment {
  margin-top: 10px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.text-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 760;
}

.text-button.danger {
  border-color: rgba(200, 62, 62, 0.34);
  color: var(--danger);
}

.delete-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(200, 62, 62, 0.22);
  backdrop-filter: blur(1px);
  z-index: 2;
}

.confirm-delete-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  padding: 0 16px;
  font-weight: 850;
  box-shadow: 0 12px 28px rgba(92, 20, 20, 0.26);
}

.confirm-delete-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #fbfcfb;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .event-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .hero {
    width: min(100% - 20px, 1540px);
    padding: 16px 0 14px;
  }

  .hero h1 {
    font-size: 1.9rem;
  }

  .legend {
    gap: 7px;
    margin: 12px 0;
    font-size: 0.78rem;
  }

  .calendar-grid,
  .side-panel,
  .event-list {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .panel-heading,
  .events-inner > div:first-child {
    display: grid;
  }

  .month-controls {
    grid-template-columns: 42px 1fr 42px;
  }

  .app-shell {
    width: calc(100% - 16px);
    gap: 14px;
    margin: 12px auto;
  }

  .date-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-actions {
    grid-template-columns: 1fr;
  }

  input[type="date"] {
    display: block;
    inline-size: 100%;
    min-inline-size: 0;
    appearance: none;
  }

  .planning-panel {
    padding: 10px;
  }

  .toolbar {
    gap: 10px;
  }

  .month-title {
    padding: 10px 8px 9px;
  }

  .month-card {
    overflow: hidden;
  }

  .weekdays,
  .days {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    min-width: 0;
  }

  .weekdays span {
    padding: 7px 2px;
    font-size: 0.66rem;
  }

  .week-row {
    min-width: 0;
    min-height: 94px;
  }

  .day {
    min-height: 94px;
    padding: 5px 3px;
  }

  .day-number {
    font-size: 0.74rem;
  }

  .week-bars {
    inset: 24px 0 7px;
    min-width: 0;
  }

  .reservation-bar {
    top: calc(var(--lane) * 17px);
    height: 15px;
    min-width: 10px;
    padding: 0 4px;
    box-shadow: none;
  }

  .reservation-bar span {
    font-size: 0.58rem;
    font-weight: 780;
  }
}
