:root {
  color-scheme: light;
  --bg: #fff7ec;
  --panel: #ffffff;
  --text: #263238;
  --muted: #6b7280;
  --line: #eadfcb;
  --primary: #0f8b8d;
  --primary-dark: #0a686a;
  --accent: #ffb703;
  --accent-dark: #e96f32;
  --busy: #ef6f6c;
  --free: #ffffff;
  --booked-soft: #ffd166;
  --shadow: 0 18px 50px rgba(21, 31, 44, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, rgba(255, 247, 236, 0.95), rgba(248, 250, 252, 0.98));
  color: var(--text);
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.1;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  background: var(--primary-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.secondary:hover {
  background: #eef2f5;
}

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

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(rgba(23, 32, 42, 0.55), rgba(23, 32, 42, 0.55)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='800' viewBox='0 0 1200 800'%3E%3Crect width='1200' height='800' fill='%232e5d56'/%3E%3Cpath d='M0 530 C210 460 320 600 520 520 C740 430 820 300 1200 360 L1200 800 L0 800 Z' fill='%23d9d2bd'/%3E%3Cpath d='M0 635 C250 565 405 690 650 615 C880 545 950 510 1200 555 L1200 800 L0 800 Z' fill='%23f2f4ef'/%3E%3Ccircle cx='965' cy='155' r='88' fill='%23f4b35c'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

.login-panel {
  width: min(420px, 100%);
  padding: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

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

.eyebrow {
  margin-bottom: 2px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 40px);
}

h2 {
  margin-bottom: 16px;
  font-size: 22px;
}

.stack {
  display: grid;
  gap: 14px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

legend {
  padding: 0 6px;
}

.radio-line,
.check-line {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  background: white;
  color: var(--text);
}

input[type="radio"] {
  width: auto;
  margin: 0;
}

input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.discount-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  gap: 8px;
}

.total-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf2;
}

.total-box span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.total-box strong {
  color: var(--primary-dark);
  font-size: 22px;
}

textarea {
  resize: vertical;
}

.app-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.calendar-head,
.month-controls,
.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 20px;
}

.topbar p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  align-items: start;
}

.calendar-area,
.booking-panel,
.list-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(21, 31, 44, 0.06);
}

.calendar-area,
.booking-panel {
  padding: 14px;
}

.slot-field {
  gap: 10px;
}

.slot-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.slot-button {
  min-height: 48px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fffaf2;
  color: var(--text);
  font-size: clamp(12px, 1.35vw, 14px);
  font-weight: 900;
}

.slot-button:hover {
  background: #fff0c2;
}

.slot-button:disabled,
.slot-button.is-unavailable {
  border-color: #d1d5db;
  background: #e5e7eb;
  color: #8a94a3;
  box-shadow: none;
}

.slot-button:disabled:hover,
.slot-button.is-unavailable:hover {
  background: #e5e7eb;
}

.slot-button.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: 0 8px 18px rgba(15, 139, 141, 0.18);
}

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

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.calendar-legend i {
  width: 18px;
  height: 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.legend-free {
  background: #ffffff;
}

.legend-half {
  background: linear-gradient(to bottom, var(--booked-soft) 0 50%, #ffffff 50% 100%);
}

.legend-busy {
  background: var(--busy);
}

.weekday-grid {
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.day {
  position: relative;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fbfcfd;
  overflow: hidden;
  text-align: left;
  color: var(--text);
}

.day:hover {
  border-color: var(--primary);
}

.day.is-other {
  opacity: 0.42;
}

.day.is-past {
  background: #e5e7eb;
  color: #98a2b3;
  cursor: not-allowed;
  opacity: 0.58;
}

.day.is-past:hover {
  border-color: var(--line);
}

.day.is-past .day-number {
  background: rgba(255, 255, 255, 0.55);
  box-shadow: none;
}

.day.is-selected {
  outline: 3px solid rgba(31, 122, 100, 0.22);
  border-color: var(--primary);
}

.day-number {
  position: relative;
  z-index: 1;
  display: inline-grid;
  min-width: 28px;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 4px rgba(21, 31, 44, 0.12);
  font-weight: 800;
}

.day.is-free {
  background: var(--free);
}

.day.is-morning {
  background: linear-gradient(to bottom, var(--booked-soft) 0 50%, #ffffff 50% 100%);
}

.day.is-afternoon {
  background: linear-gradient(to bottom, #ffffff 0 50%, var(--booked-soft) 50% 100%);
}

.day.is-busy {
  background: var(--busy);
}

.day.is-busy .day-number {
  color: #7f1d1d;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.message,
.error {
  min-height: 20px;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.error {
  color: var(--busy);
}

.message {
  color: var(--primary);
}

.list-section {
  margin-top: 20px;
  padding: 18px;
}

.settings-form,
.price-fields,
.deposit-fields,
.reset-form {
  display: grid;
  gap: 12px;
  align-items: end;
}

.settings-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

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

.deposit-fields {
  grid-template-columns: minmax(180px, 240px);
}

.reset-form {
  grid-template-columns: minmax(220px, 1fr) minmax(150px, auto);
}

.settings-form .message,
.reset-form .message {
  grid-column: 1 / -1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(38, 50, 56, 0.48);
}

.settings-modal {
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-head,
.settings-category {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  grid-template-columns: 1fr auto;
  align-items: start;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.modal-head h2,
.settings-category h3 {
  margin-bottom: 0;
}

.settings-category {
  grid-template-columns: 210px 1fr;
  align-items: start;
  border-bottom: 1px solid var(--line);
}

.settings-category:last-child {
  border-bottom: 0;
}

.settings-category p {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.danger-category {
  background: #fff7f5;
}

.booking-list {
  display: grid;
  gap: 10px;
}

.booking-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.booking-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.booking-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.button-link {
  min-width: 96px;
  min-height: 40px;
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
  overflow: hidden;
  text-decoration: none;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger-button {
  background: #b42318;
}

.danger-button:hover {
  background: #8f1b13;
}

.secondary-link {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.secondary-link:hover {
  background: #fff0c2;
  color: var(--text);
}

.empty {
  color: var(--muted);
  font-weight: 700;
}

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

  .settings-category {
    grid-template-columns: 1fr;
  }

  .settings-form,
  .price-fields,
  .deposit-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .day {
    min-height: 64px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }

  .weekday-grid,
  .calendar-grid {
    gap: 4px;
  }

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

  .day-number {
    min-width: 24px;
    min-height: 24px;
    font-size: 13px;
  }

  .field-row,
  .booking-item {
    grid-template-columns: 1fr;
  }

  .settings-form,
  .price-fields,
  .deposit-fields,
  .reset-form,
  .slot-buttons {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .settings-modal {
    max-height: calc(100vh - 20px);
  }

  .booking-actions {
    justify-content: stretch;
  }
}
