:root {
  --bg: 248 250 252;
  --card: 255 255 255;
  --border: 226 232 240;
  --text: 15 23 42;
  --muted: 100 116 139;
  --primary: 15 23 42;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { -webkit-tap-highlight-color: transparent; }
html { color-scheme: light; }
body {
  min-height: 100vh;
  margin: 0;
  background: rgb(var(--bg));
  color: rgb(var(--text));
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }

.bt-shell {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  margin: 0 auto;
  background: rgb(var(--bg));
  position: relative;
}

.bt-page {
  padding: 1rem 1rem calc(6.5rem + var(--safe-bottom));
}

.bt-page.no-nav {
  padding-bottom: 1.5rem;
}

.bt-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  min-height: 4rem;
  gap: .75rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid rgba(226,232,240,.92);
  background: rgba(255,255,255,.93);
  backdrop-filter: blur(16px);
}

.bt-title-wrap {
  min-width: 0;
  flex: 1;
}

.bt-title {
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -.02em;
  color: rgb(15 23 42);
}

.bt-subtitle {
  margin-top: .1rem;
  font-size: .72rem;
  color: rgb(100 116 139);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bt-card {
  border: 1px solid rgb(var(--border));
  border-radius: 1rem;
  background: rgb(var(--card));
  box-shadow: 0 1px 2px rgba(15,23,42,.025);
}

.bt-soft {
  background: rgb(248 250 252);
  border: 1px solid rgb(241 245 249);
  border-radius: .875rem;
}

.bt-icon-btn {
  display: inline-grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgb(226 232 240);
  border-radius: .8rem;
  background: white;
  color: rgb(71 85 105);
  transition: transform .12s ease, background-color .12s ease;
}

.bt-icon-btn:active { transform: scale(.97); background: rgb(248 250 252); }

.bt-btn {
  display: inline-flex;
  min-height: 3.25rem;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  border-radius: .9rem;
  padding: .8rem 1rem;
  font-size: .9rem;
  font-weight: 650;
  transition: transform .12s ease, background-color .12s ease, box-shadow .12s ease;
}

.bt-btn:active { transform: scale(.985); }

.bt-btn-primary {
  background: rgb(15 23 42);
  color: white;
  box-shadow: 0 6px 14px rgba(15,23,42,.12);
}

.bt-btn-primary:active { background: rgb(30 41 59); }

.bt-btn-secondary {
  background: white;
  color: rgb(30 41 59);
  border: 1px solid rgb(203 213 225);
}

.bt-btn-danger {
  background: rgb(127 29 29);
  color: white;
}

.bt-input {
  width: 100%;
  min-height: 3rem;
  border: 1px solid rgb(203 213 225);
  border-radius: .82rem;
  padding: .72rem .85rem;
  outline: none;
  background: white;
  color: rgb(15 23 42);
  box-shadow: 0 1px 2px rgba(15,23,42,.02);
}

.bt-input:focus {
  border-color: rgb(100 116 139);
  box-shadow: 0 0 0 3px rgba(148,163,184,.16);
}

.bt-label {
  display: block;
  margin-bottom: .4rem;
  font-size: .78rem;
  font-weight: 600;
  color: rgb(71 85 105);
}

.bt-section-title {
  font-size: .84rem;
  font-weight: 650;
  color: rgb(30 41 59);
  letter-spacing: -.01em;
}

.bt-section-copy {
  margin-top: .2rem;
  font-size: .75rem;
  line-height: 1.45;
  color: rgb(100 116 139);
}

.bt-bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 40;
  width: min(430px, 100%);
  transform: translateX(-50%);
  border-top: 1px solid rgba(226,232,240,.95);
  background: rgba(255,255,255,.96);
  padding: .5rem .65rem calc(.5rem + var(--safe-bottom));
  backdrop-filter: blur(18px);
  box-shadow: 0 -12px 32px rgba(15,23,42,.04);
}

.bt-bottom-nav-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .3rem;
}

.bt-nav-item {
  position: relative;
  display: flex;
  min-height: 3.45rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  border-radius: .85rem;
  color: rgb(100 116 139);
  font-size: .65rem;
  font-weight: 600;
}

.bt-nav-item-active {
  background: rgb(241 245 249);
  color: rgb(15 23 42);
}

.bt-nav-badge {
  position: absolute;
  top: .15rem;
  right: 24%;
  min-width: 1.05rem;
  border-radius: 999px;
  background: rgb(225 29 72);
  color: white;
  padding: .08rem .28rem;
  font-size: .56rem;
  line-height: 1rem;
  text-align: center;
  font-weight: 700;
}

.bt-chip {
  display: inline-flex;
  min-height: 1.8rem;
  align-items: center;
  gap: .3rem;
  border-radius: 999px;
  padding: .3rem .58rem;
  font-size: .68rem;
  font-weight: 650;
  box-shadow: inset 0 0 0 1px rgba(100,116,139,.12);
}

.bt-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: .75rem;
}

.bt-action-card {
  display: flex;
  min-height: 7.5rem;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid rgb(226 232 240);
  border-radius: 1rem;
  background: white;
  padding: 1rem;
  text-align: left;
  transition: transform .12s ease, border-color .12s ease;
}

.bt-action-card:active { transform: scale(.985); border-color: rgb(148 163 184); }

.bt-action-icon {
  display: grid;
  width: 2.6rem;
  height: 2.6rem;
  place-items: center;
  border-radius: .82rem;
  background: rgb(241 245 249);
  color: rgb(30 41 59);
}

.bt-camera {
  position: relative;
  overflow: hidden;
  min-height: 21rem;
  border-radius: 1.2rem;
  background:
    radial-gradient(circle at 50% 38%, rgba(255,255,255,.06), transparent 38%),
    linear-gradient(145deg, rgb(30 41 59), rgb(2 6 23));
}

.bt-camera::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 28px 28px;
}

.bt-scan-frame {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 78%;
  height: 8.5rem;
  transform: translate(-50%,-50%);
  border: 2px solid rgba(255,255,255,.8);
  border-radius: 1rem;
}

.bt-scan-frame::before,
.bt-scan-frame::after {
  content: "";
  position: absolute;
  left: 8%;
  width: 84%;
  height: 2px;
  background: rgba(255,255,255,.78);
}

.bt-scan-frame::before { top: 32%; }
.bt-scan-frame::after { top: 68%; }

.bt-camera-copy {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 2;
  text-align: center;
  color: rgba(255,255,255,.85);
  font-size: .75rem;
}

.bt-list-row {
  display: flex;
  align-items: center;
  gap: .8rem;
  min-height: 4.5rem;
  padding: .9rem 1rem;
  border-bottom: 1px solid rgb(241 245 249);
}

.bt-list-row:last-child { border-bottom: 0; }

.bt-list-icon {
  display: grid;
  width: 2.55rem;
  height: 2.55rem;
  place-items: center;
  flex: 0 0 auto;
  border-radius: .8rem;
  background: rgb(248 250 252);
  color: rgb(71 85 105);
}

.bt-sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 80;
  width: min(430px,100%);
  transform: translateX(-50%);
  border: 1px solid rgb(226 232 240);
  border-bottom: 0;
  border-radius: 1.3rem 1.3rem 0 0;
  background: white;
  padding: 1rem 1rem calc(1rem + var(--safe-bottom));
  box-shadow: 0 -20px 50px rgba(15,23,42,.18);
  animation: bt-sheet-in .18s ease-out;
}

.bt-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15,23,42,.34);
  backdrop-filter: blur(2px);
}

@keyframes bt-sheet-in {
  from { transform: translate(-50%, 20px); opacity: .4; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.bt-toast {
  position: fixed;
  left: 50%;
  bottom: calc(6.3rem + var(--safe-bottom));
  z-index: 90;
  width: min(390px, calc(100% - 2rem));
  transform: translateX(-50%);
  border-radius: .9rem;
  background: rgb(15 23 42);
  color: white;
  padding: .85rem 1rem;
  font-size: .78rem;
  box-shadow: 0 15px 35px rgba(15,23,42,.18);
  animation: bt-toast-in .18s ease-out;
}

@keyframes bt-toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.bt-signature {
  width: 100%;
  height: 10rem;
  border: 1px dashed rgb(148 163 184);
  border-radius: .9rem;
  background: rgb(248 250 252);
  touch-action: none;
}

.bt-segmented {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: .35rem;
  padding: .3rem;
  border: 1px solid rgb(226 232 240);
  border-radius: .9rem;
  background: rgb(248 250 252);
}

.bt-segmented button {
  min-height: 2.45rem;
  border-radius: .65rem;
  font-size: .72rem;
  font-weight: 600;
  color: rgb(100 116 139);
}

.bt-segmented button.active {
  background: white;
  color: rgb(15 23 42);
  box-shadow: 0 1px 4px rgba(15,23,42,.08);
}

@media (min-width: 431px) {
  body {
    background:
      radial-gradient(circle at 50% -10%, rgba(226,232,240,.7), transparent 28rem),
      rgb(241 245 249);
  }
  .bt-shell {
    box-shadow: 0 0 0 1px rgba(226,232,240,.85), 0 20px 60px rgba(15,23,42,.08);
  }
}

/* NEW: Leaflet/OpenStreetMap route preview */
#btLeafletRouteMap {
  z-index: 0;
  background: rgb(226 232 240);
}

.bt-osm-marker {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 5px 14px rgba(15,23,42,.28);
}

.bt-osm-marker.is-complete {
  background: #059669;
}

.leaflet-popup-content-wrapper {
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15,23,42,.16);
}

.leaflet-control-zoom {
  border: 0 !important;
  box-shadow: 0 4px 12px rgba(15,23,42,.12) !important;
}

.leaflet-control-zoom a {
  border: 0 !important;
  color: #0f172a !important;
}

/* NEW: Indowines App profile menu */
.bt-profile-wrap {
  position: relative;
  flex: 0 0 auto;
}

.bt-profile-button {
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border-radius: .85rem;
  transition: background-color .12s ease, transform .12s ease;
}

.bt-profile-button:active {
  transform: scale(.97);
}

.bt-profile-button:hover {
  background: rgb(248 250 252);
}

.bt-profile-avatar {
  display: grid;
  width: 2.15rem;
  height: 2.15rem;
  place-items: center;
  border-radius: 999px;
  background: rgb(15 23 42);
  color: white;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .02em;
}

.bt-profile-avatar-large {
  width: 2.8rem;
  height: 2.8rem;
  font-size: .78rem;
}

.bt-profile-avatar-sheet {
  width: 3.2rem;
  height: 3.2rem;
  font-size: .85rem;
}

.bt-profile-dropdown {
  position: absolute;
  top: calc(100% + .55rem);
  right: 0;
  z-index: 70;
  width: min(18rem, calc(100vw - 2rem));
  overflow: hidden;
  border: 1px solid rgb(226 232 240);
  border-radius: .95rem;
  background: white;
  box-shadow: 0 18px 45px rgba(15,23,42,.17);
}

.bt-profile-dropdown-head {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 1rem;
}

.bt-profile-menu-item {
  display: flex;
  width: 100%;
  min-height: 2.75rem;
  align-items: center;
  gap: .65rem;
  border-radius: .65rem;
  padding: .65rem .75rem;
  color: rgb(51 65 85);
  font-size: .82rem;
  font-weight: 600;
  text-align: left;
}

.bt-profile-menu-item:hover {
  background: rgb(248 250 252);
}

.bt-profile-menu-item-danger {
  color: rgb(190 18 60);
}

.bt-profile-menu-item-danger:hover {
  background: rgb(255 241 242);
}

/* NEW: real camera preview enhancement */
.bt-camera-video {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: rgb(2 6 23);
}

.bt-camera .bt-scan-frame {
  z-index: 3;
}

.bt-camera .bt-camera-copy {
  z-index: 4;
}

.bt-camera-status {
  position: absolute;
  left: .8rem;
  top: .8rem;
  z-index: 5;
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  gap: .4rem;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: rgba(15,23,42,.72);
  padding: .35rem .6rem;
  color: rgba(255,255,255,.88);
  font-size: .67rem;
  font-weight: 650;
  backdrop-filter: blur(10px);
}

.bt-camera-status-live {
  background: rgba(6,78,59,.82);
  color: rgb(209 250 229);
}

.bt-camera-status-loading {
  background: rgba(30,41,59,.82);
}

.bt-camera-status-error {
  background: rgba(127,29,29,.86);
  color: rgb(255 228 230);
}

.bt-camera-mode-note {
  display: flex;
  min-height: 3.25rem;
  align-items: center;
  gap: .55rem;
  border: 1px solid rgb(226 232 240);
  border-radius: .9rem;
  background: rgb(248 250 252);
  padding: .7rem .8rem;
  color: rgb(100 116 139);
  font-size: .68rem;
  line-height: 1.35;
}

@media (max-width: 360px) {
  .bt-camera-mode-note {
    font-size: .62rem;
  }
}
