:root {
  --bg: #ffffff;
  --bg-panel: #f0f0f0;
  --border: #b8b8b8;
  --border-strong: #888888;
  --text: #111111;
  --text-muted: #555555;
  --accent: #111111;
  --available-bg: #d4f0d8;
  --available-border: #7ec08a;
  --available-hover-bg: #b8e6c0;
  --available-hover-border: #5aab6a;
  --taken: #e4e4e4;
  --off: #e8e8e8;
  --selected: #111111;
  --selected-text: #ffffff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 2px 24px rgba(0, 0, 0, 0.08);
  --page-pad: clamp(36px, 9vw, 112px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.shell {
  height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    clamp(14px, 2vh, 22px)
    var(--page-pad)
    calc(clamp(14px, 2vh, 22px) + env(safe-area-inset-bottom, 0px));
  padding-left: calc(var(--page-pad) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--page-pad) + env(safe-area-inset-right, 0px));
  gap: clamp(10px, 1.5vh, 16px);
}

#bookingView {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

.header {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: clamp(20px, 3.5vh, 36px);
}

.logo {
  width: auto;
  max-width: 100%;
  display: block;
}

.logo--hero {
  height: clamp(44px, 7vh, 64px);
}

.footer-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: clamp(6px, 1vh, 10px);
}

.logo--footer {
  height: clamp(24px, 3vh, 30px);
  width: auto;
  opacity: 0.85;
  display: block;
  margin-inline: auto;
}

.content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-inline: clamp(8px, 1.5vw, 20px);
}

.main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 420px);
  gap: clamp(16px, 2.5vw, 28px);
  align-items: stretch;
}

.calendar-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--bg-panel);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(16px, 2vh, 24px);
  box-shadow: var(--shadow);
}

.form-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(18px, 2.2vh, 26px) clamp(20px, 2.5vw, 28px);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(10px, 1.5vh, 14px);
  flex-shrink: 0;
}

.month-label {
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.nav-btn {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s;
}

.nav-btn:hover:not(:disabled) {
  background: var(--off);
  border-color: var(--text);
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(5px, 0.7vw, 8px);
  margin-bottom: clamp(6px, 0.8vh, 10px);
  flex-shrink: 0;
  padding-bottom: 6px;
  border-bottom: 1.5px solid var(--border);
}

.weekdays span {
  text-align: center;
  font-size: clamp(10px, 1.1vw, 11px);
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.weekdays span:first-child,
.weekdays span:nth-child(2),
.weekdays span:last-child {
  color: #999;
}

.day-name-short {
  display: none;
}

.days {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(44px, 1fr);
  gap: clamp(5px, 0.7vw, 8px);
  min-height: 0;
}

.day {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  font-size: clamp(13px, 1.5vw, 15px);
  font-weight: 500;
  font-family: inherit;
  cursor: default;
  min-height: 44px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: transform 0.12s, background 0.15s, color 0.15s, border-color 0.15s;
}

.day--empty {
  visibility: hidden;
  pointer-events: none;
  border-color: transparent;
  background: transparent;
}

.day--off {
  background: var(--off);
  border-color: #ccc;
  color: #aaa;
  cursor: not-allowed;
}

.day--past {
  background: var(--off);
  border-color: #ccc;
  color: #aaa;
  cursor: not-allowed;
}

.day--available {
  background: var(--available-bg);
  border-color: var(--available-border);
  color: #1a3d22;
  cursor: pointer;
  font-weight: 700;
}

.day--available:hover {
  background: var(--available-hover-bg);
  border-color: var(--available-hover-border);
  color: #1a3d22;
  transform: scale(1.03);
}

@media (hover: none) {
  .day--available:hover {
    transform: none;
  }

  .day--available:active {
    background: var(--available-hover-bg);
    border-color: var(--available-hover-border);
    transform: scale(0.97);
  }
}

.day--selected,
.day--available.day--selected {
  background: var(--selected);
  border-color: var(--selected);
  color: var(--selected-text);
  font-weight: 700;
}

.day--taken {
  background: var(--taken);
  border-color: #ccc;
  color: #888;
  text-decoration: line-through;
  cursor: not-allowed;
}

.day--outside {
  background: #fafafa;
  border-color: #ddd;
  color: #ccc;
  cursor: default;
}

.slot-hint {
  margin-top: clamp(10px, 1.2vh, 14px);
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

.slot-hint--active {
  color: var(--text);
  font-weight: 600;
}

.mobile-date {
  display: none;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.4vh, 12px);
}

#bookingForm {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.4vh, 12px);
  width: 100%;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.field-row--company {
  grid-template-columns: minmax(0, 1fr) minmax(72px, 88px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field--grow {
  min-width: 0;
}

.field--attendees {
  flex-shrink: 0;
}

.field span {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.form-msg {
  min-height: 16px;
  font-size: 11px;
  color: #c44;
}

.form-msg--ok {
  color: #2a6b3c;
}

.submit-btn {
  width: 100%;
  min-height: 44px;
  height: 42px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--selected-text);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.02em;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.15s, transform 0.12s;
}

.submit-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #333;
}

.submit-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.fine-print {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.45;
  text-align: center;
}

.footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  margin-top: clamp(20px, 3vh, 32px);
  padding-top: clamp(18px, 2.5vh, 28px);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: clamp(11px, 1.2vw, 12px);
  line-height: 1.5;
  width: 100%;
}

.footer-patent {
  font-size: clamp(10px, 1.1vw, 11px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #888;
  margin-top: 2px;
}

.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  padding: 12px 20px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 100;
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
}

.shell--confirm {
  justify-content: space-between;
}

.confirm-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 32px) 0;
  width: 100%;
}

.confirm-card {
  width: min(100%, 480px);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 40px) clamp(22px, 4vw, 32px);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.confirm-card--error .confirm-title {
  color: #a33;
}

.confirm-tick {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  color: #2a8f47;
}

.confirm-title {
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.confirm-greeting {
  font-size: clamp(15px, 2.5vw, 17px);
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.45;
}

.confirm-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
  margin-bottom: 20px;
}

.confirm-detail {
  padding: 14px 16px;
  background: var(--bg-panel);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}

.confirm-detail-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.confirm-detail-value {
  font-size: clamp(15px, 2.5vw, 17px);
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
}

.confirm-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.45;
}

.confirm-home-link {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1.5px solid var(--border-strong);
  padding-bottom: 2px;
}

.confirm-home-link:hover {
  border-color: var(--text);
}

.confirm-error-msg {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.confirm-loading {
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 960px) {
  html,
  body {
    overflow: auto;
    height: auto;
  }

  .shell--confirm {
    min-height: 100dvh;
    height: auto;
  }
}

@media (max-width: 640px) {
  .confirm-card {
    padding: 24px 18px;
  }

  .confirm-tick svg {
    width: 56px;
    height: 56px;
  }
}

#bookingView[hidden],
.admin-view[hidden] {
  display: none !important;
}

.admin-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 1.5vh, 16px);
}

.admin-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  flex-shrink: 0;
}

.admin-title {
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.admin-msg {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
  flex-shrink: 0;
}

.admin-msg--ok {
  color: #2a6b3c;
}

.admin-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px;
}

.admin-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(14px, 1.8vh, 18px);
  background: var(--bg-panel);
}

.admin-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-card-date {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.admin-card-name {
  font-size: 16px;
  font-weight: 600;
  margin-top: 2px;
}

.admin-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.admin-status--pending {
  background: #fff3cd;
  color: #856404;
}

.admin-status--confirmed {
  background: var(--available-bg);
  color: #1a3d22;
}

.admin-card-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  font-size: 13px;
  margin-bottom: 14px;
}

.admin-card-details dt {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.admin-card-details dd {
  margin-top: 2px;
}

.admin-card-details a {
  color: var(--text);
}

.admin-cancel {
  width: 100%;
  height: 36px;
  border: 1.5px solid #c44;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: #a33;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.admin-cancel:hover {
  background: #c44;
  color: #fff;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  justify-content: center;
}

.admin-refresh {
  width: auto;
  padding: 0 16px;
}

.admin-exit {
  width: auto;
  padding: 0 20px;
}

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

  .form-panel {
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (max-width: 960px) {
  html,
  body {
    overflow: auto;
    height: auto;
    min-height: 100%;
  }

  .shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  #bookingView {
    flex: none;
    min-height: auto;
  }

  .content {
    flex: none;
    min-height: auto;
  }

  .main {
    display: flex;
    flex-direction: column;
    flex: none;
    min-height: auto;
    grid-template-columns: none;
  }

  .calendar-panel {
    flex: none;
    width: 100%;
    min-height: auto;
  }

  .form-panel {
    flex: none;
    width: 100%;
    justify-content: flex-start;
    min-height: auto;
  }

  .days {
    flex: none;
    min-height: auto;
  }
}

@media (max-width: 640px) {
  :root {
    --page-pad: clamp(16px, 4vw, 24px);
  }

  .header {
    margin-bottom: clamp(14px, 2.5vh, 20px);
  }

  .logo--hero {
    height: clamp(38px, 10vw, 48px);
  }

  .content {
    padding-inline: 0;
  }

  .main {
    gap: 14px;
  }

  .calendar-panel {
    padding: 14px 12px;
  }

  .calendar-panel .slot-hint {
    display: none;
  }

  .form-panel {
    max-width: none;
    padding: 16px 14px calc(100px + env(safe-area-inset-bottom, 0px));
  }

  .nav-btn {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  .day-name-long {
    display: none;
  }

  .day-name-short {
    display: inline;
  }

  .days {
    grid-auto-rows: minmax(48px, auto);
    gap: 6px;
  }

  .day {
    min-height: 48px;
    font-size: 15px;
    border-radius: 12px;
  }

  .slot-hint {
    font-size: 14px;
    padding: 0 4px;
  }

  .mobile-date {
    display: block;
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--available-bg);
    border: 1.5px solid var(--available-border);
    color: #1a3d22;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
  }

  .mobile-date[hidden] {
    display: none !important;
  }

  .field span {
    font-size: 11px;
  }

  .field input {
    height: 48px;
    font-size: 16px;
    border-radius: 12px;
  }

  #bookingForm {
    gap: 14px;
  }

  .form-actions {
    position: sticky;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    z-index: 20;
    margin-top: 4px;
    padding-top: 10px;
    background: linear-gradient(
      to top,
      var(--bg) 70%,
      rgba(255, 255, 255, 0.94)
    );
  }

  .submit-btn {
    height: 52px;
    font-size: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  }

  .fine-print {
    font-size: 11px;
  }

  .footer {
    margin-top: 16px;
    padding-top: 20px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    font-size: 12px;
  }

  .admin-view {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .admin-card-details {
    grid-template-columns: 1fr;
  }

  .admin-actions {
    flex-direction: column;
    width: 100%;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .admin-refresh,
  .admin-exit {
    width: 100%;
    min-height: 48px;
  }

  .admin-cancel {
    min-height: 48px;
    font-size: 15px;
  }
}

@media (max-width: 520px) {
  .field-row,
  .field-row--company {
    grid-template-columns: 1fr;
  }

  .field-row--company .field--attendees {
    max-width: none;
  }
}
