:root {
  --ink: #1a1a1a;
  --sub: #6b7280;
  --border: #e5e7eb;
  --bubble-me: #1a1a1a;
  --bubble-agent: #f0f0f0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #fafafa;
}

/* --- Login: same photo backdrop as the landing page, minimal auth card --- */

.login-body { min-height: 100vh; position: relative; }

.login-hero {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(180deg, rgba(10, 14, 20, 0.55) 0%, rgba(10, 14, 20, 0.35) 45%, rgba(10, 14, 20, 0.7) 100%),
    url("https://images.unsplash.com/photo-1590846406792-0adc7f938f1d?auto=format&fit=crop&w=2400&q=80");
  background-size: cover;
  background-position: center;
}

.login-wrap {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-brand {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 600;
  color: white;
  text-decoration: none;
  margin-bottom: 28px;
}

.auth-card {
  width: 100%;
  background: white;
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.card h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 400;
  margin: 0 0 12px;
}

.sub { color: var(--sub); font-size: 15px; line-height: 1.5; margin: 0 0 24px; }

form { display: flex; gap: 8px; margin-bottom: 12px; }

input[type="tel"], input[type="text"], input[type="number"] {
  flex: 1;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}

button[type="submit"] {
  padding: 11px 18px;
  border: none;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  cursor: pointer;
}
button[type="submit"]:disabled { opacity: 0.5; cursor: default; }

.link-button {
  background: none;
  border: none;
  color: var(--sub);
  text-decoration: underline;
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}

.error { color: #d02c2c; font-size: 14px; }

[hidden] { display: none !important; }

/* --- Dashboard shell --- */

.portal-shell {
  display: flex;
  height: 100vh;
}

.chat-pane {
  width: 40%;
  min-width: 340px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: white;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.chat-header h2 { font-size: 16px; margin: 0; }
.chat-header button { background: none; border: none; color: var(--sub); cursor: pointer; font-size: 13px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; line-height: 1.4; font-size: 14px; }
.msg.me { align-self: flex-end; background: var(--bubble-me); color: white; border-bottom-right-radius: 4px; }
.msg.agent { align-self: flex-start; background: var(--bubble-agent); border-bottom-left-radius: 4px; }
.msg.pending { opacity: 0.5; }
.msg img { max-width: 180px; border-radius: 8px; display: block; margin-top: 6px; }
.msg.me a { color: #9ecbff; }
.msg.agent a { color: #1a56db; }
.msg a { word-break: break-all; }

.msg.typing { display: flex; align-items: center; gap: 4px; padding: 14px; opacity: 1; }
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sub);
  animation: typing-bounce 1.1s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-form {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.chat-form .photo-label { font-size: 18px; cursor: pointer; padding: 4px; }
.chat-form input[type="text"] { flex: 1; border-radius: 20px; }
.chat-form button[type="submit"] { border-radius: 20px; }

.right-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- Preview toolbar + full-height site preview --- */

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: white;
}
.preview-toolbar .site-name { font-weight: 600; font-size: 15px; }
.preview-toolbar .payments-badge { font-size: 12px; margin-left: 10px; padding: 2px 8px; border-radius: 999px; }
.preview-toolbar .payments-badge.on { background: #e6f6ea; color: #1b7f3b; }
.preview-toolbar .payments-badge.off { background: #fff3e0; color: #a35a00; }
.modal-intro.sub { color: var(--sub); font-size: 13px; }
.code-line { display: block; font-size: 12px; padding: 8px 10px; background: #f4f4f4; border-radius: 6px; word-break: break-all; }
.link-btn { background: none; border: none; color: var(--accent, #2b6cb0); cursor: pointer; padding: 0; font-size: 13px; text-decoration: underline; }
.choice-group { border: 1px solid var(--border, #e3e3e3); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.choice-group-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.choice-group-head input[type="text"] { flex: 1; min-width: 160px; }
.choice-group-head .choice-max input { width: 56px; margin-left: 4px; }
.choice-option { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.choice-option input[type="text"] { flex: 1; }
.choice-option input[type="number"] { width: 90px; }

.verification-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  margin-left: 10px;
  white-space: nowrap;
}
.verification-badge.verified { background: #eafaf0; color: #146c2e; }
.verification-badge.unverified { background: #fdf0e3; color: #9a5a12; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; }

.toolbar-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 13px;
}
.toolbar-btn:hover { background: #f5f5f5; }

.toolbar-link { color: var(--sub); font-size: 13px; text-decoration: none; margin-left: 6px; }
.toolbar-link:hover { text-decoration: underline; }

.full-preview { flex: 1; border: none; width: 100%; background: white; }

.no-site-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--ink);
}
.no-site-placeholder p { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.no-site-placeholder p.sub { font-weight: 400; font-size: 14px; color: var(--sub); max-width: 360px; }

.generating-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: generating-spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes generating-spin {
  to { transform: rotate(360deg); }
}

/* --- Onboarding screen: mandatory first step, a real UI, never chat --- */

.onboarding-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg, #f5f5f5);
  padding: 24px;
}

.onboarding-card {
  background: white;
  border-radius: 16px;
  padding: 36px 32px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
  text-align: center;
}
.onboarding-card h1 { font-size: 20px; margin: 0 0 10px; }
.onboarding-sub { margin: 0 0 24px; font-size: 14px; color: var(--sub); line-height: 1.5; }

.onboarding-form { display: flex; gap: 8px; margin-bottom: 4px; }
.onboarding-form input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.onboarding-form button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.onboarding-form button:disabled { opacity: 0.6; cursor: default; }

.onboarding-error { color: #d02c2c; font-size: 13px; margin: 12px 0 0; }

.onboarding-confirm-card {
  background: var(--bg, #f5f5f5);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
  text-align: left;
}
.onboarding-confirm-name { font-weight: 700; font-size: 17px; margin-bottom: 6px; }
.onboarding-confirm-address { font-size: 14px; color: var(--sub); margin-bottom: 4px; }
.onboarding-confirm-phone { font-size: 14px; color: var(--sub); }

.onboarding-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

#onboarding-step-generating .onboarding-generating-text { margin: 16px 0 0; font-weight: 600; }

/* --- Edit modals (native <dialog>) --- */

.edit-modal {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: 480px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.edit-modal.wide { width: 640px; }
.edit-modal::backdrop { background: rgba(0, 0, 0, 0.4); }

.edit-modal form,
.edit-modal .modal-body {
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; margin: 0; }
.close-btn { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--sub); }

.modal-body { padding: 20px; overflow-y: auto; gap: 14px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.modal-error { color: #d02c2c; font-size: 13px; margin-right: auto; }

.primary-btn {
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  cursor: pointer;
  font-size: 14px;
}
.primary-btn:disabled { opacity: 0.5; cursor: default; }
.secondary-btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 14px;
}

.field-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field-row label { font-size: 13px; color: var(--sub); }
.field-row input, .field-row select, .field-row textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.field-row input:invalid { border-color: #d02c2c; }
.field-row textarea { min-height: 70px; resize: vertical; }
.field-row.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.field-row.checkbox label { font-size: 14px; color: var(--ink); }
.field-error { color: #d02c2c; font-size: 12px; min-height: 14px; }
.field-hint { color: var(--sub); font-size: 12px; margin-top: 2px; }

.modal-intro {
  font-size: 13px;
  color: var(--sub);
  background: #f5f5f5;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 16px;
}
.modal-intro.status-active { background: #eafaf0; color: #146c2e; }
.modal-intro.status-pending { background: #fff8e6; color: #8a6d00; }
.modal-intro.status-rejected { background: #fdecec; color: #a11414; }

/* --- Hours editor (Google Maps style day rows) --- */

.hours-day-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.hours-day-row:last-child { border-bottom: none; }

.hours-day-row .day-label { width: 100px; font-weight: 600; font-size: 14px; padding-top: 8px; flex-shrink: 0; }

.hours-day-row .day-closed-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--sub);
  padding-top: 6px;
  flex-shrink: 0;
}

.hours-day-row .ranges { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.hours-day-row .range-row { display: flex; align-items: center; gap: 6px; }
.hours-day-row .range-row input[type="time"] {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.hours-day-row .range-row .remove-range-btn {
  background: none;
  border: none;
  color: var(--sub);
  cursor: pointer;
  font-size: 14px;
}
.hours-day-row .add-range-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: #1a56db;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 0;
}
.hours-day-row .copy-to-all-btn {
  background: none;
  border: none;
  color: var(--sub);
  cursor: pointer;
  font-size: 15px;
  padding-top: 6px;
  flex-shrink: 0;
}
.hours-day-row .closed-label { color: var(--sub); font-size: 13px; padding-top: 8px; }

/* --- Menu table (inside menu modal) --- */

.menu-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.menu-table th, .menu-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 14px; }
.menu-table input { width: 100%; border: 1px solid transparent; padding: 4px 6px; border-radius: 6px; font-size: 14px; }
.menu-table input:focus { border-color: var(--border); outline: none; }
.menu-table .remove-btn { background: none; border: none; color: #d02c2c; cursor: pointer; font-size: 16px; }

.add-item-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.add-item-form input { flex: 1; min-width: 100px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.add-item-form button { padding: 8px 16px; border: none; border-radius: 8px; background: var(--ink); color: white; cursor: pointer; }

/* --- Template picker (Design modal) --- */

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

.template-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: white;
  text-align: left;
  padding: 0;
}
.template-card.selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); }
.template-card img { display: block; width: 100%; height: 90px; object-fit: cover; object-position: top; background: var(--border); }
.template-card .template-card-label { padding: 8px 10px; }
.template-card .template-card-name { font-weight: 600; font-size: 13px; }
.template-card .template-card-vibe { font-size: 12px; color: var(--sub); }
