/* ━━━━━━━━━━━━━━━━━━━━━━━━ TOKENS ━━━━━━━━━━━━━━━━━━━━━━━━ */
:root {
  --brand:      #f0b323;
  --brand-dark: #d49a10;
  --brand-glow: rgba(240,179,35,0.35);

  --green:      #34C759; --green-bg: #E8F8ED; --green-txt: #176B2E;
  --yellow:     #FF9500; --yellow-bg:#FFF3E0; --yellow-txt:#7A4800;
  --orange:     #FF6B35; --orange-bg:#FFF0EB; --orange-txt:#7A3200;
  --red:        #FF3B30; --red-bg:  #FFEBEA; --red-txt:   #96001A;

  --bg:   #F2F2F7;
  --card: #FFFFFF;
  --ink:  #1C1C1E;
  --sub:  #3A3A3C;
  --mute: #8E8E93;
  --sep:  rgba(60,60,67,.12);

  --r-sm: 14px; --r-md: 18px; --r-lg: 22px;

  --sh-xs: 0 1px 4px rgba(0,0,0,.08);
  --sh-sm: 0 2px 14px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.06);
  --sh-md: 0 6px 28px rgba(0,0,0,.13), 0 2px 8px rgba(0,0,0,.07);
  --sh-up: 0 -2px 24px rgba(0,0,0,.14);

  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --ease-out:    cubic-bezier(.25,.46,.45,.94);
  --ease-in-out: cubic-bezier(.4,0,.2,1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  --tab-h: 64px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ RESET ━━━━━━━━━━━━━━━━━━━━━━━━━ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; background: #111;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img, div, .gm-style, .gm-style * {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ FRAME ━━━━━━━━━━━━━━━━━━━━━━━━━ */
.frame {
  position: relative;
  width: 100%; max-width: 390px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}
@media (max-width: 420px) { .frame { max-width: none; } }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ MAP ━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
#map { width: 100%; height: 100%; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ SEARCH ━━━━━━━━━━━━━━━━━━━━━━━━ */
.search-wrap {
  position: absolute;
  top: 16px; left: 0; right: 0;
  display: flex; justify-content: center;
  z-index: 50;
  will-change: transform, opacity;
  transition: transform .32s var(--ease-out), opacity .32s var(--ease-out);
}
.search-wrap.hidden { transform: translateY(-70px); opacity: 0; pointer-events: none; }

.search-input {
  width: 84%; max-width: 320px;
  padding: 13px 20px;
  border-radius: 999px; border: none;
  font-size: 15px; font-family: var(--font); font-weight: 500;
  background: rgba(255,255,255,.97);
  box-shadow: var(--sh-md);
  text-align: center; color: var(--ink); outline: none;
  transition: box-shadow .2s;
}
.search-input:focus { box-shadow: 0 0 0 3px rgba(240,179,35,.4), var(--sh-md); }
.search-input::placeholder { color: var(--mute); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ MAP CONTROLS ━━━━━━━━━━━━━━━━━━ */
.map-ctrls {
  position: absolute;
  right: 14px; bottom: 140px;
  display: flex; flex-direction: column; gap: 0;
  border-radius: 999px; overflow: hidden;
  box-shadow: var(--sh-md);
  z-index: 60;
  will-change: transform;
}
.mc-btn {
  width: 46px; height: 46px;
  background: rgba(255,255,255,.97);
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
  border-bottom: .5px solid var(--sep);
  transition: background .15s, transform .12s;
}
.mc-btn:last-child { border-bottom: none; }
.mc-btn:active { transform: scale(.9); background: #E5E5EA; }
.mc-btn i { font-size: 20px; pointer-events: none; color: var(--ink); }
.mc-btn.gps i, .mc-btn.live i { color: #007AFF; }
.mc-btn.live.on i { animation: liveDotPulse 1.4s ease-in-out infinite; }
.mc-btn.gps.loading i {
  animation: gpsLoadingPulse 1s ease-in-out infinite;
}
@keyframes gpsLoadingPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(.82); }
}
.mc-btn.sat-on, .mc-btn.active, .mc-btn.on { background: #007AFF; }
.mc-btn.sat-on i, .mc-btn.active i, .mc-btn.on i { color: #fff !important; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ ZOOM CONTROLS (live only) ━━━━━━━━━━━━━━━━━━ */
.zoom-ctrls {
  position: absolute;
  left: 14px; bottom: 140px;
  display: flex; flex-direction: column; gap: 0;
  border-radius: 28px; overflow: hidden;
  box-shadow: var(--sh-md);
  z-index: 60;
  opacity: 0;
  transform: translateX(-12px) scale(.9);
  pointer-events: none;
  transition: opacity .25s var(--ease-out), transform .28s var(--ease-spring);
}
.zoom-ctrls.visible {
  opacity: 1;
  transform: translateX(0) scale(1);
  pointer-events: auto;
}
.zc-btn {
  width: 56px; height: 56px;
  background: rgba(255,255,255,.97);
  display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer;
  border-bottom: .5px solid var(--sep);
  transition: background .15s, transform .12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.zc-btn:last-child { border-bottom: none; }
.zc-btn:active { transform: scale(.9); background: #E5E5EA; }
.zc-btn i { font-size: 26px; pointer-events: none; color: var(--ink); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ LIVE PULSE ━━━━━━━━━━━━━━━━━━ */
@keyframes liveDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .35; transform: scale(1.45); }
}

/* Pulsring runt GPS-prick när live mode är på */
.gps-live-pulse {
  width: 16px; height: 16px; border-radius: 50%;
  background: #4285F4;
  border: 3px solid #fff;
  box-shadow: 0 0 6px rgba(66,133,244,.6);
  position: relative;
}
.gps-live-pulse::before {
  content: '';
  position: absolute; inset: -6px;
  border-radius: 50%;
  background: rgba(66,133,244,.35);
  animation: gpsPulse 1.8s ease-out infinite;
}
@keyframes gpsPulse {
  0%   { transform: scale(.6); opacity: .8; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ KPI STRIP ━━━━━━━━━━━━━━━━━━━━━ */
.kpi-strip {
  position: absolute;
  left: 12px; right: 12px; bottom: 76px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-radius: var(--r-md);
  padding: 10px 4px;
  display: flex; align-items: center; justify-content: space-around;
  box-shadow: var(--sh-sm);
  z-index: 55;
  will-change: transform, opacity;
  transition: transform .28s var(--ease-out), opacity .28s;
}
.kpi-strip.hidden { transform: translateY(20px); opacity: 0; pointer-events: none; }

.kpi { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1; }
.kpi-tap { cursor: pointer; border-radius: 12px; transition: transform .12s var(--ease-spring); }
.kpi-tap:active { transform: scale(.92); }
.kpi-dot { width: 8px; height: 8px; border-radius: 50%; }
.kpi-num {
  font-size: 18px; font-weight: 800; color: var(--ink);
  line-height: 1; letter-spacing: -.6px;
  transition: transform .2s var(--ease-spring);
}
.kpi-num.bump { transform: scale(1.4); }
.kpi-lbl { font-size: 9px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .3px; }
.kpi-sep { width: .5px; height: 26px; background: var(--sep); flex-shrink: 0; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ TAB BAR ━━━━━━━━━━━━━━━━━━━━━━━ */
.tab-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: var(--tab-h);
  background: var(--brand);
  display: flex; align-items: stretch;
  z-index: 70;
  box-shadow: 0 -1px 0 rgba(0,0,0,.06), 0 -6px 24px var(--brand-glow);
}
.tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px; cursor: pointer;
  padding-bottom: max(env(safe-area-inset-bottom), 4px);
  transition: opacity .15s;
  position: relative;
}
.tab:active { opacity: .7; }
.tab i {
  font-size: 22px; color: rgba(255,255,255,.55);
  transition: color .2s, transform .25s var(--ease-spring);
}
.tab span {
  font-size: 10px; font-weight: 700; letter-spacing: .3px;
  text-transform: uppercase; color: rgba(255,255,255,.55);
  transition: color .2s;
}
.tab.active i { color: #fff; transform: scale(1.12) translateY(-1px); }
.tab.active span { color: #fff; }

.tab.active::after {
  content: '';
  position: absolute; bottom: max(env(safe-area-inset-bottom), 6px);
  width: 4px; height: 4px; border-radius: 50%;
  background: rgba(255,255,255,.7);
  animation: dotIn .25s var(--ease-spring);
}
@keyframes dotIn { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.tab-sep { width: .5px; background: rgba(255,255,255,.2); align-self: stretch; margin: 12px 0; flex-shrink: 0; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ STATS PANEL ━━━━━━━━━━━━━━━━━━━ */
.stats-panel {
  position: absolute;
  inset: 0; bottom: var(--tab-h);
  background: var(--bg);
  z-index: 65;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 14px 24px;
  display: none;
  will-change: transform, opacity;
}
.stats-panel.visible {
  display: block;
  animation: panelSlide .32s var(--ease-out) forwards;
}
@keyframes panelSlide {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Återkom-panel ── */
.recall-panel {
  position: absolute;
  inset: 0; bottom: var(--tab-h);
  background: var(--bg);
  z-index: 75;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 14px 24px;
  display: none;
  will-change: transform, opacity;
}
.recall-panel.visible {
  display: block;
  animation: panelSlide .32s var(--ease-out) forwards;
}
.rp-header {
  padding: 24px 2px 12px;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.rp-header-left h2 {
  font-size: 30px; font-weight: 800; color: var(--ink); letter-spacing: -.8px;
}
.rp-sub { font-size: 13px; font-weight: 600; color: var(--mute); margin-top: 2px; }
.rp-close {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  border: none; background: #E5E5EA; color: var(--sub);
  font-size: 17px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s var(--ease-spring), background .15s;
}
.rp-close:active { background: #D1D1D6; transform: scale(.9); }

.rp-list { display: flex; flex-direction: column; gap: 8px; }
.rp-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--sep);
  border-left: 3px solid var(--yellow);
  border-radius: var(--r-sm);
  padding: 14px 14px;
  cursor: pointer; font-family: var(--font);
  box-shadow: var(--sh-xs);
  transition: transform .12s var(--ease-spring), box-shadow .15s;
}
.rp-item:active { transform: scale(.985); box-shadow: var(--sh-sm); }
.rp-item-main { flex: 1; min-width: 0; }
.rp-addr {
  font-size: 15px; font-weight: 700; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rp-note {
  font-size: 13px; color: var(--sub); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rp-item-side {
  display: flex; align-items: center; gap: 4px; flex-shrink: 0; color: var(--mute);
}
.rp-date { font-size: 12px; font-weight: 700; white-space: nowrap; }
.rp-item-side i { font-size: 20px; }

.rp-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 60px 20px; color: var(--mute); text-align: center;
}
.rp-empty i { font-size: 44px; opacity: .5; }
.rp-empty p { font-size: 15px; font-weight: 600; }

.sp-header {
  padding: 24px 2px 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.sp-header h2 {
  font-size: 30px; font-weight: 800; color: var(--ink); letter-spacing: -.8px;
}
.sp-pill {
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 700;
  padding: 5px 14px; border-radius: 999px;
  box-shadow: 0 2px 8px var(--brand-glow);
}

.sp-header-right {
  display: flex; align-items: center; gap: 8px;
}

.sp-logout {
  display: inline-flex; align-items: center;
  padding: 5px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 700;
  color: #fff; background: var(--red);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(255,59,48,.3);
  transition: opacity .15s, transform .12s var(--ease-spring);
}
.sp-logout:active { transform: scale(.95); opacity: .85; }

/* ── Week navigator ── */
.week-nav {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 0 16px;
}
.wn-arrow {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--sep);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; color: var(--sub);
  box-shadow: var(--sh-xs);
  transition: transform .12s var(--ease-spring), background .15s;
  flex-shrink: 0;
}
.wn-arrow:active { transform: scale(.88); background: #E5E5EA; }
.wn-arrow.disabled { opacity: .3; pointer-events: none; }

.wn-label {
  display: flex; flex-direction: column; align-items: center;
  min-width: 150px;
}
.wn-label-week {
  font-size: 17px; font-weight: 800; color: var(--ink);
  letter-spacing: -.4px; line-height: 1.2;
}
.wn-label-dates {
  font-size: 11px; font-weight: 500; color: var(--mute);
  letter-spacing: .1px;
}

.wn-all {
  margin-left: 6px;
  padding: 6px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .2px;
  cursor: pointer; border: 1.5px solid var(--sep);
  background: var(--card); color: var(--sub);
  box-shadow: var(--sh-xs);
  transition: all .15s;
  flex-shrink: 0;
}
.wn-all:active { transform: scale(.95); }
.wn-all.active {
  background: var(--brand); color: #fff;
  border-color: var(--brand);
  box-shadow: 0 2px 8px var(--brand-glow);
}

/* 2-col grid */
.sp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }

.sp-card {
  background: var(--card); border-radius: var(--r-lg);
  padding: 16px 14px 14px;
  box-shadow: var(--sh-xs);
  position: relative; overflow: hidden;
  animation: cardIn .4s var(--ease-out) both;
}
.sp-card:nth-child(1) { animation-delay: .04s; }
.sp-card:nth-child(2) { animation-delay: .08s; }
.sp-card:nth-child(3) { animation-delay: .12s; }
.sp-card:nth-child(4) { animation-delay: .16s; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.sp-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 3px; border-radius: 3px 3px 0 0;
}
.sp-card.green::before  { background: var(--green); }
.sp-card.yellow::before { background: var(--yellow); }
.sp-card.orange::before { background: var(--orange); }
.sp-card.red::before    { background: var(--red); }

.sp-card .c-lbl {
  font-size: 10px; font-weight: 700; color: var(--mute);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px;
}
.sp-card .c-val {
  font-size: 42px; font-weight: 900; letter-spacing: -2.5px; line-height: 1;
  transition: transform .2s var(--ease-spring);
}
.sp-card.green  .c-val { color: var(--green-txt); }
.sp-card.yellow .c-val { color: var(--yellow-txt); }
.sp-card.orange .c-val { color: var(--orange-txt); }
.sp-card.red    .c-val { color: var(--red-txt); }
.sp-card .c-sub { font-size: 12px; font-weight: 500; color: var(--mute); margin-top: 5px; }

/* Wide card */
.sp-wide {
  background: var(--card); border-radius: var(--r-lg);
  padding: 16px 14px;
  box-shadow: var(--sh-xs);
  margin-bottom: 10px;
}
.sp-wide-title {
  font-size: 11px; font-weight: 700; color: var(--mute);
  text-transform: uppercase; letter-spacing: .6px; margin-bottom: 14px;
}

/* Summary rows */
.sum-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: .5px solid var(--sep);
}
.sum-row:last-child { border-bottom: none; }
.sum-row .s-lbl { font-size: 15px; font-weight: 500; color: var(--sub); }
.sum-row .s-val { font-size: 22px; font-weight: 800; letter-spacing: -1px; }

/* Week chart */
.week-chart {
  display: flex; gap: 5px; align-items: flex-end;
  height: 88px; margin-top: 8px;
}
.wk-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; justify-content: flex-end; height: 100%; }
.wk-bar {
  width: 100%; border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, #4BA3FF 0%, #007AFF 100%);
  transition: height .6s var(--ease-out);
  min-width: 0;
}
.wk-bar.today { background: linear-gradient(180deg, #5EDF7A 0%, #34C759 100%); }
.wk-day { font-size: 9px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .3px; }
.wk-day.today { color: #007AFF; }
.wk-num { font-size: 11px; font-weight: 700; color: var(--ink); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ BOTTOM SHEET ━━━━━━━━━━━━━━━━━━ */
.overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0);
  display: none; align-items: flex-end;
  z-index: 80;
  transition: background .28s;
}
.overlay.open { background: rgba(0,0,0,.4); }

.sheet {
  width: 100%;
  background: #fff;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding-bottom: max(env(safe-area-inset-bottom), 20px);
  box-shadow: var(--sh-up);
  transform: translateY(100%);
  will-change: transform;
  transition: transform .38s var(--ease-spring);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  max-height: 90dvh;
}
.overlay.open .sheet { transform: translateY(0); }

.sheet-pull { width: 36px; height: 4px; background: #D1D1D6; border-radius: 999px; margin: 12px auto 0; }

.sheet-head {
  padding: 12px 18px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.sheet-head-left { display: flex; flex-direction: column; gap: 6px; }
.sheet-head h3 { font-size: 19px; font-weight: 700; color: var(--ink); }

.addr-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 600; color: #007AFF;
  background: rgba(0,122,255,.09);
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: opacity .2s;
  min-height: 28px;
}
.addr-chip.loading { color: var(--mute); background: #F2F2F7; }
.addr-chip i { font-size: 13px; flex-shrink: 0; }
.knock-time {
  display: inline-flex; align-items: center; gap: 4px;
  align-self: flex-start;
  font-size: 12px; font-weight: 600; color: var(--sub);
  background: #F2F2F7;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  min-height: 26px;
}
.knock-time i { font-size: 13px; flex-shrink: 0; color: var(--mute); }

.sheet-close {
  width: 28px; height: 28px; border-radius: 50%;
  background: #EBEBF0; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #6C6C70;
  flex-shrink: 0; margin-top: 2px;
  transition: background .15s, transform .12s;
}
.sheet-close:active { background: #D1D1D6; transform: scale(.9); }

.sheet-body { padding: 14px 16px 0; overflow-y: auto; flex: 1 1 auto; min-height: 0; }

/* Status buttons */
.status-list { display: flex; flex-direction: column; gap: 8px; }
.s-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; border-radius: var(--r-sm);
  border: 1.5px solid transparent;
  cursor: pointer; background: #F5F5F7;
  transition: transform .15s var(--ease-spring), border-color .15s, background .15s;
  will-change: transform;
}
.s-btn:active { transform: scale(.97); }
.s-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.s-btn span { font-size: 15px; font-weight: 600; color: var(--sub); flex: 1; }
.s-chk { font-size: 18px; opacity: 0; transition: opacity .15s, transform .2s var(--ease-spring); transform: scale(.5); flex-shrink: 0; }
.s-btn.picked .s-chk { opacity: 1; transform: scale(1); }

.s-btn.besok            { background: var(--green-bg);  } .s-btn.besok            .s-dot { background: var(--green); }
.s-btn.aterkom          { background: var(--yellow-bg); } .s-btn.aterkom          .s-dot { background: var(--yellow); }
.s-btn.ej_hemma         { background: var(--orange-bg); } .s-btn.ej_hemma         .s-dot { background: var(--orange); }
.s-btn.ej_intresserad   { background: var(--red-bg);    } .s-btn.ej_intresserad   .s-dot { background: var(--red); }
.s-btn.besok.picked            { border-color: var(--green); }
.s-btn.aterkom.picked          { border-color: var(--yellow); }
.s-btn.ej_hemma.picked         { border-color: var(--orange); }
.s-btn.ej_intresserad.picked   { border-color: var(--red); }

/* Note field */
.note-field {
  margin-top: 12px;
  background: #fff; border-radius: var(--r-sm);
  border: 1.5px solid #D1D1D6;
  padding: 10px 14px 12px;
  transition: border-color .2s;
}
.note-field:focus-within { border-color: var(--brand); }
.note-lbl { font-size: 10px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px; }
textarea {
  width: 100%; border: none; background: transparent;
  font-size: 15px; font-family: var(--font); color: var(--ink);
  resize: none; outline: none; min-height: 48px;
}
textarea::placeholder { color: #AEAEB2; }

/* Save button */
.save-btn {
  margin-top: 12px; width: 100%;
  padding: 15px; border-radius: var(--r-sm); border: none;
  background: var(--brand); color: #fff;
  font-size: 16px; font-weight: 700; font-family: var(--font);
  cursor: pointer; letter-spacing: .1px;
  box-shadow: 0 4px 14px var(--brand-glow);
  transition: opacity .15s, transform .15s var(--ease-spring), box-shadow .2s;
  will-change: transform;
}
.save-btn:active { transform: scale(.98); opacity: .9; }
.save-btn:disabled { background: #C7C7CC; box-shadow: none; cursor: default; }

/* Reveal av anteckning + spara efter statusval */
.note-reveal {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-4px);
  transition:
    max-height .4s var(--ease-out),
    opacity .24s var(--ease-out),
    transform .32s var(--ease-out);
  pointer-events: none;
}
.note-reveal-inner { padding-top: 2px; }
.note-reveal.show {
  max-height: 420px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ BOOKING FORM ━━━━━━━━━━━━━━━━━━ */
.book-back {
  display: flex; align-items: center; justify-content: center; gap: 2px;
  background: none; border: none; cursor: pointer;
  font-size: 15px; font-weight: 600; color: #007AFF;
  font-family: var(--font);
  padding: 12px 0 0;
  width: 100%;
  transition: opacity .15s;
}
.book-back:active { opacity: .6; }
.book-back i { font-size: 20px; }

.book-title {
  font-size: 19px; font-weight: 700; color: var(--ink);
  margin-bottom: 14px;
}

.book-form { display: flex; flex-direction: column; gap: 10px; }

.book-field { display: flex; flex-direction: column; gap: 4px; }

.book-lbl {
  font-size: 10px; font-weight: 700; color: var(--mute);
  text-transform: uppercase; letter-spacing: .5px;
}

.book-input {
  width: 100%; min-width: 0; padding: 12px 14px;
  border-radius: var(--r-sm); border: 1.5px solid #D1D1D6;
  font-size: 15px; font-family: var(--font); color: var(--ink);
  background: #fff; outline: none;
  box-sizing: border-box;
  transition: border-color .2s;
}
.book-input:focus { border-color: var(--brand); }

.book-input.input-error { border-color: #FF3B30; background: #FFF5F5; }
.book-input.input-error::placeholder { color: #FF8A80; }
.book-field.has-error { animation: shake .4s ease-in-out; }

.field-error {
  font-size: 12px; color: #FF3B30; font-weight: 500;
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .25s ease, opacity .2s ease, margin .25s ease;
  margin-top: 0;
}
.book-field.has-error .field-error {
  max-height: 24px; opacity: 1; margin-top: 4px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(2px); }
}

.book-input::placeholder { color: #AEAEB2; }

/* SMS-val i bokningsformuläret */
.sms-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1.5px solid #D1D1D6;
  background: #fff;
  cursor: pointer; user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: border-color .2s, background .2s;
}
.sms-opt > * { pointer-events: none; }
.sms-opt.on { border-color: var(--brand); background: #F5FAFF; }
.sms-opt-text { flex: 1; min-width: 0; }
.sms-opt-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.sms-opt-sub { font-size: 12px; color: var(--mute); margin-top: 2px; }

.opt-switch {
  flex: none;
  width: 34px; height: 20px;
  background: #E5E5EA;
  border-radius: 999px;
  position: relative;
  transition: background .25s;
}
.sms-opt.on .opt-switch { background: #007AFF; }
.opt-knob {
  position: absolute;
  left: 2px; top: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .28s var(--ease-spring);
}
.sms-opt.on .opt-knob { transform: translateX(14px); }

.book-row { display: flex; gap: 10px; }
.book-half { flex: 1 1 0; min-width: 0; overflow: hidden; }

/* Redigerbar adress */
.addr-chip-row { display: flex; align-items: center; gap: 6px; }
.addr-edit-btn {
  flex-shrink: 0; width: 28px; height: 28px;
  border-radius: 50%; border: none;
  background: rgba(0,122,255,.09); cursor: pointer; color: #007AFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; padding: 0;
  transition: background .15s, transform .12s, color .15s;
}
.addr-edit-btn:active { transform: scale(.9); }
.addr-edit-btn.active { background: #007AFF; color: #fff; }
.addr-edit-fields { display: flex; flex-direction: column; gap: 8px; }

.book-form .note-field { margin-top: 2px; }

#sheetStep2 .save-btn { margin-top: 14px; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ TOAST ━━━━━━━━━━━━━━━━━━━━━━━━━ */
.toast {
  position: absolute; bottom: 88px; left: 50%;
  transform: translateX(-50%) translateY(16px) scale(.94);
  background: rgba(28,28,30,.9);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 12px;
  z-index: 999; opacity: 0;
  transition: opacity .28s var(--ease-out), transform .3s var(--ease-spring);
  white-space: nowrap; pointer-events: none;
  will-change: transform, opacity;
  animation: toastSlideIn .3s var(--ease-out);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
  pointer-events: auto;
}
.toast * {
  pointer-events: auto !important;
}
.toast button {
  background: none; border: none; color: #5AC8FA;
  font-weight: 800; font-size: 14px; font-family: var(--font); cursor: pointer;
  padding: 4px 6px; margin: 0 -6px;
  touch-action: manipulation;
  pointer-events: auto !important;
  -webkit-user-select: none;
  user-select: none;
  transition: opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.toast button:active {
  opacity: .7;
  transform: scale(.95);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ CELEBRATION ━━━━━━━━━━━━━━━━━━━━ */
.celebration {
  position: absolute; inset: 0;
  z-index: 100;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--brand);
  pointer-events: none;
}
.celebration.active { display: flex; pointer-events: auto; }

.celebration canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.celeb-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; gap: 0;
  width: 100%; padding: 0 28px;
}

.celeb-close {
  position: absolute; top: -60px; right: 0;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(82,71,39,.15); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #524727;
  transition: background .15s, transform .12s;
  opacity: 0;
  animation: celebFadeIn .4s .6s ease forwards;
}
.celeb-close:active { background: rgba(82,71,39,.25); transform: scale(.9); }

.celeb-icon {
  font-size: 72px; line-height: 1;
  margin-bottom: 16px;
  opacity: 0;
  animation: celebBounceIn .6s var(--ease-spring) forwards;
}

.celeb-title {
  font-size: 26px; font-weight: 900; color: #131E29;
  text-align: center;
  letter-spacing: -.6px; line-height: 1.25;
  margin-bottom: 28px;
  opacity: 0;
  animation: celebWiggle 2s .2s var(--ease-out) forwards;
}

.celeb-card {
  width: 100%;
  background: #fff;
  border: none;
  border-radius: var(--r-lg);
  padding: 0;
  box-shadow: var(--sh-xs);
  opacity: 0;
  animation: celebSlideUp .5s .5s var(--ease-out) forwards;
}

.celeb-card-row {
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 20px;
}

.celeb-card-label {
  font-size: 10px; font-weight: 700; color: var(--mute);
  text-transform: uppercase; letter-spacing: .5px;
}

.celeb-card-value {
  font-size: 16px; font-weight: 700; color: var(--ink);
}

.celeb-card-divider {
  height: .5px; background: var(--sep); margin: 0 20px;
}

.celeb-cta {
  margin-top: 28px; width: 100%;
  padding: 18px 24px; border-radius: 999px; border: none;
  background: rgba(0,0,0,.18); color: #fff;
  font-size: 15px; font-weight: 700; font-family: var(--font);
  cursor: pointer; letter-spacing: .2px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: background .15s, transform .15s var(--ease-spring);
  opacity: 0;
  animation: celebSlideUp .5s .7s var(--ease-out) forwards;
}
.celeb-cta:active { transform: scale(.96); background: rgba(0,0,0,.28); }

@keyframes celebBounceIn {
  0%   { opacity: 0; transform: scale(0) rotate(-20deg); }
  60%  { opacity: 1; transform: scale(1.2) rotate(5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes celebWiggle {
  0%   { opacity: 0; transform: scale(.7) rotate(-2deg); }
  12%  { opacity: 1; transform: scale(1.06) rotate(1.5deg); }
  24%  { transform: scale(1) rotate(-1deg); }
  36%  { transform: scale(1.03) rotate(.5deg); }
  48%  { transform: scale(1) rotate(0); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes celebSlideUp {
  0%   { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes celebFadeIn {
  0%   { opacity: 0; }
  100% { opacity: 1; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ SPINNER ━━━━━━━━━━━━━━━━━━━━━━━ */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 10px; height: 10px;
  border: 2px solid rgba(142,142,147,.3); border-top-color: var(--mute);
  border-radius: 50%; animation: spin .7s linear infinite;
  vertical-align: middle; margin-right: 3px; flex-shrink: 0;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ SKELETON LOADERS ━━━━━━━━━━━━━━━━━━ */
.skeleton {
  background: linear-gradient(90deg, #E5E5EA 0%, #F2F2F7 50%, #E5E5EA 100%);
  background-size: 200% 100%;
  animation: skeletonLoad 1.5s infinite;
  border-radius: var(--r-sm);
}
@keyframes skeletonLoad {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-card { height: 60px; margin-bottom: 12px; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ TAB TRANSITIONS ━━━━━━━━━━━━━━━━━━ */
#statsPanel {
  animation: slideInRight .4s var(--ease-out);
  opacity: 0;
}
#statsPanel.visible {
  animation: slideInRight .4s var(--ease-out) forwards;
  opacity: 1;
}
@keyframes slideInRight {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(20px); opacity: 0; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ AUTO-SAVE INDICATOR ━━━━━━━━━━━━ */
.save-success {
  position: relative;
}
.save-success::after {
  content: '✓';
  position: absolute;
  right: 15px; top: 50%;
  transform: translateY(-50%) scale(0);
  color: #fff;
  font-size: 18px; font-weight: 700;
  animation: savePulse .4s var(--ease-out) forwards;
  pointer-events: none;
}
@keyframes savePulse {
  0%   { transform: translateY(-50%) scale(0); }
  50%  { transform: translateY(-50%) scale(1.3); }
  100% { transform: translateY(-50%) scale(1); }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ ENHANCED BUTTON FEEDBACK ━━━━━━━━ */
.tab:active {
  opacity: .65;
  transform: scale(.98);
}
.tab-bar .tab {
  transition: opacity .15s, transform .12s;
}

.save-btn:active {
  transform: scale(.96);
  opacity: .92;
  box-shadow: 0 2px 6px rgba(240,179,35,.3);
}

.s-btn:active {
  transform: scale(.96);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.mc-btn:active {
  transform: scale(.92);
  background: #E5E5EA;
}

.sheet-close:active {
  transform: scale(.92);
  background: #D1D1D6;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ MOMENTUM SCROLLING ━━━━━━━━━━━━━━━ */
.sheet-body {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.sp-grid, .wk-grid {
  scroll-behavior: smooth;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ ENHANCED OVERLAY ━━━━━━━━━━━━━━━━ */
.overlay {
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: background .28s, backdrop-filter .28s, -webkit-backdrop-filter .28s;
}
.overlay.open {
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ WEEK NAVIGATOR SMOOTH ━━━━━━━━━━━ */
.wn-arrow {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s, transform .15s var(--ease-spring);
  color: var(--ink);
}
.wn-arrow:active {
  transform: scale(.9);
  background: rgba(0,0,0,.05);
}
.wn-arrow i {
  font-size: 18px;
  transition: transform .2s var(--ease-spring);
}

.wn-label {
  flex: 1;
  text-align: center;
  transition: opacity .2s;
}
.wn-label.updating { opacity: .6; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━ TOAST ANIMATION ━━━━━━━━━━━━━━━━ */
@keyframes toastSlideIn {
  from { transform: translateX(-50%) translateY(16px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ HAPTIC FEEDBACK SUPPORT ━━━━━━━━━ */
button, .tab, .s-btn, .wn-arrow {
  -webkit-user-select: none;
  user-select: none;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━ NOTCH SAFE AREA ━━━━━━━━━━━━━━━━ */
@supports (padding: max(0px)) {
  .sheet {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* ━━━━━━━━━━━ INTERAKTIV GENOMGÅNG (coachmark) ━━━━━━━━━━━ */
.coach-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.62);
  z-index: 9990;
  animation: coachFade .3s ease both;
}
.coach-ring {
  position: fixed;
  border-radius: 16px;
  border: 2px solid var(--brand);
  pointer-events: none;                 /* klick går igenom till KPI-rutan */
  z-index: 9997;
  animation: coachPulse 1.6s ease-out infinite;
}
.coach-callout {
  position: fixed;
  z-index: 9998;
  max-width: 260px;
  background: #fff;
  border-radius: var(--r-sm);
  padding: 14px 16px;
  box-shadow: var(--sh-md);
  font-family: var(--font);
  animation: coachIn .42s var(--ease-spring) both;
}
.coach-callout b { font-size: 15px; font-weight: 800; color: var(--ink); letter-spacing: -.3px; }
.coach-callout p { margin: 6px 0 0; font-size: 13px; line-height: 1.4; color: var(--mute); }
.coach-skip {
  margin-top: 12px; width: 100%;
  padding: 10px 14px;
  background: var(--brand); color: #1a1304;
  border: 0; border-radius: 10px;
  font-family: var(--font); font-size: 14px; font-weight: 700;
  cursor: pointer; transition: transform .12s var(--ease-spring);
}
.coach-skip:active { transform: scale(.95); }
.coach-arrow {
  position: absolute; top: -7px; left: 24px;
  width: 14px; height: 14px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 3px 0 0 0;
}
@keyframes coachFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes coachIn { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes coachPulse {
  0%   { box-shadow: 0 0 0 0 var(--brand-glow); }
  70%  { box-shadow: 0 0 0 14px rgba(240,179,35,0); }
  100% { box-shadow: 0 0 0 0 rgba(240,179,35,0); }
}
@media (prefers-reduced-motion: reduce) {
  .coach-ring { animation: none; }
  .coach-callout, .coach-backdrop { animation: none; }
  .coach-skip { transition: none; }
}
/* ━━━ NÄT- & SESSIONSBANNER ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.net-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9998;
  display: none; align-items: center; justify-content: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 9px) 14px 9px;
  font: 600 13px/1.25 var(--font);
  color: #fff; text-align: center;
}
.net-banner.show { display: flex; }
.net-banner.offline { background: rgba(58,58,60,.96); }
.net-banner.session { background: rgba(255,59,48,.96); }
.net-banner a { color: #fff; text-decoration: underline; font-weight: 700; }
.net-banner i { font-size: 16px; flex-shrink: 0; }
