:root {
 --bg: #f3f7f8;
 --bg-elev: #ffffff;
 --ink: #082E6E;
 --ink-muted: #5a6f8a;
 --line: #d5e0e8;
 --accent: #0A9FA8;
 --accent-deep: #087f86;
 --warn: #b45309;
 --danger: #9b2c2c;
 --ok: #0A9FA8;
 --shadow: 0 10px 30px rgba(8, 46, 110, 0.08);
 --radius: 16px;
 --safe-b: env(safe-area-inset-bottom, 0px);
 --tab-h: 64px;
 --font: "DM Sans", system-ui, sans-serif;
 --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body {
 margin: 0;
 min-height: 100%;
 background:
 radial-gradient(1200px 600px at 10% -10%, #d9f4f6 0%, transparent 55%),
 radial-gradient(900px 500px at 100% 0%, #e4ecf7 0%, transparent 50%),
 var(--bg);
 color: var(--ink);
 font-family: var(--font);
 font-size: 16px;
 line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-deep); }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  /* Keep content clear of fixed tab bar */
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 28px);
}
#app.shell-off {
  padding-bottom: max(16px, var(--safe-b));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(243, 247, 248, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand-lockup {
 display: flex;
 align-items: center;
 justify-content: center;
 gap: 10px;
 min-width: 0;
 cursor: pointer;
}
.brand-mark {
 width: 40px;
 height: 40px;
 display: block;
 flex-shrink: 0;
 border-radius: 10px;
 background: #fff;
}
.brand-name {
 font-family: var(--display);
 font-weight: 700;
 letter-spacing: -0.02em;
 font-size: 1.05rem;
}
.icon-btn {
 width: 44px; height: 44px; border: 0; border-radius: 12px;
 background: transparent;
}
.icon-btn:hover { background: rgba(26,46,36,0.06); }

.view {
  padding: 16px 16px calc(28px + var(--tab-h) * 0.15);
  min-height: 0;
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 8px 8px calc(8px + var(--safe-b));
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  z-index: 30;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar {
  display: none;
}
.tabbar[hidden] {
  display: none !important;
}

.hero-title {
 font-family: var(--display);
 font-size: clamp(1.8rem, 5vw, 2.25rem);
 line-height: 1.15;
 letter-spacing: -0.03em;
 margin: 8px 0 10px;
}
.lede { color: var(--ink-muted); margin: 0 0 20px; }

.card {
 background: var(--bg-elev);
 border: 1px solid var(--line);
 border-radius: var(--radius);
 padding: 16px;
 box-shadow: var(--shadow);
 margin-bottom: 12px;
}
.card h2, .card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.muted { color: var(--ink-muted); font-size: 0.92rem; }
.row {
 display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.stack { display: grid; gap: 10px; }

.btn {
 display: inline-flex; align-items: center; justify-content: center; gap: 8px;
 border: 0; border-radius: 999px;
 padding: 12px 18px;
 background: var(--accent);
 color: #fff;
 font-weight: 600;
 text-decoration: none;
}
.btn:hover { background: var(--accent-deep); }
.btn-block { width: 100%; }
.btn-ghost {
 background: transparent;
 color: var(--ink);
 border: 1px solid var(--line);
}
.btn-ghost:hover { background: rgba(26,46,36,0.04); }
.btn-danger { background: var(--danger); }
.btn-warn { background: var(--warn); }
.btn-sm { padding: 8px 12px; font-size: 0.88rem; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 0.85rem; font-weight: 600; }
.field input, .field select, .field textarea {
 width: 100%;
 border: 1px solid var(--line);
 border-radius: 12px;
 padding: 12px 14px;
 background: #fff;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
 border: 1px solid var(--line);
 background: #fff;
 border-radius: 999px;
 padding: 8px 14px;
 font-weight: 500;
}
.chip.active {
 background: var(--ink);
 color: #fff;
 border-color: var(--ink);
}

.pill {
 display: inline-flex; align-items: center;
 border-radius: 999px;
 padding: 4px 10px;
 font-size: 0.78rem;
 font-weight: 600;
 background: #e5efe8;
 color: var(--accent-deep);
}
.pill.warn { background: #f5e6d3; color: var(--warn); }

.line-item {
 display: grid;
 grid-template-columns: 1fr auto;
 gap: 8px 12px;
 padding: 12px 0;
 border-bottom: 1px solid var(--line);
}
.line-item:last-child { border-bottom: 0; }
.qty-ctrl { display: flex; align-items: center; gap: 8px; }
.qty-ctrl button {
 width: 32px; height: 32px; border-radius: 10px;
 border: 1px solid var(--line); background: #fff;
}
.actions { display: flex; flex-wrap: wrap; gap: 6px; grid-column: 1 / -1; }

.tab {
 border: 0;
 background: transparent;
 padding: 10px 12px;
 font-size: 0.75rem;
 font-weight: 600;
 color: var(--ink-muted);
 border-radius: 12px;
 flex: 1 0 auto;
 min-width: 4.6rem;
 scroll-snap-align: center;
 white-space: nowrap;
}
.tab.active { color: var(--accent-deep); background: #e7f6f7; }
.tab-scan {
 background: var(--ink);
 color: #fff !important;
 border-radius: 14px;
 min-width: 5rem;
}
.tab-scan.active { background: var(--accent-deep); color: #fff !important; }

.view.swipe-hint {
 touch-action: pan-y;
}

.toast {
 position: fixed;
 left: 50%;
 bottom: calc(var(--tab-h) + var(--safe-b) + 16px);
 transform: translateX(-50%);
 background: var(--ink);
 color: #fff;
 padding: 12px 16px;
 border-radius: 12px;
 z-index: 50;
 max-width: min(420px, calc(100% - 24px));
 box-shadow: var(--shadow);
}

.back-to-top {
 position: fixed;
 right: max(16px, calc(50% - 240px + 16px));
 bottom: calc(var(--tab-h) + var(--safe-b) + 18px);
 z-index: 40;
 width: 44px;
 height: 44px;
 border: 0;
 border-radius: 14px;
 background: var(--ink);
 color: #fff;
 font-size: 1.15rem;
 font-weight: 700;
 line-height: 1;
 box-shadow: var(--shadow);
 opacity: 0;
 pointer-events: none;
 transform: translateY(8px);
 transition: opacity 0.18s ease, transform 0.18s ease;
}
.back-to-top.is-visible {
 opacity: 1;
 pointer-events: auto;
 transform: translateY(0);
}
.back-to-top:hover { background: var(--accent-deep); }
#app.shell-off ~ .back-to-top,
body.ops-body .back-to-top {
 bottom: calc(18px + var(--safe-b));
}

.scan-stage {
 border: 2px dashed var(--line);
 border-radius: var(--radius);
 padding: 28px 16px;
 text-align: center;
 background: #fff;
}
.scan-stage code {
 display: inline-block;
 margin-top: 8px;
 padding: 6px 10px;
 background: #f3efe6;
 border-radius: 8px;
 font-size: 0.85rem;
}

.price {
 font-family: var(--display);
 font-size: 1.6rem;
 font-weight: 700;
}
.kpi {
 display: grid;
 grid-template-columns: 1fr 1fr;
 gap: 10px;
}
.kpi .card { margin: 0; padding: 14px; }
.kpi .label { font-size: 0.78rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .value { font-family: var(--display); font-size: 1.35rem; font-weight: 700; margin-top: 4px; }

.pay-fake {
 border: 1px solid var(--line);
 border-radius: 14px;
 padding: 14px;
 background: linear-gradient(180deg, #fff, #f7f4ee);
}
.pay-fake .brand-row {
 display: flex; justify-content: space-between; align-items: center;
 margin-bottom: 12px; font-size: 0.85rem; color: var(--ink-muted);
}

.entry {
 padding-bottom: 8px;
}
.offer-banner {
 display: grid;
 gap: 4px;
 margin: 0 0 14px;
 padding: 12px 14px;
 border-radius: 14px;
 background: linear-gradient(135deg, #e7f6f7, #eef6fb);
 border: 1px solid rgba(10, 159, 168, 0.35);
 color: var(--ink);
}
.offer-banner strong {
 font-size: 0.95rem;
}
.offer-banner span,
.offer-banner-slim span {
 color: var(--ink-muted);
 font-size: 0.92rem;
}
.offer-banner-slim {
 margin-bottom: 12px;
}
.play-banner {
 display: flex;
 align-items: center;
 justify-content: space-between;
 gap: 12px;
 margin: 0 0 14px;
 padding: 12px 14px;
 border-radius: 14px;
 background: #fff7e8;
 border: 1px solid rgba(180, 83, 9, 0.28);
}
.plan-tease {
 margin-bottom: 0;
}
.check-row {
 display: flex;
 align-items: flex-start;
 gap: 10px;
 font-size: 0.92rem;
 color: var(--ink-muted);
 margin: 4px 0 0;
}
.check-row input {
 margin-top: 3px;
 flex-shrink: 0;
}

.splash {
 min-height: calc(100dvh - 32px);
 display: flex;
 flex-direction: column;
 justify-content: flex-start;
 gap: 20px;
 padding: 28px 8px 12px;
 box-sizing: border-box;
}
.splash-brand {
 display: flex;
 align-items: center;
 gap: 14px;
 flex-shrink: 0;
 margin: 12px 0 8px 4px;
 padding: 12px 14px;
 background: rgba(255, 255, 255, 0.92);
 border: 1px solid var(--line);
 border-radius: 16px;
 box-shadow: var(--shadow);
}
.splash .logo-mark-lg {
 width: 72px;
 height: 72px;
 display: block;
 flex-shrink: 0;
 border-radius: 16px;
}
.splash-wordmark-wrap {
 display: grid;
 gap: 2px;
 min-width: 0;
}
.splash .logo-wordmark {
 width: min(280px, 58vw);
 height: auto;
 display: block;
}
.splash-name {
 font-family: var(--display);
 font-weight: 700;
 font-size: clamp(1.35rem, 5vw, 1.75rem);
 letter-spacing: -0.03em;
 color: var(--ink);
 line-height: 1.1;
}
/* If SVG wordmark fails to paint text, HTML name still shows the brand */
.splash .logo-wordmark[src] + .splash-name {
 display: block;
}
.splash-copy {
 margin-top: auto;
 padding-bottom: 4px;
}

.plan-grid {
 display: grid;
 gap: 10px;
}
.plan-combo-summary {
 display: flex;
 justify-content: space-between;
 gap: 12px;
 align-items: flex-start;
 padding: 12px 14px;
 margin-bottom: 10px;
 border-radius: 14px;
 border: 1px solid var(--line);
 background: #f7faf8;
}
.plan-combo-summary.is-combo {
 border-color: var(--accent);
 background: #eefafb;
}
.plan-card {
 text-align: left;
 border: 1px solid var(--line);
 background: #fff;
 border-radius: 14px;
 padding: 14px;
 cursor: pointer;
}
.plan-card:hover { border-color: #a8bdb0; }
.plan-card.active {
 border-color: var(--accent);
 box-shadow: inset 0 0 0 1px var(--accent);
 background: #eefafb;
}
.plan-card-top {
 display: flex;
 justify-content: space-between;
 align-items: baseline;
 gap: 8px;
 margin-bottom: 4px;
}
.plan-card-top .price {
 font-size: 1.25rem;
}
.btn:disabled {
 cursor: not-allowed;
}

.plan-compact {
 display: flex;
 align-items: center;
 justify-content: space-between;
 gap: 12px;
}
.plan-compact-value {
 font-family: var(--display);
 font-weight: 700;
 font-size: 1.15rem;
 margin-top: 2px;
}

.sheet-root {
 position: fixed;
 inset: 0;
 z-index: 80;
 display: flex;
 align-items: flex-end;
 justify-content: center;
}
.sheet-backdrop {
 position: absolute;
 inset: 0;
 border: 0;
 background: rgba(26, 46, 36, 0.45);
 cursor: pointer;
}
.sheet-panel {
 position: relative;
 width: min(480px, 100%);
 max-height: min(78dvh, 560px);
 overflow: auto;
 background: var(--bg-elev);
 border-radius: 20px 20px 0 0;
 padding: 10px 16px calc(20px + var(--safe-b));
 box-shadow: 0 -12px 40px rgba(0,0,0,0.18);
 animation: sheetUp 0.22s ease-out;
}
.sheet-handle {
 width: 40px;
 height: 4px;
 border-radius: 999px;
 background: var(--line);
 margin: 4px auto 14px;
}
.plan-sheet-list { display: grid; gap: 8px; }
.plan-sheet-option {
 display: flex;
 justify-content: space-between;
 align-items: center;
 gap: 12px;
 width: 100%;
 text-align: left;
 border: 1px solid var(--line);
 background: #fff;
 border-radius: 14px;
 padding: 14px;
}
.plan-sheet-option.active {
 border-color: var(--accent);
 background: #f3faf5;
 box-shadow: inset 0 0 0 1px var(--accent);
}
@keyframes sheetUp {
 from { transform: translateY(24px); opacity: 0.6; }
 to { transform: translateY(0); opacity: 1; }
}

.line-item.line-muted { opacity: 0.72; }
.line-item.line-dropped {
 background: #f7f1e8;
 margin: 8px -8px 0;
 padding: 12px 8px;
 border-radius: 12px;
 border-bottom: 0;
}
.dropped-block h3 { font-size: 1rem; }


@media (min-width: 900px) {
  body { padding: 24px 0; }
  #app {
    border: 1px solid var(--line);
    border-radius: 24px;
    /* Clip radius without killing scroll — scroll the view pane instead */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 48px);
    min-height: calc(100dvh - 48px);
    max-height: calc(100dvh - 48px);
    padding-bottom: 0;
    box-shadow: var(--shadow);
    background: rgba(255, 253, 248, 0.55);
  }
  #app.shell-off {
    padding-bottom: 0;
  }
  #app.shell-off .splash {
    min-height: calc(100dvh - 48px - 32px);
  }
  #app .topbar {
    flex: 0 0 auto;
  }
  #app .view {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px 20px calc(var(--tab-h) + var(--safe-b) + 28px);
  }
  #app.shell-off .view {
    padding-bottom: 28px;
  }
  #app .tabbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    transform: none;
    border-radius: 0 0 24px 24px;
  }
}
