:root {
  color-scheme: light;
  --ink: #0b1324;
  --muted: #64748b;
  --line: #dce3ed;
  --surface: #ffffff;
  --canvas: #f3f6fa;
  --nav: #0b1324;
  --nav-soft: #17233a;
  --accent: #2764ff;
  --accent-soft: #eaf0ff;
  --success: #11845b;
  --warning: #b26a08;
  --danger: #bf3344;
  --shadow: 0 14px 40px rgba(11, 19, 36, .08);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.boot-screen {
  min-height: 100vh; display: grid; place-content: center; justify-items: center;
  gap: 16px; color: var(--muted);
}
.brand-mark {
  display: grid; place-items: center; width: 48px; height: 48px;
  border-radius: 15px; background: var(--accent); color: white;
  font-weight: 800; letter-spacing: -.04em;
}
.boot-line {
  width: 150px; height: 3px; border-radius: 9px;
  background: linear-gradient(90deg, var(--accent) 35%, #dbe4f3 35%);
  animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse { to { opacity: .45; transform: scaleX(.92); } }

.auth-page {
  min-height: 100vh; display: grid; grid-template-columns: 1.08fr .92fr;
  background: var(--surface);
}
.auth-story {
  position: relative; overflow: hidden; padding: 56px clamp(32px, 6vw, 92px);
  display: flex; flex-direction: column; justify-content: space-between;
  color: white; background:
    radial-gradient(circle at 84% 14%, rgba(72, 116, 255, .55), transparent 28%),
    linear-gradient(145deg, #0b1324 0%, #14264c 54%, #173b79 100%);
}
.auth-story::after {
  content: ""; position: absolute; width: 440px; height: 440px;
  right: -220px; bottom: -170px; border: 1px solid rgba(255,255,255,.17);
  border-radius: 50%; box-shadow: 0 0 0 58px rgba(255,255,255,.035),
    0 0 0 118px rgba(255,255,255,.025);
}
.wordmark { display: flex; align-items: center; gap: 12px; font-weight: 750; font-size: 19px; }
.wordmark .brand-mark { background: white; color: var(--nav); }
.auth-copy { position: relative; z-index: 1; max-width: 620px; }
.eyebrow { margin: 0 0 12px; color: #8facff; font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.auth-copy h1 { margin: 0 0 22px; font-size: clamp(42px, 5.3vw, 76px); line-height: .99; letter-spacing: -.055em; }
.auth-copy p { max-width: 520px; margin: 0; color: #c7d4ea; font-size: 18px; line-height: 1.65; }
.auth-proof { position: relative; z-index: 1; display: flex; gap: 28px; color: #b9c8e2; font-size: 13px; }
.auth-proof span::before { content: "●"; margin-right: 8px; color: #59dcac; }
.auth-panel { display: grid; place-items: center; padding: 36px; }
.auth-card { width: min(430px, 100%); }
.auth-card h2 { margin: 0; font-size: 32px; letter-spacing: -.035em; }
.auth-card > p { color: var(--muted); margin: 10px 0 28px; line-height: 1.6; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 26px; background: #edf1f7; border-radius: 12px; }
.tab { border: 0; padding: 10px; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; }
.tab.active { color: var(--ink); background: white; box-shadow: 0 2px 8px rgba(11,19,36,.08); }
.field { display: grid; gap: 8px; margin: 16px 0; }
.field label { font-size: 13px; font-weight: 750; }
.field input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; outline: 0; color: var(--ink); background: white;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(191, 51, 68, .09);
}
.field-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; }
.password-guidance {
  display: grid; gap: 7px; padding: 12px 14px; border-radius: 11px;
  color: var(--muted); background: #f5f7fb; font-size: 12px; line-height: 1.45;
}
.password-guidance strong { color: var(--ink); }
.password-guidance span { font-size: 11px; }
.password-checklist { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.password-checklist li::first-letter { font-weight: 900; }
.password-checklist li.met { color: var(--success); }
.primary, .secondary, .ghost, .icon-button {
  border: 0; border-radius: 11px; font-weight: 750;
}
.primary { padding: 13px 18px; color: white; background: var(--accent); box-shadow: 0 7px 18px rgba(39,100,255,.2); }
.primary:hover { background: #1754ed; }
.primary:disabled { opacity: .55; cursor: wait; }
.auth-card .primary { width: 100%; margin-top: 8px; }
.form-error { min-height: 20px; color: var(--danger); font-size: 13px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 252px; z-index: 5;
  display: flex; flex-direction: column; padding: 26px 18px;
  color: #d9e4f5; background: var(--nav);
}
.sidebar .wordmark { padding: 0 8px 26px; }
.sidebar .brand-mark { width: 40px; height: 40px; }
.nav-label { margin: 20px 12px 9px; color: #6f819e; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 12px;
  border: 0; border-radius: 10px; color: #aebcd2; background: transparent;
  text-align: left; font-weight: 650;
}
.nav-item.active { color: white; background: var(--nav-soft); }
.nav-dot { width: 8px; height: 8px; border: 2px solid currentColor; border-radius: 50%; }
.sidebar-footer { margin-top: auto; padding: 16px 8px 0; border-top: 1px solid #26344b; }
.user-mini { display: flex; gap: 11px; align-items: center; min-width: 0; }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 12px; background: #263c66; color: white; font-weight: 800; }
.user-mini strong, .user-mini span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini span { margin-top: 3px; color: #8191aa; font-size: 11px; }
.logout { margin-top: 14px; width: 100%; border: 1px solid #2c3b53; border-radius: 10px; padding: 9px; color: #aebcd2; background: transparent; }

.main { grid-column: 2; min-width: 0; }
.topbar {
  height: 78px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(22px, 4vw, 52px); border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.9); backdrop-filter: blur(12px);
}
.topbar-title { font-size: 15px; font-weight: 800; }
.org-select {
  min-width: 220px; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 36px 10px 12px; color: var(--ink); background: white;
}
.content { padding: 42px clamp(22px, 4vw, 52px) 70px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-heading h1 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.045em; }
.page-heading p { margin: 0; color: var(--muted); }
.secondary { padding: 11px 16px; color: var(--accent); background: var(--accent-soft); }
.ghost { padding: 10px 14px; border: 1px solid var(--line); background: white; color: var(--ink); }

.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 28px; }
.analytics-kpis { grid-template-columns: repeat(4, 1fr); }
.period-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.period-tab { padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: white; font-weight: 750; }
.period-tab.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.analytics-breakdown { max-width: 720px; }
.privacy-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.privacy-grid .privacy-deletion { grid-column: 1 / -1; }
.privacy-warning { margin: 0 0 18px; color: var(--muted); line-height: 1.6; }
.privacy-warning strong { color: var(--danger); }
.auth-consent { margin: 20px 0 8px; line-height: 1.45; }
.metric { padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.metric span { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric strong { display: block; margin-top: 5px; font-size: 25px; letter-spacing: -.03em; }
.business-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(315px, 1fr)); gap: 18px; }
.business-card {
  position: relative; overflow: hidden; border: 1px solid var(--line);
  border-radius: var(--radius); background: white; box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.business-card:hover { transform: translateY(-2px); box-shadow: 0 18px 48px rgba(11,19,36,.12); }
.card-accent { height: 5px; background: linear-gradient(90deg, var(--accent), #7ca2ff); }
.card-body { padding: 23px; }
.card-kicker { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.business-card h2 { margin: 8px 0 5px; font-size: 22px; letter-spacing: -.025em; }
.business-meta { min-height: 42px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.status-list { display: grid; gap: 11px; margin: 22px 0; padding: 16px 0; border-block: 1px solid #edf0f5; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 999px; font-size: 10px; font-weight: 850; letter-spacing: .05em; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--success); background: #e9f8f2; }
.pill.warn { color: var(--warning); background: #fff5df; }
.pill.muted { color: #65758c; background: #eef2f7; }
.card-actions { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.card-actions button { white-space: nowrap; }

.empty, .error-panel {
  padding: 60px 28px; border: 1px dashed #c9d2df; border-radius: var(--radius);
  text-align: center; background: rgba(255,255,255,.65);
}
.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 18px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); font-size: 24px; }
.empty h2, .error-panel h2 { margin: 0 0 9px; }
.empty p, .error-panel p { max-width: 460px; margin: 0 auto 22px; color: var(--muted); line-height: 1.6; }
.skeleton { min-height: 290px; border-radius: var(--radius); background: linear-gradient(100deg,#e9edf3 30%,#f7f9fc 45%,#e9edf3 60%); background-size: 250% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position-x: -250%; } }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(5,11,24,.58); backdrop-filter: blur(5px); }
.modal { width: min(520px, 100%); max-height: 88vh; overflow: auto; padding: 26px; border-radius: 20px; background: white; box-shadow: 0 28px 80px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.modal h2 { margin: 0; letter-spacing: -.03em; }
.icon-button { width: 34px; height: 34px; color: var(--muted); background: #eef2f7; }
.detail-table { display: grid; gap: 0; margin-top: 20px; }
.detail-row { display: grid; grid-template-columns: 150px 1fr; gap: 20px; padding: 13px 0; border-bottom: 1px solid #edf0f5; font-size: 13px; }
.detail-row span { color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 390px;
  padding: 13px 16px; border-radius: 12px; color: white; background: var(--nav);
  box-shadow: var(--shadow); opacity: 0; transform: translateY(12px);
  pointer-events: none; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

.editor-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.editor-header h1 { margin: 3px 0 10px; font-size: clamp(30px, 4vw, 44px); letter-spacing: -.045em; }
.back-link { padding: 0; margin-bottom: 22px; border: 0; color: var(--accent); background: transparent; font-weight: 750; }
.editor-status { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.publish-actions { display: flex; gap: 10px; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 24px; align-items: start; }
.editor-column { display: grid; gap: 18px; }
.editor-card { padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: white; box-shadow: var(--shadow); }
.section-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.section-title h2 { margin: 0 0 5px; font-size: 20px; }
.section-title p { margin: 0; color: var(--muted); font-size: 13px; }
.save-state { color: var(--success); font-size: 12px; font-weight: 800; }
.field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; outline: 0; color: var(--ink); background: white; resize: vertical; }
.field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.block-list { display: grid; gap: 10px; }
.block-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px; border: 1px solid #e6ebf2; border-radius: 13px; }
.block-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--accent); background: var(--accent-soft); font-size: 11px; font-weight: 900; }
.block-copy { min-width: 0; }
.block-copy strong, .block-copy span { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.block-copy span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.block-controls { display: flex; gap: 6px; align-items: center; }
.block-controls .icon-button:disabled { opacity: .3; cursor: default; }
.danger-button { padding: 9px 11px; border: 0; border-radius: 10px; color: var(--danger); background: #fff0f2; font-weight: 750; }
.compact-empty { display: grid; gap: 5px; padding: 28px 18px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); text-align: center; }
.permission-note { margin: 0; padding: 13px 16px; border-radius: 12px; color: #79580a; background: #fff5df; font-size: 13px; }
.preview-column { position: sticky; top: 22px; }
.public-access { margin-top: 18px; text-align: center; }
.public-access h2 { margin: 0 0 8px; font-size: 18px; }
.public-access p { overflow-wrap: anywhere; }
.public-access img { max-width: 100%; height: auto; padding: 8px; background: white; }
.preview-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.preview-label .ghost { padding: 7px 10px; font-size: 11px; letter-spacing: 0; text-transform: none; }
.phone-preview { min-height: 620px; padding: 35px 25px 24px; border: 9px solid var(--ink); border-radius: 38px; color: #f8fbff; background: linear-gradient(155deg,#132548,#08101f 65%); box-shadow: 0 24px 60px rgba(11,19,36,.2); }
.phone-speaker { width: 60px; height: 5px; margin: -19px auto 34px; border-radius: 8px; background: #4a5870; }
.preview-brand { color: #89a9ff; font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.phone-preview h2 { margin: 13px 0 8px; font-size: 28px; letter-spacing: -.04em; }
.phone-preview > p { margin: 0 0 24px; color: #aebdd5; font-size: 13px; line-height: 1.55; }
.preview-blocks { display: grid; gap: 9px; }
.preview-block { display: grid; gap: 4px; padding: 14px 15px; border: 1px solid #30405a; border-radius: 14px; background: rgba(255,255,255,.055); }
.preview-block small { color: #769dff; font-size: 9px; font-weight: 850; }
.preview-block strong { font-size: 13px; }
.preview-block span { overflow-wrap: anywhere; color: #b7c4d8; font-size: 11px; }
.preview-foot { margin-top: 25px; color: #667894; font-size: 10px; text-align: center; }
.check-field { display: flex; gap: 9px; align-items: center; margin-top: 18px; color: var(--muted); font-size: 13px; }
.mobile-tabs { display: none; }
.editor-loading { max-width: 720px; margin: 40px auto; text-align: center; color: var(--muted); }

@media (max-width: 850px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-story { min-height: 330px; padding: 34px 26px; }
  .auth-copy h1 { font-size: 42px; }
  .auth-proof { display: none; }
  .auth-panel { padding: 38px 24px; }
  .shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; flex-direction: row; align-items: center; padding: 13px 18px; }
  .sidebar .wordmark { padding: 0; }
  .sidebar nav, .sidebar-footer .user-mini { display: none; }
  .sidebar-footer { margin: 0 0 0 auto; padding: 0; border: 0; }
  .logout { margin: 0; width: auto; }
  .main { grid-column: auto; }
  .topbar { height: auto; padding: 14px 20px; }
  .topbar-title { display: none; }
  .org-select { width: 100%; }
  .content { padding-top: 28px; }
  .summary-grid, .analytics-kpis, .privacy-grid { grid-template-columns: 1fr; }
  .privacy-grid .privacy-deletion { grid-column: auto; }
  .editor-layout { grid-template-columns: 1fr; }
  .preview-column { position: static; }
  .phone-preview { width: min(390px, 100%); margin: auto; }
}

@media (max-width: 560px) {
  .auth-story { min-height: 280px; }
  .auth-copy p { font-size: 15px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .business-grid { grid-template-columns: 1fr; }
  .card-actions { grid-template-columns: 1fr; }
  .detail-row { grid-template-columns: 1fr; gap: 4px; }
  .editor-header { align-items: stretch; flex-direction: column; }
  .publish-actions button { width: 100%; }
  .mobile-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 16px; border-radius: 12px; background: #e7ecf4; }
  .mobile-tabs button { padding: 10px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-weight: 750; }
  .mobile-tabs button.active { color: var(--ink); background: white; }
  .editor-layout [data-editor-panel="preview"] { display: none; }
  .editor-layout[data-mobile-tab="preview"] [data-editor-panel="preview"] { display: block; }
  .editor-layout[data-mobile-tab="preview"] [data-editor-panel="form"] { display: none; }
  .editor-card { padding: 18px; }
  .section-title { align-items: stretch; flex-direction: column; }
  .block-row { grid-template-columns: 42px minmax(0, 1fr); }
  .block-controls { grid-column: 1 / -1; }
  .phone-preview { min-height: 560px; }
}
