/*
 * BIWLS Native H5 — mobile-first shell (isolated TEST contour).
 *
 * No third-party fonts, no external map/upload endpoints, no keys: the shell must
 * stay deployable without any legacy integration from the reference client.
 */

:root {
  --bg: #0b1220;
  --surface: #131c2e;
  --surface-2: #1b2740;
  --line: #26344f;
  --text: #e8eefc;
  --muted: #93a4c4;
  --accent: #35e07a;
  --accent-ink: #052613;
  --warn: #ffc94d;
  --radius: 16px;
  --frame: 430px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: #05080f;
  color: var(--text);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Phone-shaped frame: on a desktop viewport the app stays a centered column
   instead of stretching, which is how the reference H5 behaves. */
.device {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--frame);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

@media (min-width: 720px) {
  body { background: radial-gradient(1200px 700px at 50% -10%, #16233c, #05080f 70%); padding: 24px 0; }
  .device {
    min-height: calc(100vh - 48px);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
  }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--bg));
}

.brand { display: flex; align-items: baseline; gap: 8px; margin-right: auto; }
.brand__mark { font-weight: 800; letter-spacing: .14em; font-size: 1.05rem; }
.brand__sub { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }

.env {
  padding: 3px 9px;
  border: 1px solid rgba(255, 201, 77, .5);
  border-radius: 999px;
  color: var(--warn);
  font: 700 .68rem/1 ui-sans-serif, system-ui;
  letter-spacing: .12em;
}

.iconbtn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.views { flex: 1; display: flex; }
.view { display: none; flex: 1; flex-direction: column; padding: 16px; gap: 10px; }
.view.is-active { display: flex; }
.view__title { margin: 0; font-size: 1.25rem; }
.view__lead { margin: 0; color: var(--muted); font-size: .9rem; }

#view-map.is-active { padding: 0; gap: 0; }

/* Map placeholder: neutral, no tiles, no provider keys. */
.map { position: relative; flex: 1; min-height: 46vh; background: #0e1728; overflow: hidden; }
.map__grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: .35;
}
.map__zone {
  position: absolute; left: 12%; top: 22%;
  width: 62%; height: 44%;
  border: 1px dashed rgba(53, 224, 122, .55);
  border-radius: 42% 58% 55% 45% / 52% 46% 54% 48%;
  background: rgba(53, 224, 122, .07);
}
.map__me {
  position: absolute; left: 46%; top: 54%;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #4da3ff;
  box-shadow: 0 0 0 6px rgba(77, 163, 255, .22);
}

.sheet {
  margin: -18px 12px 12px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 -12px 30px rgba(0, 0, 0, .35);
}
.sheet__handle { width: 42px; height: 4px; margin: 0 auto 12px; border-radius: 999px; background: var(--line); }
.sheet__title { margin: 0 0 4px; font-size: 1.15rem; }
.sheet__text { margin: 0 0 14px; color: var(--muted); font-size: .88rem; }

.cta {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 15px 18px;
  border: 0; border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700; font-size: 1rem;
  cursor: pointer;
}
.cta svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.cta:disabled { opacity: .45; cursor: not-allowed; }
.cta--secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.cta--compact { width: auto; padding: 12px 18px; font-size: .92rem; }

.ghost {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.ghost:disabled { opacity: .45; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .74rem;
}
.chip--ok { color: var(--accent); border-color: rgba(53, 224, 122, .45); }
.chip--bad { color: #ff8080; border-color: rgba(255, 128, 128, .45); }
.chip--pay { color: var(--warn); border-color: rgba(255, 201, 77, .45); }

.card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card__title { margin: 0 0 6px; font-size: .98rem; }
.card__text { margin: 0; color: var(--muted); font-size: .86rem; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: .82em; }

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  padding: 13px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
}
.tab.is-active { color: var(--text); box-shadow: inset 0 2px 0 var(--accent); }

.modal {
  position: fixed; inset: 0;
  display: grid; place-items: end center;
  background: rgba(3, 6, 12, .68);
  z-index: 20;
}
.modal[hidden] { display: none; }
.modal__panel {
  position: relative;
  width: 100%;
  max-width: var(--frame);
  padding: 20px 18px 24px;
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: var(--surface);
}
@media (min-width: 720px) {
  .modal { place-items: center; padding: 24px; }
  .modal__panel { border-radius: 22px; border-bottom: 1px solid var(--line); }
}
.modal__title { margin: 0 0 14px; font-size: 1.15rem; }
.modal__close {
  position: absolute; right: 14px; top: 10px;
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs__item {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.tabs__item.is-active { background: var(--surface-2); color: var(--text); border-color: rgba(53, 224, 122, .4); }

.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: block; }
.field__label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .78rem; }
.field__row { display: flex; gap: 8px; }
.prefix {
  display: grid; place-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.input {
  flex: 1;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
}
.input:disabled { opacity: .6; }
.form__row { display: flex; gap: 10px; justify-content: space-between; }

.summary { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.summary__row {
  display: flex; justify-content: space-between; gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
  font-size: .9rem;
}
.summary__row span { color: var(--muted); }

.notice { margin: 12px 0 0; color: var(--muted); font-size: .78rem; }

#payment-widget-mount:not([hidden]) {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  min-height: 60px;
}

.toast {
  position: fixed;
  left: 50%; bottom: 84px;
  transform: translateX(-50%);
  max-width: min(92vw, var(--frame));
  margin: 0;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .84rem;
  z-index: 30;
}

.map__note {
  position: absolute; left: 16px; right: 16px; top: 16px;
  margin: 0;
  color: var(--muted);
  font-size: .78rem;

/* --- Payment state machine (C.3-PREP). --- */
.pay-state {
  margin: 10px 0 0;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .78rem;
}

.pay-state::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.pay-state[data-state='widget_ready']::before,
.pay-state[data-state='awaiting_user']::before { background: var(--warn); }

.pay-state[data-state='succeeded']::before { background: var(--accent); }

.pay-state[data-state='failed']::before,
.pay-state[data-state='indeterminate']::before,
.pay-state[data-state='cancelled']::before { background: #ff7a7a; }

.test-marker {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: 10px;
  color: var(--muted);
  font-size: .76rem;
}

}
