
/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Light Mode Base */
  --bg:           #f8f9fb;        /* was #080c14 */
  --bg2:          #ffffff;        /* was #0d1220 */
  --bg3:          #f1f3f6;        /* was #111827 */
  --surface:      #f8f9fb;        /* was #141d2e */
  --border:       #e2e8f0;        /* was rgba(255,255,255,.07) */
  --border-bright:#cbd5e1;        /* was rgba(255,255,255,.14) */
  
  /* Brand Colors (UNCHANGED) */
  --primary:      #dd4827;
  --primary-rgb:  221, 72, 39;
  --secondary:    #184629;
  --secondary-rgb: 24, 70, 41;
  --primary-dark: #b83a1a;
  
  /* Text - Light Mode Optimized */
  --text:         #1e293b;        /* was #e2e8f0 */
  --text-muted:   #64748b;        /* kept same - works in light */
  --text-dim:     #94a3b8;        /* kept same */
  
  /* Status Colors - Muted for Light BG */
  --avail:        #0d9488;        /* was #22d3a0 */
  --sold:         #b91c1c;        /* was #f4617a */
  --reserved:     #b45309;        /* was #f59e0b */
  --forsale:      #1d4ed8;        /* was #60a5fa */
  
  /* UI Tokens */
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 4px 24px rgba(0,0,0,.08);   /* softer for light */
  --shadow-sm:    0 2px 8px rgba(0,0,0,.05);
}
body {
  font-family: 'Outfit', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 14px;
}

/* ─── Header ─── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 16px;
  flex-wrap: wrap;
  position: relative;
}
header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary) 0%, transparent 0%);
}
.h-left h1 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);          /* was #fff */
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.h-title-icon {
  width: 20px; height: 20px;
  background: var(--primary);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
}
.h-left p {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: 1px;
  font-weight: 300;
}
.legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  font-weight: 500;
}
.ld {
  width: 8px; height: 8px;
  border-radius: 50%;
}

/* ─── Stats Bar ─── */
.sbar {
  background: var(--bg2);
  padding: 0 20px;
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 44px;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none;
}
.sbar::-webkit-scrollbar { display: none; }
.st {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-right: 1px solid var(--border);
  position: relative;
}
.st:first-child { padding-left: 0; }
.st .n {
  font-size: 1rem;
  font-weight: 700;
  font-family: 'DM Mono', monospace;
  line-height: 1;
  color: var(--text);
}
.st .l {
  font-size: .65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 500;
}

/* ─── Main Workspace ─── */
.ws {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ─── Map Pane ─── */
.mpane {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg);
  cursor: crosshair;
  scroll-behavior: smooth; /* Smooth pan/center */
}
/* Custom scrollbar - Light Mode */
.mpane::-webkit-scrollbar { width: 6px; height: 6px; }
.mpane::-webkit-scrollbar-track { background: transparent; }
.mpane::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
.mpane::-webkit-scrollbar-corner { background: transparent; }
#scaler {
  position: relative;
  display: inline-block;
  transform-origin: top left;
}
#mimg {
  display: block;
  width: 1500px;
  height: auto;
  user-select: none;
  pointer-events: none;
}
#ovc {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
}
#hitc {
  position: absolute;
  top: 0; left: 0;
  opacity: 0;
  cursor: crosshair;
}

/* ─── Tooltip ─── */
#tip {
  position: fixed;
  background: rgba(255,255,255,.98);  /* was rgba(10,15,28,.97) */
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 12px 15px;
  pointer-events: none;
  display: none;
  min-width: 200px;
  max-width: 270px;
  z-index: 9999;
  box-shadow: var(--shadow), 0 0 0 1px rgba(0,0,0,.02);
  backdrop-filter: blur(8px);
  color: var(--text);
}
#tip:has(.tt-calc-link) { pointer-events: auto; }
#tip .th {
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
#tip .tr {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: .77rem;
  margin: 4px 0;
}
#tip .tl { color: var(--text-muted); }
#tip .tv { color: var(--text); font-weight: 500; text-align: right; max-width: 155px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #fff;
}
/* Status badge backgrounds - light mode */
.badge[style*="color:#22d3a0"] { background: var(--avail); }
.badge[style*="color:#f4617a"] { background: var(--sold); }
.badge[style*="color:#f59e0b"] { background: var(--reserved); }
.badge[style*="color:#60a5fa"] { background: var(--forsale); }

/* ─── Side Panel ─── */
.side {
  width: 272px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.side-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.side-title {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--secondary); /* was var(--primary) */
}
.side-count {
  font-size: .7rem;
  color: var(--text-muted);
  font-family: 'DM Mono', monospace;
}

/* Search */
.srch {
  padding: 10px 10px 6px;
  border-bottom: 1px solid var(--border);
}
.srch-wrap { position: relative; }
.srch-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .75rem;
  pointer-events: none;
}
.srch input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .8rem;
  font-family: 'Outfit', Helvetica, Arial, sans-serif;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.srch input::placeholder { color: var(--text-muted); }
.srch input:focus { 
  border-color: var(--primary); 
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

/* Filters */
.filters {
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  border-bottom: 1px solid var(--border);
}
.fb {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .67rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  transition: all .18s;
  font-family: 'Outfit', Helvetica, Arial, sans-serif;
  letter-spacing: .3px;
  min-height: 32px; /* Touch target */
}
.fb:hover { border-color: var(--border-bright); color: var(--text-dim); }
.fb.on { color: var(--text); }
.fb[data-f="all"].on        { background: var(--surface); border-color: var(--border-bright); }
.fb[data-f="Available"].on  { background: rgba(13,148,136,.08); border-color: var(--avail); color: var(--avail); }
.fb[data-f="Sold"].on       { background: rgba(185,28,28,.08); border-color: var(--sold); color: var(--sold); }
.fb[data-f="Reserved"].on   { background: rgba(180,83,9,.08); border-color: var(--reserved); color: var(--reserved); }
.fb[data-f="For Sale"].on   { background: rgba(29,78,216,.08); border-color: var(--forsale); color: var(--forsale); }

/* Stand List */
.slist {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  scroll-snap-type: y proximity; /* Mobile snap */
}
.slist::-webkit-scrollbar { width: 4px; }
.slist::-webkit-scrollbar-track { background: transparent; }
.slist::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sc {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  margin-bottom: 3px;
  cursor: pointer;
  transition: all .14s;
  border-left: 3px solid transparent;
  scroll-snap-align: start;
}
.sc:hover { background: var(--surface); border-color: var(--border); border-left-color: inherit; }
.sc.hl { 
  background: var(--surface); 
  border-color: var(--border-bright); 
  box-shadow: 0 0 0 1px rgba(221,72,39,.15); 
  border-left-color: var(--primary) !important; 
}
.sc .sn { font-weight: 600; font-size: .8rem; color: var(--text); }
.sc .si { font-size: .67rem; color: var(--text-muted); display: flex; justify-content: space-between; margin-top: 3px; }

/* ─── Bottom Detail Strip ─── */
#dtl {
  position: fixed;
  bottom: 0; left: 0; right: 272px;
  background: rgba(255,255,255,.98);  /* was rgba(9,13,24,.97) */
  border-top: 1px solid var(--border);
  padding: 10px 18px;
  display: none;
  align-items: center;
  gap: 0;
  z-index: 200;
  flex-wrap: wrap;
  backdrop-filter: blur(12px);
  box-shadow: 0 -4px 24px rgba(0,0,0,.06);
}
#dtl::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--primary), transparent 50%);
}
#dtl .dt {
  font-weight: 700;
  font-size: .9rem;
  white-space: nowrap;
  color: var(--text);  /* was #fff */
  min-width: 90px;
  padding-right: 16px;
  border-right: 1px solid var(--border);
  margin-right: 16px;
}
.di {
  text-align: center;
  min-width: 68px;
  padding: 0 10px;
  border-right: 1px solid var(--border);
}
.di:last-of-type { border-right: none; }
.di .dv { font-size: .82rem; font-weight: 600; font-family: 'DM Mono', monospace; color: var(--text); }
.di .dl { font-size: .58rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.dtl-close {
  margin-left: auto;
  cursor: pointer;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  color: var(--text-muted);
  font-size: .8rem;
  transition: all .15s;
  border: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.dtl-close:hover { color: var(--text); background: var(--bg3); border-color: var(--border-bright); }

/* ─── Zoom Controls ─── */
.zb {
  position: fixed;
  top: 112px;
  right: 284px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
}
.zbtn {
  width: 32px;
  height: 32px;
  background: var(--bg2);  /* was rgba(13,18,32,.92) */
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: .9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  backdrop-filter: blur(8px);
  font-family: 'Outfit', Helvetica, Arial, sans-serif;
  font-weight: 500;
}
.zbtn:hover { background: var(--primary); color: #fff; border-color: var(--primary); transform: scale(1.08); }
.zbtn:active { transform: scale(.95); }

/* ─── Global Scrollbar ─── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Calculate button in detail strip ─── */
.calc-btn-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Outfit', Helvetica, Arial, sans-serif;
  letter-spacing: .2px;
  transition: all .15s;
  white-space: nowrap;
  margin-left: 8px;
  min-height: 32px; /* Touch target */
}
.calc-btn-strip:hover { filter: brightness(1.05); transform: translateY(-1px); }

/* ─── Calculator Modal ─── */
#calc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);  /* softer overlay */
  z-index: 500;
  backdrop-filter: blur(4px);
}
#calc-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 501;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  background: var(--bg2);
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,.12);
  flex-direction: column;
  overflow: hidden;
}
.calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.calc-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);  /* was #fff */
}
.calc-subtitle {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.calc-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 5px; color: var(--text-muted);
  cursor: pointer; font-size: .8rem;
  transition: all .15s;
}
.calc-close:hover { color: var(--text); background: var(--bg3); }
.calc-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}
.calc-body::-webkit-scrollbar { width: 4px; }
.calc-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.calc-field-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.calc-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
}
.calc-input-wrap { display: flex; flex-direction: column; gap: 5px; }
.calc-input {
  padding: 9px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
  font-family: 'DM Mono', monospace;
  font-weight: 500;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
  min-height: 40px; /* Touch target */
}
.calc-input:focus { 
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}
.calc-lot-info {
  font-size: .75rem;
  color: var(--text-muted);
  min-height: 18px;
  line-height: 1.4;
}

/* Price banner */
.calc-price-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.cpb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: .8rem;
}
.cpb-label { color: var(--text-muted); }
.cpb-val   { font-family: 'DM Mono', monospace; font-weight: 500; color: var(--text); }
.cpb-total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}
.cpb-total .cpb-label { color: var(--text); font-weight: 600; }
.cpb-total .cpb-val   { color: var(--primary); font-size: .95rem; font-weight: 700; }

/* Plan tabs */
.plan-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.plan-tab {
  flex: 1;
  padding: 7px 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  font-family: 'Outfit', Helvetica, Arial, sans-serif;
  min-height: 36px; /* Touch target */
}
.plan-tab:hover { border-color: var(--border-bright); color: var(--text-dim); }
.plan-tab.active {
  background: rgba(221,72,39,.08);
  border-color: var(--primary);
  color: var(--primary);
}

/* Plan details */
.plan-detail { display: none; }
.plan-detail.active { display: block; }
.plan-highlight {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.ph-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(221,72,39,.08);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem;
  flex-shrink: 0;
}
.ph-title { font-weight: 600; font-size: .85rem; margin-bottom: 2px; color: var(--text); }
.ph-sub   { font-size: .72rem; color: var(--text-muted); line-height: 1.4; }
.plan-rows { display: flex; flex-direction: column; gap: 0; }
.plan-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text-dim);
}
.plan-row:last-child { border-bottom: none; }
.plan-row-em {
  color: var(--text);
  background: rgba(0,0,0,.02);
  padding-left: 8px; padding-right: 8px;
  border-radius: 4px;
}
.plan-row-em .plan-val { color: var(--primary); font-weight: 700; }
.plan-val { font-family: 'DM Mono', monospace; font-weight: 500; }
.plan-row-cta {
  padding-top: 14px;
  border-bottom: none;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: .75rem;
}

/* WhatsApp button */
.wa-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: #25D366;
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Outfit', Helvetica, Arial, sans-serif;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
  min-height: 36px; /* Touch target */
}
.wa-btn:hover { background: #20bc5a; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(37,211,102,.25); }
.wa-btn:active { transform: translateY(0); }

/* ─── Hover label clarity fix ─── */
#hover-label {
  position: fixed;
  pointer-events: none;
  z-index: 9998;
  display: none;
  background: rgba(255,255,255,.98);  /* was rgba(8,12,20,.95) */
  border: 1px solid var(--border-bright);
  border-radius: 5px;
  padding: 3px 7px;
  font-family: 'DM Mono', monospace;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transform: translate(-50%, -100%) translateY(-10px);
  color: var(--text);
}

/* ─── Floating Calculator Button (FAB) ─── */
.calc-fab {
  position: fixed;
  bottom: 15px;
  left: 24px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px 10px 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  border: none;
  border-radius: 50px;
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  font-family: 'Outfit', Helvetica, Arial, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(221,72,39,.25), 0 2px 8px rgba(0,0,0,.06);
  transition: all .2s cubic-bezier(.34,1.56,.64,1);
  letter-spacing: .2px;
  min-height: 44px; /* Touch target */
}
.calc-fab:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 8px 28px rgba(221,72,39,.35), 0 4px 12px rgba(0,0,0,.08);
}
.calc-fab:active { transform: scale(.97); }
.calc-fab-icon  { font-size: 1rem; }
.calc-fab-label { white-space: nowrap; }

/* ─── Tooltip quick-calc link ─── */
.tt-calc-link {
  margin-top: 8px;
  padding: 6px 8px;
  background: rgba(221,72,39,.08);
  border: 1px solid rgba(221,72,39,.2);
  border-radius: 5px;
  color: var(--primary);
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background .15s;
  pointer-events: auto;
}
.tt-calc-link:hover { background: rgba(221,72,39,.12); }

/* ─── Responsive (Minimal, Non-Breaking) ─── */
@media (max-width: 768px) {
  .ws { flex-direction: column; }
  .mpane { height: 50vh; border-bottom: 1px solid var(--border); }
  .side { 
    width: 100%; 
    height: 50vh; 
    border-left: none; 
    border-top: 1px solid var(--border); 
  }
  #dtl { 
    right: 0; 
    position: relative; 
    border-top: none; 
    border-bottom: 1px solid var(--border); 
    box-shadow: none; 
  }
  .zb { 
    top: auto; 
    bottom: 20px; 
    right: 20px; 
    flex-direction: row; 
  }
  .zbtn { width: 40px; height: 40px; font-size: 1.1rem; }
  .calc-fab { bottom: 20px; left: 20px; }
  /* Ensure touch targets */
  .fb, .plan-tab, .wa-btn, .zbtn, .calc-btn-strip, .srch input { min-height: 44px; }
}

/* ─── Focus Accessibility (Non-Breaking) ─── */
:focus-visible { 
  outline: 2px solid var(--primary); 
  outline-offset: 2px; 
  border-radius: 4px; 
}

/* ========================================
   MOBILE RESPONSIVE STYLES
   ======================================== */

@media (max-width: 992px) {
    /* Internal Header - Mobile */
    .map-internal-header {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }
    
    .map-internal-header .h-left {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .map-internal-header h1 {
        font-size: 15px;
        flex-wrap: wrap;
    }
    
    .map-internal-header p {
        font-size: 12px;
    }
    
    .map-internal-header .legend {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .map-internal-header .legend .li {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    /* Stats Bar - Mobile */
    .sbar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 16px;
    }
    
    .sbar::-webkit-scrollbar {
        height: 3px;
    }
    
    .sbar::-webkit-scrollbar-thumb {
        background: rgba(0,0,0,0.2);
        border-radius: 3px;
    }
    
    /* Workspace - Mobile */
    .ws {
        position: relative;
    }
    
    /* Map Pane - Mobile */
    .mpane {
        touch-action: none; /* Enable touch gestures */
    }
    
    #scaler {
        transform-origin: 0 0;
    }
    
    #mimg {
        max-width: none; /* Allow panning */
    }
    
    /* Zoom Controls - Mobile Position */
    .zb {
        left: 12px;
        top: 12px;
        padding: 8px;
        gap: 6px;
    }
    
    .zbtn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .zoom-pct {
        font-size: 9px;
        padding: 3px 0;
    }
    
    /* Side Panel - Mobile (Bottom Sheet Style) */
    .side {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 45vh;
        max-height: 400px;
        background: #fff;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        z-index: 100;
        display: flex;
        flex-direction: column;
        transform: translateY(calc(100% - 60px)); /* Show only header */
        transition: transform 0.3s ease;
    }
    
    .side.active {
        transform: translateY(0); /* Full height when active */
    }
    
    .side-header {
        padding: 16px;
        background: #f8f9fa;
        border-radius: 16px 16px 0 0;
        cursor: pointer;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid rgba(0,0,0,0.06);
    }
    
    .side-header::after {
        content: '▲';
        font-size: 12px;
        color: #666;
        transition: transform 0.3s ease;
    }
    
    .side.active .side-header::after {
        transform: rotate(180deg);
    }
    
    .side-title {
        font-size: 14px;
        font-weight: 600;
    }
    
    .side-count {
        font-size: 12px;
        color: #666;
    }
    
    /* Search - Mobile */
    .srch {
        padding: 12px 16px;
        border-bottom: 1px solid rgba(0,0,0,0.06);
    }
    
    .srch-wrap {
        position: relative;
    }
    
    .srch-icon {
        left: 14px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 14px;
    }
    
    #srch {
        padding: 12px 14px 12px 42px;
        font-size: 15px;
        border-radius: 10px;
    }
    
    /* Filters - Mobile */
    .filters {
        padding: 12px 16px;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-bottom: 1px solid rgba(0,0,0,0.06);
    }
    
    .filters::-webkit-scrollbar {
        height: 2px;
    }
    
    .fb {
        padding: 8px 16px;
        font-size: 13px;
        border-radius: 20px;
        white-space: nowrap;
    }
    
    /* Stand List - Mobile */
    .slist {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 16px;
    }
    
    .sitem {
        padding: 14px;
        margin-bottom: 10px;
        border-radius: 10px;
        font-size: 14px;
    }
    
    /* Tooltip - Mobile */
    #tip {
        max-width: calc(100vw - 40px);
        font-size: 13px;
        padding: 12px;
    }
    
    #tip .th {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    /* Detail Panel - Mobile */
    #dtl {
        left: 12px;
        right: 12px;
        max-width: none;
        padding: 20px;
        border-radius: 14px;
    }
    
    #dtl .dt {
        font-size: 16px;
        margin-bottom: 16px;
    }
    
    #dtl .di {
        margin-bottom: 12px;
    }
    
    #dtl .dv {
        font-size: 15px;
    }
    
    #dtl .dl {
        font-size: 11px;
    }
    
    .calc-btn-strip {
        padding: 12px;
        font-size: 14px;
        margin-top: 16px;
    }
    
    .dtl-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    /* Calculator FAB - Mobile */
    .calc-fab {
        right: 12px;
        bottom: 100px; /* Above side panel */
        top: auto;
        padding: 12px 20px;
        font-size: 13px;
    }
    
    .calc-fab-label {
        display: none; /* Show only icon on mobile */
    }
    
    .calc-fab-icon {
        font-size: 18px;
    }
    
    /* Calculator Modal - Mobile */
    #calc-modal {
        width: calc(100vw - 32px);
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 16px;
        padding: 20px;
    }
    
    .calc-header {
        margin-bottom: 20px;
    }
    
    .calc-title {
        font-size: 18px;
    }
    
    .calc-subtitle {
        font-size: 13px;
    }
    
    .calc-close {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
    
    .calc-field-row {
        margin-bottom: 16px;
    }
    
    .calc-label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .calc-input {
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
        border-radius: 10px;
    }
    
    .plan-tabs {
        gap: 8px;
        margin-bottom: 16px;
    }
    
    .plan-tab {
        padding: 10px 16px;
        font-size: 13px;
        border-radius: 8px;
        flex: 1;
    }
    
    .plan-highlight {
        padding: 14px;
        margin-bottom: 16px;
        border-radius: 10px;
    }
    
    .ph-title {
        font-size: 14px;
    }
    
    .ph-sub {
        font-size: 12px;
    }
    
    .plan-row {
        padding: 12px 0;
        font-size: 14px;
    }
    
    .plan-val {
        font-size: 15px;
        font-weight: 600;
    }
    
    .wa-btn {
        padding: 12px 20px;
        font-size: 14px;
        border-radius: 10px;
    }
    
    /* Navigation Hint - Mobile */
    #nav-hint {
        bottom: 70px;
        font-size: 10px;
        padding: 6px 12px;
        max-width: calc(100vw - 40px);
        text-align: center;
    }
}

/* Extra Small Devices (Phones in portrait) */
@media (max-width: 480px) {
    .map-internal-header h1 {
        font-size: 14px;
    }
    
    .map-internal-header p {
        font-size: 11px;
    }
    
    .map-internal-header .legend .li {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .zb {
        padding: 6px;
        gap: 4px;
    }
    
    .zbtn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .side {
        height: 50vh;
        max-height: 350px;
    }
    
    .side-header {
        padding: 14px;
    }
    
    .srch, .filters {
        padding: 10px 14px;
    }
    
    #srch {
        padding: 10px 12px 10px 38px;
        font-size: 14px;
    }
    
    .fb {
        padding: 7px 14px;
        font-size: 12px;
    }
    
    .sitem {
        padding: 12px;
        font-size: 13px;
    }
    
    #dtl {
        padding: 16px;
    }
    
    #dtl .dt {
        font-size: 15px;
    }
    
    #calc-modal {
        padding: 16px;
    }
    
    .calc-title {
        font-size: 16px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 992px) and (orientation: landscape) {
    .side {
        height: 35vh;
        max-height: 250px;
    }
    
    #nav-hint {
        display: none; /* Hide hint in landscape to save space */
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .zbtn {
        width: 40px;
        height: 40px;
    }
    
    .fb, .plan-tab, .wa-btn {
        min-height: 44px; /* Apple's recommended touch target */
    }
    
    /* Remove hover effects on touch devices */
    .zbtn:hover, .fb:hover, .plan-tab:hover {
        background: inherit;
    }
    
    .zbtn:active, .fb:active, .plan-tab:active {
        background: rgba(0,0,0,0.1);
    }
}

/* Prevent pull-to-refresh on mobile when scrolling map */
body {
    overscroll-behavior-y: contain;
}

/* Smooth scrolling for mobile */
.slist, .sbar, .filters {
    scroll-behavior: smooth;
}

/* Fix for iOS safe areas */
@supports (padding: max(0px)) {
    @media (max-width: 992px) {
        .side {
            padding-left: max(0px, env(safe-area-inset-left));
            padding-right: max(0px, env(safe-area-inset-right));
            padding-bottom: max(0px, env(safe-area-inset-bottom));
        }
        
        .calc-fab {
            right: max(12px, env(safe-area-inset-right));
            bottom: max(100px, env(safe-area-inset-bottom));
        }
    }
}

/* Ensure hit canvas works on touch devices */
#hitc {
    touch-action: none; /* Prevent browser zoom/pan interference */
    -webkit-tap-highlight-color: transparent;
}

/* Fix for iOS: ensure canvas is clickable */
@media (pointer: coarse) {
    #hitc {
        cursor: pointer;
    }
    .mpane {
        touch-action: pan-x pan-y; /* Allow panning but not pinch-zoom interference */
    }
}