:root {
  --azul-oscuro: #001533;
  --azul-profundo: #002C65;
  --azul-vivo: #0062DE;
  --celeste: #D7ECFE;
  --verde: #00BF8C;
  --verde-bg: #E6F9F4;
  --verde-txt: #007A5A;
  --rojo: #D0021B;
  --rojo-bg: #FDECEA;
  --rojo-txt: #9B0013;
  --azul: #0062DE;
  --azul-bg: #D7ECFE;
  --naranja-bg: #FFF3CD;
  --naranja-txt: #7A4F00;
  --bg: #ffffff;
  --bg2: #F0F5FF;
  --border: #dde6f5;
  --txt: #001533;
  --txt2: #4A607A;
  --txt3: #8DA3BB;
  --radius: 12px;
  --radius-sm: 8px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg2); min-height: 100vh; display: flex; justify-content: center; }
#app { background: var(--bg); width: 100%; max-width: 480px; min-height: 100vh; display: flex; flex-direction: column; position: relative; }

.header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; background: var(--azul-oscuro); position: sticky; top: 0; z-index: 5; }
.header-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--azul-vivo); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.header-icon i { color: white; font-size: 16px; }
.header-title { font-size: 15px; font-weight: 700; color: #ffffff; flex: 1; letter-spacing: -0.2px; }
.header-reset { font-size: 11px; color: rgba(255,255,255,0.5); }
.header-brand { font-size: 10px; color: rgba(255,255,255,0.4); font-weight: 500; letter-spacing: .05em; }

.ptr-indicator { height: 0; overflow: hidden; background: var(--bg2); display: flex; align-items: center; justify-content: center; transition: height 0.25s cubic-bezier(0.1, 0.9, 0.2, 1); will-change: height; border-bottom: 0 solid transparent; }
.ptr-indicator.pulling { transition: none; }
.ptr-indicator.active { border-bottom: 1px solid var(--border); }
.ptr-content { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--txt2); pointer-events: none; }
.ptr-icon { font-size: 13px; color: var(--azul-vivo); transition: transform 0.2s ease; }
.ptr-indicator.threshold .ptr-icon { transform: rotate(180deg); }
.ptr-indicator.refreshing .ptr-icon { transform: none; }

.yo-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--celeste); border-bottom: 1px solid var(--border); }
.yo-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--azul-vivo); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: white; flex-shrink: 0; }
.yo-nombre { font-size: 13px; color: var(--azul-profundo); flex: 1; font-weight: 600; }
.yo-cambiar { font-size: 12px; color: var(--azul-vivo); cursor: pointer; font-weight: 500; background: none; border: none; font-family: inherit; }

.tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--bg); }
.tab { flex: 1; padding: 11px; font-size: 13px; text-align: center; cursor: pointer; color: var(--txt2); border-bottom: 2px solid transparent; font-weight: 500; transition: all .15s; background: none; border-top: none; border-left: none; border-right: none; font-family: inherit; }
.tab.active { color: var(--azul-vivo); border-bottom: 2px solid var(--azul-vivo); }
.tab-badge { display: none; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: var(--rojo); color: white; font-size: 11px; font-weight: 700; vertical-align: middle; line-height: 18px; }
.tab-badge.show { display: inline-block; }

.piso-label { font-size: 11px; font-weight: 700; color: var(--azul-profundo); letter-spacing: .08em; padding: 10px 16px 4px; text-transform: uppercase; background: var(--celeste); border-bottom: 1px solid var(--border); }
.card { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; gap: 12px; background: var(--bg); transition: background .12s; }
.card:active { background: var(--bg2); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-l { background: var(--verde); }
.dot-o { background: var(--rojo); }
.card-num { font-size: 16px; font-weight: 600; color: var(--txt); min-width: 34px; }
.card-info { flex: 1; }
.card-usr { font-size: 13px; color: var(--txt); }
.card-pat { font-size: 12px; color: var(--txt2); font-family: 'SF Mono', 'Fira Code', monospace; margin-top: 1px; }
.card-libre { font-size: 13px; color: var(--txt3); }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 500; }
.badge-l { background: var(--verde-bg); color: var(--verde-txt); }
.badge-o { background: var(--rojo-bg); color: var(--rojo-txt); }

.resumen-metrics { display: flex; gap: 10px; padding: 14px 16px; }
.metric { flex: 1; background: var(--bg2); border-radius: var(--radius); padding: 14px 10px; text-align: center; }
.metric-num { font-size: 26px; font-weight: 700; }
.metric-lbl { font-size: 12px; color: var(--txt2); margin-top: 2px; }
.nv { color: var(--verde); } .nr { color: var(--rojo); }
.resumen-piso { padding: 0 16px 16px; }
.resumen-piso-title { font-size: 13px; font-weight: 600; color: var(--txt); margin-bottom: 6px; margin-top: 14px; }
.resumen-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.resumen-row:last-child { border-bottom: none; }

.sync-footer { font-size: 11px; color: var(--txt3); text-align: center; padding: 10px 16px; border-top: 1px solid var(--border); margin-top: auto; }

/* Driving Hero Mode (~70% screen height) */
.driving-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(65vh - 56px);
  padding: 24px 20px 20px;
  background: radial-gradient(circle at 50% 30%, #ffffff 0%, var(--bg2) 100%);
  border-bottom: 2px solid var(--border);
  position: relative;
  overflow: hidden;
}

.hero-circle-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

/* Big Circular Button */
.btn-circular {
  width: clamp(170px, 48vw, 220px);
  height: clamp(170px, 48vw, 220px);
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  padding: 16px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 12px 32px rgba(0, 98, 222, 0.18), 0 4px 12px rgba(0, 21, 51, 0.08);
  position: relative;
  outline: none;
  background: var(--azul-vivo);
  color: #ffffff;
}

.btn-circular:active:not(:disabled) {
  transform: scale(0.96);
}

.btn-circular-icon {
  font-size: clamp(32px, 8vw, 44px);
  margin-bottom: 8px;
  line-height: 1;
}

.btn-circular-label {
  font-size: clamp(14px, 3.8vw, 17px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.2px;
  max-width: 90%;
  word-break: break-word;
}

/* State: In Range (< 400m) - Green & Glowing pulse */
.btn-circular.en-rango {
  background: linear-gradient(135deg, #00d69d 0%, var(--verde) 100%);
  color: #ffffff;
  box-shadow: 0 14px 36px rgba(0, 191, 140, 0.38), 0 4px 14px rgba(0, 122, 90, 0.2);
  border-color: rgba(255, 255, 255, 0.95);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 191, 140, 0.5), 0 12px 30px rgba(0, 191, 140, 0.3);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(0, 191, 140, 0), 0 12px 30px rgba(0, 191, 140, 0.3);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 191, 140, 0), 0 12px 30px rgba(0, 191, 140, 0.3);
  }
}

/* State: Out of Range / Disabled (> 400m or loading) */
.btn-circular:disabled {
  background: #c3d5ee;
  color: #3b5373;
  box-shadow: 0 6px 18px rgba(0, 44, 101, 0.08);
  border-color: rgba(255, 255, 255, 0.7);
  cursor: not-allowed;
  opacity: 0.92;
}

/* State: Cochera Already Assigned */
.btn-circular.asignada {
  background: linear-gradient(135deg, var(--azul-vivo) 0%, var(--azul-profundo) 100%);
  color: #ffffff;
  box-shadow: 0 14px 34px rgba(0, 44, 101, 0.3);
}
.btn-circular.asignada .btn-circular-label {
  font-size: clamp(15px, 4.2vw, 19px);
}

/* Distance Container */
.hero-dist-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 12px;
  width: 100%;
}

.hero-dist-val {
  font-size: clamp(2.3rem, 8.5vw, 4.2rem);
  font-weight: 800;
  color: var(--azul-profundo);
  letter-spacing: -1.5px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  max-width: 100%;
}

.hero-dist-val.en-rango {
  color: var(--verde-txt);
}

.hero-dist-sub {
  font-size: clamp(13px, 3.4vw, 15px);
  color: var(--txt2);
  font-weight: 600;
  margin-top: 4px;
}

.asignar-hint { font-size: 12px; color: var(--txt2); text-align: center; margin-top: 2px; }
.asignar-hint.clickable { cursor: pointer; color: var(--azul-vivo); text-decoration: underline; }
.asignar-hint.en-rango { color: var(--verde-txt); font-weight: 700; text-decoration: none; cursor: default; }
.card-free { cursor: default; }
.card-free:active { background: var(--bg); }

.rep-item { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.rep-meta { font-size: 12px; color: var(--txt2); margin-bottom: 4px; }
.rep-texto { font-size: 13px; color: var(--txt); line-height: 1.4; }
.rep-empty { padding: 24px 16px; text-align: center; color: var(--txt3); font-size: 13px; }

.overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { background: var(--bg); border-radius: 20px 20px 0 0; padding: 20px 16px 32px; width: 100%; max-width: 480px; }
.sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }
.sheet-num { font-size: 26px; font-weight: 700; color: var(--txt); }
.sheet-piso { font-size: 13px; color: var(--txt2); margin-bottom: 16px; }
.search-wrap { position: relative; margin-bottom: 8px; }
.search-input { width: 100%; padding: 10px 12px 10px 34px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--bg2); color: var(--txt); outline: none; }
.search-input:focus { border-color: var(--azul-vivo); }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--txt3); font-size: 14px; }
.emp-list { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 14px; }
.emp-item { padding: 9px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: var(--bg); }
.emp-item:last-child { border-bottom: none; }
.emp-item:active { background: var(--bg2); }
.emp-item.selected { background: var(--celeste); }
.emp-item.selected .emp-name { color: var(--azul-vivo); font-weight: 600; }
.emp-pat { font-size: 11px; font-family: 'SF Mono', 'Fira Code', monospace; color: var(--txt2); }
.btn-primary { width: 100%; padding: 13px; border-radius: var(--radius); font-size: 15px; font-weight: 600; cursor: pointer; border: none; background: var(--azul-vivo); color: white; margin-bottom: 8px; font-family: 'Plus Jakarta Sans', sans-serif; }
.btn-secondary { width: 100%; padding: 13px; border-radius: var(--radius); font-size: 15px; font-weight: 500; cursor: pointer; border: 1px solid var(--border); background: var(--bg); color: var(--txt); margin-bottom: 8px; font-family: 'Plus Jakarta Sans', sans-serif; }
.btn-ghost { width: 100%; padding: 11px; border-radius: var(--radius); font-size: 14px; cursor: pointer; border: none; background: transparent; color: var(--txt2); font-family: 'Plus Jakarta Sans', sans-serif; }
.btn-tiny { padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; border: none; font-family: inherit; }
.btn-tiny-ok { background: var(--verde-bg); color: var(--verde-txt); }
.btn-tiny-no { background: var(--rojo-bg); color: var(--rojo-txt); }
.quien-txt { font-size: 13px; color: var(--txt2); margin-bottom: 14px; line-height: 1.5; }

.ob-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; }
.ob-card { background: var(--bg); border-radius: 20px; padding: 24px 16px; width: 100%; max-width: 400px; }
.auth-boot-card { display: flex; align-items: center; justify-content: center; min-height: 120px; }
.auth-boot-card .loading { padding: 0; }
.ob-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; color: var(--txt); }
.ob-sub { font-size: 14px; color: var(--txt2); margin-bottom: 16px; line-height: 1.5; }
#google-btn { display: flex; justify-content: center; margin: 8px 0 12px; min-height: 44px; }

.offline-banner { background: var(--naranja-bg); color: var(--naranja-txt); font-size: 12px; padding: 8px 16px; display: flex; align-items: center; gap: 8px; }
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--txt3); font-size: 14px; gap: 10px; }

.reg-link { text-align: center; font-size: 13px; color: var(--azul-vivo); cursor: pointer; margin-top: 6px; padding: 8px; font-weight: 500; background: none; border: none; width: 100%; font-family: inherit; }
.text-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--bg2); color: var(--txt); outline: none; margin-bottom: 8px; font-family: 'Plus Jakarta Sans', sans-serif; }
.text-input:focus { border-color: var(--azul-vivo); }
.input-lbl { font-size: 12px; color: var(--txt2); margin-bottom: 4px; font-weight: 600; }
.form-error { color: var(--rojo); font-size: 12px; margin-bottom: 8px; }

.user-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.user-item-body { flex: 1; min-width: 0; }
.user-email { font-size: 13px; font-weight: 600; color: var(--txt); word-break: break-all; }
.user-meta { font-size: 12px; color: var(--txt2); margin-top: 2px; }
.user-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-user-edit { padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--bg); color: var(--azul-vivo); font-family: inherit; }
.asig-center { text-align: center; }
.asig-num { margin-bottom: 2px; }
.asig-nota { margin: 10px 0 4px; color: var(--txt2); }
.header-grow { flex: 1; }
.hidden { display: none !important; }
.ob-list-tall { max-height: 180px; margin-bottom: 10px; }
.reporte-texto { resize: vertical; min-height: 70px; }

/* Geo status and help banner */
.geo-status-banner { margin-top: 10px; padding: 10px 12px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.geo-status-text { font-size: 12px; color: var(--txt2); line-height: 1.4; margin-bottom: 8px; text-align: center; }
.geo-status-actions { display: flex; gap: 8px; justify-content: center; }
.btn-geo-action { padding: 7px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--bg); color: var(--azul-vivo); font-family: inherit; display: inline-flex; align-items: center; gap: 6px; }
.btn-geo-action:active { background: var(--celeste); }
.btn-geo-help { color: var(--txt2); background: transparent; border-color: transparent; text-decoration: underline; }

/* Geo modal */
.geo-modal-card { max-width: 420px; }
.geo-modal-header { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.geo-modal-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--celeste); color: var(--azul-vivo); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.geo-modal-sub { margin-bottom: 0; font-size: 13px; }
.geo-tabs { display: flex; background: var(--bg2); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 14px; gap: 3px; }
.geo-tab { flex: 1; padding: 8px 10px; font-size: 12px; font-weight: 600; border: none; background: transparent; color: var(--txt2); border-radius: 6px; cursor: pointer; font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all .15s; }
.geo-tab.active { background: var(--bg); color: var(--azul-vivo); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.geo-instructions { margin-bottom: 16px; }
.geo-step { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.geo-step-num { width: 22px; height: 22px; border-radius: 50%; background: var(--azul-vivo); color: white; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.geo-step-txt { font-size: 13px; color: var(--txt); line-height: 1.45; }
.geo-step-txt strong { color: var(--azul-profundo); }
.geo-note { margin-top: 12px; padding: 10px 12px; background: var(--naranja-bg); color: var(--naranja-txt); border-radius: var(--radius-sm); font-size: 11px; line-height: 1.45; }
.geo-note strong { color: #5a3a00; }

