:root {
  --primary: #03A9F4;
  --primary-dark: #0288D1;
  --primary-light: #B3E5FC;
  --primary-wash: #E7F6FE;
  --accent: #26A69A;
  --warn: #E85D5D;
  --temp-hot: #F4432E;
  --temp-medium: #E6289E;
  --temp-cold: #2979FF;
  --bg: #F4F7FA;
  --surface: #FFFFFF;
  --text: #16232B;
  --muted: #6C7C88;
  --line: #E4EAEF;
  --readonly-bg: #F1F4F7;
  --radius: 16px;
  --nav-height: calc(64px + env(safe-area-inset-bottom));
  --topbar-height: calc(56px + env(safe-area-inset-top));
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  overscroll-behavior-y: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button, input, textarea, label {
  font-family: inherit;
}

#app {
  min-height: 100%;
  min-height: 100dvh;
  padding-bottom: var(--nav-height);
  background: var(--bg);
}

/* ===================== TOP BAR ===================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: env(safe-area-inset-top) 20px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.topbar-account {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-wash);
  padding: 5px 11px;
  border-radius: 999px;
  max-width: 32vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-badge:empty { display: none; }

/* ===================== VIEWS ===================== */
.view {
  display: none;
  animation: fadeIn 0.18s ease;
}
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===================== DAY TABS ===================== */
.day-tabs {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  position: sticky;
  top: var(--topbar-height);
  z-index: 15;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.day-tab {
  flex: 1;
  border: none;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 10px 0;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.day-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(3, 169, 244, 0.35);
}

/* ===================== LIST / CARDS ===================== */
.list {
  padding: 8px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slot-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--line);
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.slot-card:active {
  transform: scale(0.98);
}

.slot-card.filled {
  border-color: var(--primary-light);
  box-shadow: 0 2px 10px rgba(3, 169, 244, 0.1);
}

.slot-time-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 58px;
  flex-shrink: 0;
}

.slot-time {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.slot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  margin-top: 6px;
}

.slot-card.filled .slot-dot {
  background: var(--accent);
}

.slot-card.filled .slot-dot.temp-hot { background: var(--temp-hot); }
.slot-card.filled .slot-dot.temp-medium { background: var(--temp-medium); }
.slot-card.filled .slot-dot.temp-cold { background: var(--temp-cold); }

.slot-main {
  flex: 1;
  min-width: 0;
}

.slot-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-company {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-empty-label {
  font-size: 0.88rem;
  color: var(--muted);
}

.slot-chevron {
  color: var(--muted);
  flex-shrink: 0;
}

.overview-day-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--primary-dark);
  background: var(--primary-wash);
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.slot-user {
  font-size: 0.76rem;
  color: var(--primary-dark);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-count-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  padding: 3px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.slot-card-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Overview rows: clickable content + separate delete action */
.overview-row {
  cursor: default;
}

.slot-open {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

.delete-slot-btn {
  flex-shrink: 0;
  margin-left: 4px;
}

.no-user-hint {
  margin: 14px 16px 0;
  padding: 12px 14px;
  background: var(--primary-wash);
  border: 1px solid var(--primary-light);
  border-radius: 12px;
  font-size: 0.85rem;
  color: var(--primary-dark);
  line-height: 1.4;
}

/* ===================== OVERVIEW FILTER ===================== */
.overview-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 6px;
  position: sticky;
  top: var(--topbar-height);
  z-index: 15;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.overview-filter label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.overview-filter select {
  flex: 1;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 9px 12px;
  border-radius: 10px;
  outline: none;
}

.overview-filter select:focus {
  border-color: var(--primary);
}

/* ===================== EMPTY STATE ===================== */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 30px;
  color: var(--muted);
}
.empty-state.show { display: flex; }
.empty-icon { font-size: 2.4rem; margin-bottom: 10px; }
.empty-state p { margin: 0; font-weight: 700; color: var(--text); font-size: 1rem; }
.empty-state span { font-size: 0.85rem; margin-top: 4px; }

/* ===================== FORMS ===================== */
.form, .detail-body {
  padding: 18px 20px 24px;
}

.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 18px 0 8px;
}

.field-label:first-child { margin-top: 0; }

.field-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.4;
}

input[type="text"], textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(3, 169, 244, 0.15);
}

textarea { resize: vertical; min-height: 90px; line-height: 1.45; }

.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 26px 0 6px;
}

/* ===================== LEAD TEMPERATURE ===================== */
.temp-selector {
  display: flex;
  gap: 8px;
}

.temp-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 11px 0;
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s;
}

.temp-option.active {
  background: var(--bg);
  border-color: currentColor;
}
.temp-option[data-temp="hot"].active { color: var(--temp-hot); }
.temp-option[data-temp="medium"].active { color: var(--temp-medium); }
.temp-option[data-temp="cold"].active { color: var(--temp-cold); }

.temp-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--line);
}
.temp-dot.temp-hot { background: var(--temp-hot); }
.temp-dot.temp-medium { background: var(--temp-medium); }
.temp-dot.temp-cold { background: var(--temp-cold); }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 13px 18px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  width: 100%;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(3, 169, 244, 0.35);
}
.btn-primary:disabled { opacity: 0.5; box-shadow: none; }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--line);
}

.btn.small {
  width: auto;
  padding: 9px 14px;
  font-size: 0.82rem;
  flex-shrink: 0;
  gap: 6px;
}

.save-toast {
  opacity: 0;
  transform: translateY(-4px);
  text-align: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 10px;
  transition: opacity 0.25s, transform 0.25s;
}
.save-toast.show { opacity: 1; transform: translateY(0); }

/* ===================== RECORDER ===================== */
.recorder {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}

.rec-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--primary-wash);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.rec-dot {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--warn);
  transition: border-radius 0.2s;
}

.rec-btn.recording {
  background: rgba(232, 93, 93, 0.14);
  animation: pulse 1.4s infinite;
}
.rec-btn.recording .rec-dot { border-radius: 4px; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(232, 93, 93, 0.3); }
  70% { box-shadow: 0 0 0 12px rgba(232, 93, 93, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 93, 93, 0); }
}

.rec-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
#recStatus { font-weight: 600; font-size: 0.9rem; }
#recTimer { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.audio-player {
  width: 100%;
  margin-top: 12px;
  height: 40px;
}

.rec-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.hidden { display: none !important; }
.hidden-input { display: none; }

/* ===================== AUTH / SIGN-IN GATE ===================== */
.auth-view {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--primary-wash) 0%, var(--bg) 55%);
  padding: 24px;
}

.auth-view.active { display: flex; }

.auth-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border-radius: 20px;
  padding: 36px 28px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(3, 169, 244, 0.16);
}

.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 16px;
}

.auth-card h1 {
  font-size: 1.3rem;
  margin: 0 0 6px;
}

.auth-card p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 22px;
  line-height: 1.4;
}

.google-btn-slot {
  display: flex;
  justify-content: center;
  min-height: 44px;
}

.auth-error {
  color: var(--warn);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 16px !important;
}

.auth-loading {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 14px !important;
}

/* ===================== GOOGLE ACCOUNT (top bar) ===================== */
.google-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--primary-light);
}

/* ===================== VOICE MEMO CHECKLIST ===================== */
.voice-checklist {
  background: var(--primary-wash);
  border: 1px solid var(--primary-light);
  border-radius: 12px;
  padding: 12px 15px;
  margin-bottom: 12px;
}

.voice-checklist-title {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary-dark);
  margin-bottom: 6px;
}

.voice-checklist ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ===================== TRANSCRIPTION ===================== */
.transcription-box {
  background: var(--primary-wash);
  border: 1px dashed var(--primary-light);
  border-radius: 12px;
  padding: 4px;
  min-height: 20px;
  position: relative;
}

.transcription-input {
  width: 100%;
  display: block;
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
  min-height: 20px;
}

.transcription-input::placeholder { color: var(--muted); }

.transcription-box.loading .transcription-input {
  color: var(--primary-dark);
  padding-left: 30px;
}

.transcription-box.loading::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 19px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--primary-light);
  border-top-color: var(--primary-dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===================== PHOTOS ===================== */
.photo-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.photo-thumb {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

/* ===================== PHOTO LIGHTBOX ===================== */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 20, 0.92);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox.show {
  display: flex;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(22, 35, 43, 0.65);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
}

.add-photo-btn {
  display: block;
  text-align: center;
  color: var(--primary-dark);
  border-color: var(--primary-light);
  background: var(--primary-wash);
}

/* ===================== DETAIL / ENTRIES VIEW (overlays) ===================== */
.detail-view {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  display: none;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.22s ease;
  overflow-y: auto;
}

.detail-view.active {
  display: flex;
  transform: translateY(0);
}

.entries-view { z-index: 45; }

.booked-by {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-wash);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.detail-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) 10px 0 10px;
  height: var(--topbar-height);
  flex-shrink: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:active { background: var(--line); }
.icon-btn.danger { color: var(--warn); margin-left: auto; }

.detail-heading {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.detail-heading span { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.detail-heading strong { font-size: 1.05rem; }

.detail-body { flex: 1; }

.detail-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ===================== BOTTOM NAV ===================== */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.nav-item {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding-top: 6px;
}

.nav-item.active {
  color: var(--primary);
}

/* ===================== SCROLLBARS ===================== */
::-webkit-scrollbar { width: 0; height: 0; }

/* ===================== SHARED-SLOT + READ-ONLY STATES ===================== */

/* A slot the caller doesn't own still exists — say so quietly rather than
   letting "Available" imply the whole slot is free. */
.slot-others {
  font-size: 12px;
  color: var(--muted, #7a8794);
  margin-top: 2px;
}

.entries-others-note {
  font-size: 13px;
  color: var(--muted, #7a8794);
  padding: 12px 4px 0;
  margin: 0;
  line-height: 1.4;
}

/* Other people's bookings open for reading only. */
.temp-selector.is-readonly {
  opacity: 0.6;
  pointer-events: none;
}

input[readonly],
textarea[readonly] {
  background: var(--readonly-bg, #f1f4f7);
  color: var(--muted, #7a8794);
  cursor: default;
}

/* Photos on someone else's booking can be viewed, not removed. */
.photo-strip.is-readonly .photo-remove {
  display: none;
}

/* ===================== UNSAVED DRAFT BANNER ===================== */

/* Shown when a booking was being typed and the page reloaded or the OS
   reclaimed the app before it could be saved. */
.draft-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 16px 0;
  padding: 12px 14px;
  border: 1px solid var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary-wash);
}

.draft-banner.hidden { display: none; }

.draft-banner-text {
  flex: 1 1 200px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
}

.draft-banner-text strong { font-weight: 600; }

.draft-banner-lost {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}

.draft-banner-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
