:root {
  --bg: #f5eed8;
  --bg-2: #efe3c0;
  --ink: #1f2430;
  --muted: #616779;
  --line: #2d3240;
  --card: #fff8e7;
  --cream: #fffef8;
  --teal: #53a39b;
  --teal-dark: #24736c;
  --coral: #f17466;
  --gold: #e4b84f;
  --lavender: #a58dd8;
  --green: #6fa96b;
  --shadow: 5px 5px 0 var(--line);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  padding-bottom: 92px;
  background:
    linear-gradient(180deg, #faf3df 0%, #efe1b9 100%),
    linear-gradient(90deg, rgba(31, 36, 48, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(31, 36, 48, 0.05) 1px, transparent 1px);
  background-size: auto, 28px 28px, 28px 28px;
}

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

button {
  cursor: pointer;
}

.page-shell {
  width: min(1240px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 12px 0 20px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 3px solid var(--line);
  background: linear-gradient(180deg, #fff7e3 0%, #f6e7be 100%);
  box-shadow: var(--shadow);
}

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

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 6px;
  border: 3px solid var(--line);
  background: var(--cream);
  box-shadow: 4px 4px 0 var(--line);
}

.brand-mark span {
  background: linear-gradient(180deg, var(--coral), #f7c25a);
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.1;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.contact {
  display: grid;
  gap: 2px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  background: var(--cream);
}

.address {
  display: grid;
  gap: 2px;
  max-width: 300px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  background: #fff7ef;
}

.contact-label {
  font-size: 12px;
  color: var(--muted);
}

.contact strong {
  font-size: 18px;
}

.address strong {
  font-size: 13px;
  line-height: 1.35;
}

.mode-switch {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 6px;
  padding: 4px;
  border: 2px solid var(--line);
  background: var(--cream);
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 14px;
  border: 2px solid transparent;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.mode-btn svg,
.icon-btn svg,
.install-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-btn.active {
  border-color: var(--line);
  background: linear-gradient(180deg, #c7f0ec 0%, #94d9d2 100%);
  box-shadow: 2px 2px 0 var(--line);
}

.install-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 12px;
  border: 2px solid var(--line);
  background: linear-gradient(180deg, #c7f0ec 0%, #94d9d2 100%);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.install-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 2px 2px 0 var(--line);
}

.layout {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.board,
.side-rail > *,
.stats-band,
.detail-panel,
.art-panel {
  border: 3px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.board {
  padding: 16px;
}

.board-head,
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.board-head h2,
.detail-head h3 {
  font-size: 22px;
}

.calendar-help {
  display: inline-flex;
  align-items: center;
  margin: 8px 0 0;
  padding: 6px 10px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fffdf6;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.3;
}

.month-controls,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.month-controls {
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.icon-btn:hover,
.mode-btn:hover,
.primary-btn:hover,
.ghost-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 2px 2px 0 var(--line);
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.weekday-row {
  margin-top: 14px;
  margin-bottom: 8px;
}

.weekday-row div {
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.day-cell {
  min-height: auto;
  aspect-ratio: 1 / 1;
  padding: 10px 6px 8px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fffdf6;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  overflow: hidden;
  box-shadow: 2px 2px 0 rgba(45, 50, 64, 0.18);
}

.day-cell .day-number {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 50%;
  font-weight: 900;
  line-height: 1;
}

.day-cell.outside {
  opacity: 0.45;
  background: #fffaf0;
}

.day-cell.today .day-number {
  border-color: var(--coral);
  background: #fff0ef;
}

.day-cell.selected {
  background: linear-gradient(180deg, #d9f7f2 0%, #b1ebe4 100%);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--line);
}

.day-cell .count-pill {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #fff;
  line-height: 1.1;
}

.day-cell .tiny-note {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.1;
}

.side-rail {
  display: grid;
  gap: 14px;
}

.art-panel {
  padding: 14px;
}

.art-panel canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  border: 3px solid var(--line);
  background: linear-gradient(180deg, #caf3ff 0%, #fdf0d8 55%, #ffd6b9 100%);
  image-rendering: pixelated;
}

.stats-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.stat {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 2px solid var(--line);
  background: linear-gradient(180deg, #fffdf7 0%, #f7f0db 100%);
}

.stat .label {
  font-size: 12px;
  color: var(--muted);
}

.stat .value {
  font-size: 22px;
  font-weight: 900;
}

.stat .hint {
  font-size: 12px;
}

.stat-wide {
  min-height: 100%;
}

.customer-summary {
  display: grid;
  gap: 10px;
}

.detail-panel {
  padding: 14px;
}

.mini-pill {
  padding: 6px 10px;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.detail-content {
  margin-top: 12px;
  max-height: 480px;
  overflow: auto;
  padding-right: 4px;
}

.slot-list,
.booking-list {
  display: grid;
  gap: 8px;
}

.slot-row,
.booking-row {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 2px solid var(--line);
  background: #fffdf6;
}

.slot-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.slot-row strong,
.booking-row strong {
  font-size: 14px;
}

.slot-meta,
.booking-meta {
  font-size: 12px;
  color: var(--muted);
}

.slot-badge {
  min-width: 74px;
  text-align: center;
  padding: 5px 8px;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.slot-badge.full {
  background: #ffd8d0;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.compact-row {
  gap: 6px;
}

.summary-tools {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  padding: 8px 10px;
  border: 2px solid var(--line);
  background: #fff;
  font-weight: 800;
}

.filter-btn.active {
  background: #c7f0ec;
}

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

.booking-row {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.customer-row {
  grid-template-columns: 1fr;
}

.booking-row.completed {
  background: #eef7ea;
}

.booking-main {
  display: grid;
  gap: 4px;
}

.booking-topline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.status-chip.done {
  background: #dff4da;
}

.check-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
}

.check-wrap input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 18px;
  border: 2px dashed var(--line);
  background: #fffef8;
  text-align: center;
  gap: 8px;
}

.empty-state p {
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(24, 26, 32, 0.55);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-card {
  width: min(640px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
  padding: 16px;
  border: 3px solid var(--line);
  background: var(--card);
  box-shadow: 8px 8px 0 var(--line);
}

.modal-body {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-weight: 800;
}

.field small {
  color: var(--muted);
}

.priority-field {
  padding: 10px;
  border: 3px solid var(--teal-dark);
  background: #e8faf5;
  box-shadow: 3px 3px 0 var(--line);
}

.priority-field span {
  color: var(--teal-dark);
  font-size: 15px;
}

.priority-field small {
  color: var(--teal-dark);
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--line);
  background: #fffef8;
  color: var(--ink);
}

.field textarea {
  resize: vertical;
}

.field.priority-field select {
  border-color: var(--teal-dark);
  background: #fff;
  box-shadow: inset 0 0 0 2px #c7f0ec;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.ghost-btn,
.primary-btn {
  min-height: 42px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  font-weight: 800;
}

.ghost-btn {
  background: #fff;
}

.primary-btn {
  background: linear-gradient(180deg, #f8c95c 0%, #e4b23f 100%);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  padding: 10px 14px;
  border: 3px solid var(--line);
  background: #fff8e7;
  box-shadow: 4px 4px 0 var(--line);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: 12px;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: min(520px, calc(100vw - 16px));
  padding: 6px;
  transform: translateX(-50%);
  border: 3px solid var(--line);
  background: rgba(255, 248, 231, 0.96);
  box-shadow: 4px 4px 0 var(--line);
  backdrop-filter: blur(4px);
}

.dock-btn {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-height: 52px;
  padding: 8px 6px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  font-size: 12px;
}

.dock-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dock-btn.active {
  background: linear-gradient(180deg, #c7f0ec 0%, #94d9d2 100%);
}

.dock.hidden-dock {
  transform: translate(-50%, 68%);
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .detail-content {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .page-shell {
    width: min(100vw - 16px, 100%);
    padding-top: 8px;
  }

  body {
    padding-bottom: 104px;
  }

  .topbar,
  .board,
  .detail-panel,
  .stats-band,
  .art-panel {
    box-shadow: 3px 3px 0 var(--line);
  }

  .topbar {
    align-items: stretch;
  }

  .topbar-meta {
    width: 100%;
    justify-content: stretch;
  }

  .contact,
  .address,
  .mode-switch,
  .install-btn {
    width: 100%;
  }

  .mode-switch {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 22px;
  }

  .contact strong {
    font-size: 16px;
  }

  .address strong {
    font-size: 12px;
  }

  .stats-band {
    grid-template-columns: 1fr;
  }

  .history-stats {
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    gap: 4px;
  }

  .weekday-row {
    gap: 4px;
  }

  .day-cell {
    padding: 4px;
    box-shadow: 1px 1px 0 rgba(45, 50, 64, 0.2);
  }

  .day-cell.selected {
    transform: translate(0, -1px);
    box-shadow: 2px 2px 0 var(--line);
  }

  .day-cell .day-number {
    width: 22px;
    height: 22px;
    font-size: 13px;
  }

  .day-cell .tiny-note {
    display: none;
  }

  .day-cell .count-pill {
    padding: 2px 4px;
    border-width: 1px;
    font-size: 10px;
  }

  .dock {
    width: calc(100vw - 12px);
    bottom: 6px;
  }

  .dock.hidden-dock {
    transform: translate(-50%, 72%);
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions button {
    width: 100%;
  }
}

.modal.owner-mode .modal-card {
  width: min(720px, 100%);
}

.modal.owner-mode .modal-head {
  margin-bottom: 6px;
}

.modal.owner-mode .modal-actions {
  display: none;
}

.owner-day-summary {
  display: grid;
  gap: 10px;
}

.owner-login-card {
  width: min(520px, 100%);
}

.owner-calendar .count-pill {
  background: #eef7ea;
}

.owner-calendar.selected .count-pill {
  background: #dff4da;
}

.owner-row .booking-meta {
  word-break: break-word;
}
