:root {
  --bg: #0b0f14;
  --surface: #121821;
  --surface-2: #18212d;
  --surface-3: #1f2a38;
  --border: #263244;
  --text: #f3f6fa;
  --text-muted: #98a6b8;
  --emerald: #00d084;
  --emerald-dark: #009e63;
  --emerald-soft: rgba(0, 208, 132, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --coral: #ff5a5f;
  --coral-soft: rgba(255, 90, 95, 0.14);
  --blue: #38bdf8;
  --blue-soft: rgba(56, 189, 248, 0.14);
  --paper: #faf8f3;
  --paper-ink: #171a1f;
  --mono: ui-monospace, "Cascadia Mono", "Consolas", "SFMono-Regular", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: radial-gradient(circle at top right, #12212b 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 88px;
  overflow-x: hidden;
}

.hero-grid > *,
.demo-bar > *,
.purchase-grid > *,
.share-layout > *,
.stat-tiles > * {
  min-width: 0;
}

.pcard-title,
.pcard-headline,
.pcard-meta {
  overflow-wrap: anywhere;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  background: rgba(11, 15, 20, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.brand-name {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 7px;
}

.brand-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.plan-pill {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}
.plan-pill.free {
  background: var(--surface-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.plan-pill.pro {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid rgba(0, 208, 132, 0.45);
}

.desktop-nav {
  display: flex;
  gap: 6px;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: 0.15s ease;
}

.nav-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-btn.active {
  color: var(--bg);
  background: var(--emerald);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.app-main {
  padding: 18px;
}

.view {
  display: none;
}
.view.active {
  display: block;
  animation: fadeIn 0.18s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile bottom nav */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  background: rgba(15, 21, 29, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around;
}

.mnav-btn {
  position: relative;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.mnav-btn.active {
  color: var(--emerald);
  background: var(--emerald-soft);
}
.mnav-ico {
  font-size: 1.1rem;
  line-height: 1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 10px 15px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn-sm {
  padding: 7px 11px;
  font-size: 0.8rem;
}
.btn-primary {
  background: var(--emerald);
  color: #062116;
}
.btn-primary:hover {
  background: #1ce298;
}
.btn-secondary {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  border-color: #3a4c66;
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}
.btn-amber {
  background: var(--amber);
  color: #261602;
}
.btn-danger {
  background: var(--coral-soft);
  color: var(--coral);
  border-color: rgba(255, 90, 95, 0.35);
}

/* Badges */
.badge {
  background: var(--coral);
  color: #fff;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 0.7rem;
  font-weight: 800;
  font-family: var(--mono);
}
.mobile-nav .badge {
  position: absolute;
  top: 2px;
  right: 4px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.pill-emerald { background: var(--emerald-soft); color: var(--emerald); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-coral { background: var(--coral-soft); color: var(--coral); }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-muted { background: var(--surface-3); color: var(--text-muted); }

.hidden {
  display: none !important;
}

/* Cards & Hero */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.hero-ledger {
  background: linear-gradient(135deg, #112621 0%, #111822 65%);
  border: 1px solid rgba(0, 208, 132, 0.3);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--emerald);
}

.hero-figure {
  font-size: clamp(2rem, 4vw, 2.7rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: var(--emerald);
  line-height: 1.05;
  margin: 4px 0;
}

.hero-subrow {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  font-size: 0.86rem;
  color: var(--text-muted);
}
.hero-subrow strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
}
.stat-tile .label {
  font-size: 0.76rem;
  color: var(--text-muted);
}
.stat-tile .val {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

/* Demo Bar */
.demo-bar {
  background: var(--surface);
  border: 1px dashed #32445b;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.demo-bar-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}
.demo-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* Filter Row */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
  justify-content: space-between;
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.filter-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.filter-pill.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* Purchase List */
.purchase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.purchase-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.purchase-card:hover {
  border-color: #3a4f69;
}
.purchase-card.has-drop {
  border-color: rgba(0, 208, 132, 0.45);
  box-shadow: 0 8px 26px rgba(0, 208, 132, 0.08);
}

.pcard-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.retailer-tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--blue);
}
.pcard-title {
  margin: 4px 0 2px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}
.pcard-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.price-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-variant-numeric: tabular-nums;
}
.price-col .lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.price-col .num {
  font-size: 1.05rem;
  font-weight: 800;
}
.drop-highlight {
  text-align: right;
}
.drop-highlight .amt {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--emerald);
}
.drop-highlight .pct {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.pcard-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pcard-headline {
  font-size: 0.83rem;
  color: #cbd5e1;
  line-height: 1.4;
}
.pcard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: auto;
  padding-top: 4px;
}

/* Forms & Ingest */
.ingest-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.tab-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.tab-chip.active {
  background: var(--emerald);
  color: #052015;
  border-color: var(--emerald);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.9rem;
}
.field input[type="checkbox"] {
  width: auto;
  padding: 0;
  accent-color: var(--emerald);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--emerald);
}

.dropzone {
  border: 2px dashed #354962;
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--emerald);
  background: rgba(0, 208, 132, 0.06);
}

.draft-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.draft-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(4, 7, 11, 0.76);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.modal-sheet {
  width: 100%;
  max-width: 760px;
  max-height: 92vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.modal-compact {
  max-width: 520px;
}
.modal-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.modal-header h2 {
  margin: 3px 0 0;
  font-size: 1.15rem;
}
.icon-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
.modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.section-box h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.script-box {
  background: #0a0e14;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  color: #e2e8f0;
}

/* Share 9:16 Studio */
.share-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}
.canvas-frame {
  background: #070a0e;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 12px;
  display: flex;
  justify-content: center;
}
.canvas-frame canvas {
  width: 100%;
  max-width: 330px;
  aspect-ratio: 9 / 16;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

/* Alerts & Settings */
.notif-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.notif-item.unread {
  border-left: 4px solid var(--emerald);
  background: #141e28;
}

.check-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 9px;
}
.check-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.check-card input {
  margin-top: 3px;
  accent-color: var(--emerald);
}

/* Toasts */
.toast-stack {
  position: fixed;
  bottom: 84px;
  right: 16px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}
.toast {
  background: #17222f;
  border: 1px solid var(--emerald);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.toast.error {
  border-color: var(--coral);
}

/* Mobile Responsive */
@media (max-width: 820px) {
  .desktop-nav {
    display: none;
  }
  .mobile-nav {
    display: flex;
  }
  .topbar {
    padding: 10px 12px;
    gap: 8px;
  }
  .brand-sub,
  #sweepBtn {
    display: none;
  }
  .mnav-btn {
    padding: 6px 6px;
    font-size: 0.7rem;
  }
  .hero-grid, .share-layout {
    grid-template-columns: 1fr;
  }
  .purchase-grid {
    grid-template-columns: 1fr;
  }
  .app-main {
    padding: 12px;
  }
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-sheet {
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
  }
}


/* --- Google sign-in --- */
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
}

.auth-logo {
  width: 56px;
  height: 56px;
}

.auth-title {
  margin: 12px 0 4px;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}

.auth-tagline {
  margin: 0 0 16px;
  color: var(--emerald);
  font-family: var(--mono);
  font-size: 0.85rem;
}

.auth-copy {
  margin: 0 0 24px;
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 0.95rem;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid #dadce0;
  background: #fff;
  color: #1f1f1f;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background 0.15s ease;
}

.google-btn:hover {
  background: #f4f6f8;
}

.google-btn:focus-visible {
  outline: 2px solid var(--emerald);
  outline-offset: 2px;
}

.auth-error {
  margin: 16px 0 0;
  color: var(--coral);
  font-size: 0.9rem;
}

.auth-fine {
  margin: 20px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.account-chip.hidden {
  display: none;
}

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.account-email {
  color: var(--text-muted);
  font-size: 0.8rem;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .account-email {
    display: none;
  }
}
