:root {
  color-scheme: light;
  --border: #d8dee8;
  --text: #172033;
  --muted: #667085;
  --surface: #ffffff;
  --soft: #f5f7fb;
  --busy: #9ca3af;
  --busy-soft: #f3f4f6;
  --prebook: #eab308;
  --prebook-soft: #fef9c3;
  --booking-soft: #fff7ed;
  --confirmed: #16a34a;
  --process: #d97706;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.guide-header {
  display: none;
  z-index: 10;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px;
}

.guide-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.guide-title h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.guide-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.year-tabs,
.legend,
.action-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.year-tabs {
  margin-top: 0;
}

.year-tabs button,
.action-bar button {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  white-space: nowrap;
}

.year-tabs button.active {
  border-color: #111827;
  background: #111827;
  color: white;
}

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

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

.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.months {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.month {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.month h2 {
  margin: 0;
  padding: 10px 12px;
  font-size: 14px;
  background: #eef2f7;
  border-bottom: 1px solid var(--border);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
}

.weekday,
.day-cell {
  min-height: 42px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px;
}

.weekday {
  min-height: 28px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  background: #fafbfc;
}

.day-cell {
  background: var(--surface);
  text-align: left;
}

.day-cell.selected {
  outline: 2px solid #111827;
  outline-offset: -2px;
}

.day-cell[disabled] {
  color: #98a2b3;
  background: #f2f4f7;
}

.day-number {
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.cell-info {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}

.status-busy {
  background: var(--busy-soft);
  border-left: 4px solid var(--busy);
  color: var(--text);
  font-weight: 600;
}

.status-prebook {
  background: var(--prebook-soft);
  border-left: 4px solid var(--prebook);
  color: var(--text);
  font-weight: 600;
}

.status-confirmed {
  background: var(--booking-soft);
  border-left: 4px solid #f97316;
  color: var(--text);
  font-weight: 600;
}

.status-in_process {
  background: var(--booking-soft);
  border-left: 4px solid #f97316;
  color: var(--text);
  font-weight: 600;
}

.calendar-scroll {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: auto;
  background: var(--surface);
}

.year-table {
  min-width: 2888px;
  width: max-content;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}

.year-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.year-head,
.month-head,
.sub-head,
.day-head,
.calendar-cell {
  border: 1px solid var(--border);
}

.year-head,
.month-head {
  background: #ffedd5;
  color: #111827;
  font-weight: 700;
}

.year-head {
  position: sticky;
  left: 0;
  z-index: 7;
  width: 56px;
  min-width: 56px;
}

.month-head {
  height: 36px;
  text-align: center;
}

.sub-head {
  width: 118px;
  height: 30px;
  background: #fff7ed;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.day-head {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 56px;
  min-width: 56px;
  height: 28px;
  background: #fff7ed;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.calendar-cell {
  width: 118px;
  max-width: 118px;
  height: 42px;
  padding: 5px 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.15;
  background: var(--surface);
  cursor: pointer;
}

.calendar-cell:hover {
  background: #fff7ed;
}

.calendar-cell.invalid {
  background: #f2f4f7;
  cursor: default;
}

.calendar-cell.has-content {
  background: var(--booking-soft);
}

.calendar-cell.status-busy {
  background: var(--busy-soft);
}

.calendar-cell.status-prebook {
  background: var(--prebook-soft);
}

.calendar-cell.selected {
  outline: 2px solid #111827;
  outline-offset: -2px;
}

.note-cell {
  vertical-align: top;
}

.note-demo {
  border: 1px solid rgb(17 24 39 / 12%);
}

.note-cell-content {
  min-height: 30px;
  overflow: hidden;
  word-break: break-word;
}

.note-cell.editing {
  height: 64px;
  padding: 4px;
  background: #fff7ed;
}

.note-cell.editing.saving {
  opacity: 0.82;
}

.note-editor-inline {
  display: grid;
  gap: 4px;
}

.note-color-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.note-color-swatch,
.note-color-clear {
  min-height: 24px;
  border: 1px solid rgb(17 24 39 / 12%);
  border-radius: 999px;
  padding: 0;
}

.note-color-clear {
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.note-color-clear.active,
.note-color-swatch.active {
  box-shadow: inset 0 0 0 2px #111827;
}

.note-input {
  width: 100%;
  min-height: 34px;
  border: 1px solid #111827;
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
  background: white;
}

.note-input:focus {
  outline: 2px solid rgb(17 24 39 / 16%);
  outline-offset: 1px;
}

.note-saving-text {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.note-cell.note-color-green,
.note-demo.note-color-green {
  background: #dcfce7;
}

.note-cell.note-color-red,
.note-demo.note-color-red {
  background: #fee2e2;
}

.note-cell.note-color-yellow,
.note-demo.note-color-yellow {
  background: #fef3c7;
}

.note-cell.note-color-purple,
.note-demo.note-color-purple {
  background: #ede9fe;
}

.note-cell.note-color-blue,
.note-demo.note-color-blue {
  background: #dbeafe;
}

.note-cell.note-color-orange,
.note-demo.note-color-orange {
  background: #ffedd5;
}

.note-color-swatch.note-color-green {
  background: #22c55e;
}

.note-color-swatch.note-color-red {
  background: #ef4444;
}

.note-color-swatch.note-color-yellow {
  background: #facc15;
}

.note-color-swatch.note-color-purple {
  background: #8b5cf6;
}

.note-color-swatch.note-color-blue {
  background: #3b82f6;
}

.note-color-swatch.note-color-orange {
  background: #f97316;
}

.selected-date {
  display: block;
  color: #111827;
  font-size: 10px;
  font-weight: 700;
}

.action-bar {
  z-index: 20;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.footer-guide {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-width: 150px;
  max-width: 220px;
  gap: 2px;
}

.footer-guide strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.footer-guide span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}

.footer-years,
.footer-legend {
  flex: 0 0 auto;
}

.status-panel {
  position: fixed;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 180px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgb(17 24 39 / 18%);
}

.panel-handle {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  cursor: move;
  touch-action: none;
  user-select: none;
  font-size: 11px;
  font-weight: 700;
}

.anchored-panel {
  grid-template-columns: 1fr;
}

.status-panel button {
  min-height: 32px;
  border: 0;
  border-radius: 7px;
  color: white;
  cursor: pointer;
  touch-action: manipulation;
  font-size: 12px;
  font-weight: 700;
}

.clear-selection {
  min-height: 24px !important;
  background: #e5e7eb;
  color: #374151 !important;
  padding: 0 8px;
  font-size: 11px !important;
}

.busy-action {
  background: var(--busy);
  color: #111827 !important;
}

.prebook-action {
  background: var(--prebook);
  color: #111827 !important;
}

.primary-action {
  background: #111827;
}

.delete-action {
  grid-column: 1 / -1;
  background: #ef4444;
}

.action-bar input {
  min-width: 120px;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
}

.action-bar button.primary {
  background: #111827;
  color: white;
}

.action-bar button.danger {
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 72px;
  left: 12px;
  z-index: 30;
  padding: 10px 12px;
  border-radius: 8px;
  background: #111827;
  color: white;
  font-size: 13px;
}

.toast-success {
  background: #16a34a;
}

.toast-error {
  background: #dc2626;
}

.toast-warning {
  background: #eab308;
  color: #111827;
}

.saving-overlay {
  position: fixed;
  right: 12px;
  bottom: 72px;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #111827;
  color: white;
  font-size: 13px;
  box-shadow: 0 12px 30px rgb(17 24 39 / 18%);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgb(255 255 255 / 35%);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.state-panel {
  margin: 18px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

@media (min-width: 900px) {
  .months {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .calendar-scroll {
    padding-bottom: 70px;
  }

  .action-bar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    align-items: flex-start;
    gap: 6px;
    padding: 7px;
    box-shadow: 0 -8px 22px rgb(17 24 39 / 10%);
  }

  .footer-guide {
    min-width: 128px;
    max-width: 150px;
  }

  .year-tabs button {
    min-height: 30px;
    padding: 0 10px;
  }

  .footer-legend {
    display: none;
  }

  .status-panel {
    width: auto;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .panel-handle {
    font-size: 13px;
  }

  .status-panel button {
    min-height: 44px;
    font-size: 14px;
  }

  .clear-selection {
    min-height: 34px !important;
    font-size: 13px !important;
  }

  .delete-action {
    grid-column: auto;
  }

  .note-cell.editing {
    height: 72px;
    padding: 5px;
  }

  .note-input {
    min-height: 40px;
    font-size: 13px;
  }

  .note-color-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .note-color-swatch,
  .note-color-clear {
    min-height: 30px;
  }
}
