:root {
  --app-green-950: #092f20;
  --app-green-900: #0f442d;
  --app-green-800: #185b3b;
  --app-green-700: #24744b;
  --app-green-600: #2f8a59;
  --app-green-100: #e8f4ec;
  --app-gold-600: #c58a0a;
  --app-gold-100: #fff5d9;
  --app-ink: #10271c;
  --app-muted: #61746a;
  --app-bg: #f3f6f1;
  --app-surface: #ffffff;
  --app-line: #dce5dd;
  --app-danger: #b42318;
  --app-shadow-sm: 0 7px 22px rgba(9, 47, 32, .08);
  --app-shadow-lg: 0 22px 64px rgba(9, 47, 32, .16);
  --app-radius-sm: 14px;
  --app-radius-md: 20px;
  --app-radius-lg: 28px;
  --app-font: "Segoe UI Variable", "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
}

html {
  color-scheme: light;
  background: var(--app-bg);
}

body {
  font-family: var(--app-font) !important;
  -webkit-tap-highlight-color: transparent;
}

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

button,
a {
  -webkit-touch-callout: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(213, 158, 31, .38) !important;
  outline-offset: 2px;
}

.app-icon {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn .app-icon,
.auth-choice .app-icon {
  margin-right: 9px;
  vertical-align: -5px;
}

.auth-choice .app-icon {
  margin-right: 0;
}

/* Registro compartido */
body.mode-auth {
  position: relative;
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom)) !important;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 4%, rgba(214, 163, 26, .13), transparent 24rem),
    radial-gradient(circle at 96% 18%, rgba(36, 116, 75, .14), transparent 25rem),
    linear-gradient(155deg, #fffdf8, #f3f6f0 64%, #edf4ee) !important;
}

body.mode-auth::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='none' stroke='%2324704b' stroke-opacity='.12'%3E%3Cpath d='M-20 40C25 16 48 62 92 39s76-16 114 8'/%3E%3Cpath d='M-20 66c45-24 68 22 112-1s76-16 114 8'/%3E%3C/g%3E%3C/svg%3E");
}

body.mode-auth #auth {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 448px;
}

body.mode-auth .brand-logo {
  width: 100px !important;
  height: 100px !important;
  margin-bottom: 2px !important;
  filter: drop-shadow(0 10px 24px rgba(9, 47, 32, .13)) !important;
}

body.mode-auth .tag {
  margin: 0 0 14px !important;
  color: var(--app-muted) !important;
  font-size: 13px !important;
  font-weight: 650;
  letter-spacing: .01em;
}

.auth-role {
  width: max-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 auto 7px;
  padding: 6px 10px;
  border: 1px solid #cfe0d2;
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  color: var(--app-green-900);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .075em;
  text-transform: uppercase;
  box-shadow: 0 5px 18px rgba(9, 47, 32, .06);
}

.auth-role .app-icon {
  width: 15px;
  height: 15px;
}

body.mode-auth .card {
  padding: 23px !important;
  border: 1px solid rgba(15, 68, 45, .13) !important;
  border-radius: 24px !important;
  background: rgba(255, 255, 255, .96) !important;
  box-shadow: var(--app-shadow-lg) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

body.mode-auth .card h2 {
  margin-bottom: 6px;
  color: var(--app-ink);
  font-size: clamp(21px, 6vw, 25px) !important;
  line-height: 1.15;
  letter-spacing: -.035em;
}

body.mode-auth .sub {
  margin-bottom: 18px;
  color: var(--app-muted);
  line-height: 1.5;
}

body.mode-auth .steps {
  gap: 6px;
  margin: 0 0 20px;
}

body.mode-auth .steps .dot {
  height: 5px;
  flex: 1 1 18px;
  max-width: 34px;
  border-radius: 999px;
  background: #e0e7e1;
  transition: background .2s ease, transform .2s ease;
}

body.mode-auth .steps .dot.on {
  background: linear-gradient(90deg, var(--app-green-800), #42a36c);
  box-shadow: 0 3px 9px rgba(36, 116, 75, .23);
}

body.mode-auth label {
  color: #456052;
  font-size: 12px;
  font-weight: 750;
}

body.mode-auth input,
body.mode-auth select,
body.mode-auth textarea {
  min-height: 52px;
  border: 1px solid var(--app-line);
  border-radius: 15px;
  padding: 13px 14px;
  background: #fff;
  color: var(--app-ink);
  box-shadow: inset 0 1px 1px rgba(9, 47, 32, .02);
}

body.mode-auth input:focus,
body.mode-auth select:focus,
body.mode-auth textarea:focus {
  border-color: var(--app-green-600);
  box-shadow: 0 0 0 4px rgba(47, 138, 89, .1);
}

body.mode-auth .btn {
  min-height: 52px;
  border-radius: 15px !important;
  transition: transform .15s ease, box-shadow .18s ease, border-color .18s ease;
}

body.mode-auth .btn:not(:disabled):active {
  transform: scale(.98);
}

body.mode-auth .btn.primary {
  border: 0;
  background: linear-gradient(135deg, var(--app-green-800), #2e8959) !important;
  color: #fff;
  box-shadow: 0 9px 22px rgba(24, 91, 59, .23);
}

body.mode-auth .btn.ghost {
  border: 1px solid var(--app-line);
  background: #f7faf7;
}

body.mode-auth .auth-choice {
  position: relative;
  min-height: 56px;
  border-color: #d8e1da !important;
  border-radius: 16px !important;
  background: #fff !important;
  color: var(--app-ink);
  box-shadow: 0 5px 15px rgba(9, 47, 32, .055);
}

body.mode-auth .auth-choice:not(:disabled):hover {
  border-color: #a9c5b0 !important;
  box-shadow: 0 8px 20px rgba(9, 47, 32, .09);
}

.auth-trust {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 18px 0 3px;
}

.auth-trust span {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  padding: 8px 5px;
  border: 1px solid #e1e9e2;
  border-radius: 13px;
  background: #f8faf7;
  color: #4e6659;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}

.auth-security-note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 16px 0 0;
  padding: 11px 12px;
  border: 1px solid #e4dfc8;
  border-radius: 14px;
  background: #fffaf0;
  color: #665929;
  font-size: 11px;
  line-height: 1.45;
}

.auth-security-note .app-icon {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  color: var(--app-gold-600);
}

body.mode-auth .docrow {
  min-height: 67px;
  border-radius: 16px;
  background: #fbfcfa;
}

body.mode-auth .docrow .mini {
  min-height: 40px;
  border-radius: 12px;
  background: var(--app-green-100);
  color: var(--app-green-900);
}

body.mode-auth .service-preview {
  border-radius: 20px;
  border-color: #e6e2d3;
  background: radial-gradient(circle at center, #fff9e9, #fff);
}

body.mode-auth .seg {
  padding: 4px;
  border-radius: 15px;
  background: #eff4ef;
}

body.mode-auth .seg button {
  min-height: 45px;
  border: 0;
  border-radius: 12px;
  background: transparent;
}

body.mode-auth .seg button.on {
  background: #fff;
  color: var(--app-green-900);
  box-shadow: 0 4px 13px rgba(9, 47, 32, .1);
}

.install-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 13px;
  padding: 12px 13px;
  border: 1px solid rgba(15, 68, 45, .13);
  border-radius: 18px;
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--app-shadow-sm);
}

.install-card-icon {
  width: 42px;
  height: 42px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  background: var(--app-green-100);
  color: var(--app-green-800);
}

.install-card-copy {
  min-width: 0;
  flex: 1;
}

.install-card-copy strong,
.install-card-copy small {
  display: block;
}

.install-card-copy strong {
  color: var(--app-ink);
  font-size: 12px;
}

.install-card-copy small {
  margin-top: 2px;
  color: var(--app-muted);
  font-size: 10px;
  line-height: 1.3;
}

.install-card button {
  min-width: 76px;
  min-height: 39px;
  border: 0;
  border-radius: 12px;
  padding: 8px 11px;
  background: var(--app-green-800);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

/* App instalada / operación */
body.mode-app {
  background:
    radial-gradient(circle at 50% -20%, rgba(36, 116, 75, .16), transparent 32rem),
    #e9efea !important;
}

body.mode-app #rideapp,
body.mode-app #driverapp {
  position: relative;
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--app-bg);
  box-shadow: 0 0 0 1px rgba(9, 47, 32, .06), 0 22px 72px rgba(9, 47, 32, .16);
}

body.mode-app .topbar {
  position: relative;
  min-height: 74px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  border: 0;
  isolation: isolate;
  background: linear-gradient(135deg, var(--app-green-950), var(--app-green-800) 64%, #2d8658);
  box-shadow: 0 8px 25px rgba(9, 47, 32, .23);
}

body.mode-app .topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .18;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='100' viewBox='0 0 420 100'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='1.2'%3E%3Cpath d='M-20 24C62-8 106 57 190 24S325 1 450 31'/%3E%3Cpath d='M-20 43C68 12 116 75 205 43S340 22 450 51'/%3E%3Cpath d='M-20 64C72 34 131 91 221 64S350 43 450 72'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
}

body.mode-app .app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: -.025em;
}

body.mode-app .app-brand img {
  width: 46px;
  height: 46px;
  border: 2px solid rgba(255, 255, 255, .72);
  border-radius: 15px;
  background: #fff;
}

body.mode-app .app-brand > span {
  display: grid;
  line-height: 1.05;
}

body.mode-app .app-brand small {
  margin-top: 4px;
  color: rgba(255, 255, 255, .7);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

body.mode-app .iconbtn {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, .19);
  border-radius: 15px;
  background: rgba(255, 255, 255, .11);
  color: #fff;
  backdrop-filter: blur(8px);
  padding: 0;
}

body.mode-app #map {
  background: #dce7df;
}

body.mode-app .sheet {
  border: 1px solid rgba(15, 68, 45, .11);
  border-bottom: 0;
  border-radius: 30px 30px 0 0;
  padding: 19px 19px calc(19px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255, 255, 255, .99), #fffefb);
  box-shadow: 0 -18px 48px rgba(9, 47, 32, .14);
  scrollbar-width: thin;
  scrollbar-color: #bed0c2 transparent;
}

body.mode-app .sheet::before {
  content: "";
  display: block;
  width: 48px;
  height: 5px;
  margin: -8px auto 14px;
  border-radius: 999px;
  background: #d3dcd5;
}

body.mode-app .sheet h2,
body.mode-app .ride-status-title {
  color: var(--app-ink);
  letter-spacing: -.04em;
}

body.mode-app .btn {
  min-height: 53px;
  border-radius: 16px;
  font-weight: 780;
}

body.mode-app .btn.primary {
  background: linear-gradient(135deg, var(--app-green-800), #31895a);
  box-shadow: 0 9px 23px rgba(24, 91, 59, .22);
}

body.mode-app .btn.ghost {
  border-color: var(--app-line);
  background: #f7faf7;
}

/* Conductor */
body.mode-app #driverapp .driver-status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .9);
  font-size: 10px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

body.mode-app #driverapp .driver-status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aebdb4;
}

body.mode-app #driverapp .driver-status-pill.online .dot,
body.mode-app #driverapp .driver-status-pill.active .dot {
  background: #62e69a;
  box-shadow: 0 0 0 5px rgba(98, 230, 154, .13);
}

body.mode-app #driverapp .online-card {
  padding: 5px 0 2px;
}

body.mode-app #driverapp .radar {
  position: relative;
  width: 90px;
  height: 90px;
  margin-bottom: 14px;
  border: 1px solid #dbe8dd;
  border-radius: 28px;
  background: linear-gradient(145deg, #f7fbf7, #e7f0e8);
  color: var(--app-green-800);
  box-shadow: inset 0 0 0 7px rgba(255, 255, 255, .64), 0 10px 28px rgba(9, 47, 32, .1);
}

body.mode-app #driverapp .radar .app-icon {
  width: 43px;
  height: 43px;
}

body.mode-app #driverapp .radar.on {
  background: linear-gradient(145deg, #e9f8ed, #d5eedc);
}

body.mode-app #driverapp #swLbl {
  display: block;
  color: var(--app-ink);
  font-size: 23px;
  letter-spacing: -.035em;
}

body.mode-app #driverapp .idle {
  max-width: 330px;
  margin: 2px auto 12px;
  padding: 0;
  color: var(--app-muted);
  font-size: 13px;
}

body.mode-app #driverapp .health {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 13px 0;
}

body.mode-app #driverapp .health span {
  min-height: 52px;
  display: grid;
  place-items: center;
  padding: 7px 5px;
  border: 1px solid #e0e8e1;
  border-radius: 13px;
  background: #f8faf7;
  color: #556c5f;
  font-size: 10px;
  font-weight: 750;
  line-height: 1.25;
}

body.mode-app #driverapp .online-action {
  min-height: 57px;
}

body.mode-app #driverapp .offer-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

body.mode-app #driverapp .offer-title strong {
  font-size: 20px;
  letter-spacing: -.03em;
}

body.mode-app #driverapp .offer .fare {
  margin: 5px 0;
  color: var(--app-green-900);
  font-family: var(--app-font);
  font-size: 38px;
  letter-spacing: -.05em;
}

body.mode-app #driverapp .offer-queue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 9px 0;
}

body.mode-app #driverapp .offer-queue button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--app-line);
  border-radius: 13px;
  background: #fff;
  color: var(--app-green-900);
  font-size: 25px;
}

body.mode-app #driverapp .offer-position {
  min-width: 70px;
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

body.mode-app #driverapp .trip-panel {
  padding: 13px;
  border: 1px solid var(--app-line);
  border-radius: 18px;
  background: #fbfcfa;
}

body.mode-app #driverapp .route-line {
  position: relative;
  display: grid;
  grid-template-columns: 17px 1fr;
  gap: 10px;
  padding: 8px 0;
}

body.mode-app #driverapp .route-line:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 25px;
  bottom: -5px;
  width: 2px;
  background: #dce5dd;
}

body.mode-app #driverapp .route-line .pin {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--app-green-600);
  box-shadow: 0 0 0 5px rgba(47, 138, 89, .1);
}

body.mode-app #driverapp .route-line .pin.d {
  background: var(--app-danger);
  box-shadow: 0 0 0 5px rgba(180, 35, 24, .08);
}

body.mode-app #driverapp .route-line strong,
body.mode-app #driverapp .route-line span {
  display: block;
}

body.mode-app #driverapp .route-line span {
  color: var(--app-muted);
  font-size: 12px;
}

/* Menús y modales con apariencia de hoja nativa */
.menu {
  align-items: end !important;
  padding: 0 !important;
  background: rgba(6, 29, 19, .54) !important;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.menu > .card {
  width: 100% !important;
  max-width: 520px !important;
  max-height: min(90dvh, 760px);
  margin: 0 auto;
  overflow: auto;
  border: 1px solid rgba(15, 68, 45, .12) !important;
  border-bottom: 0 !important;
  border-radius: 28px 28px 0 0 !important;
  padding: 23px 19px calc(20px + env(safe-area-inset-bottom)) !important;
  background: #fff !important;
  box-shadow: 0 -24px 64px rgba(6, 29, 19, .25) !important;
  animation: appSheetUp .22s cubic-bezier(.2, .72, .25, 1);
}

.menu > .card::before {
  content: "";
  display: block;
  width: 46px;
  height: 5px;
  margin: -12px auto 17px;
  border-radius: 999px;
  background: #d3dcd5;
}

.menu .card h2 {
  color: var(--app-ink);
  letter-spacing: -.035em;
}

.menu .card > .btn,
.menu .card > a.btn {
  display: flex !important;
  align-items: center;
  justify-content: flex-start;
  min-height: 51px;
  padding: 12px 14px;
  text-align: left !important;
}

.menu .card > .btn.primary {
  justify-content: center;
  color: #fff;
}

.menu .card > .btn .app-icon,
.menu .card > a.btn .app-icon {
  margin-right: 11px;
}

.menu .profile-card,
.menu .support-card {
  max-height: 94dvh !important;
}

@keyframes appSheetUp {
  from { opacity: .45; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Estado de red */
#candamo-network-status {
  position: fixed;
  z-index: 2147483644;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  max-width: calc(100vw - 28px);
  align-items: center;
  gap: 8px;
  transform: translate(-50%, -220%);
  padding: 9px 13px;
  border-radius: 999px;
  background: #8f271e;
  color: #fff;
  box-shadow: 0 9px 24px rgba(64, 14, 10, .28);
  font-size: 11px;
  font-weight: 800;
  opacity: 0;
  visibility: hidden;
  transition: transform .22s ease, opacity .18s ease, visibility .18s ease;
}

#candamo-network-status.show {
  transform: translate(-50%, 0);
  opacity: 1;
  visibility: visible;
}

#candamo-network-status.restored {
  background: var(--app-green-800);
}

/* Guía de instalación */
#candamo-install-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483646;
  display: grid;
  place-items: end center;
  padding: 0;
  background: rgba(6, 29, 19, .55);
  backdrop-filter: blur(5px);
}

#candamo-install-card {
  width: 100%;
  max-width: 520px;
  padding: 25px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: #fff;
  color: var(--app-ink);
  box-shadow: 0 -24px 64px rgba(6, 29, 19, .25);
  animation: appSheetUp .22s ease-out;
}

#candamo-install-card h2 {
  margin: 0 0 7px;
  letter-spacing: -.04em;
}

#candamo-install-card p {
  margin: 0 0 15px;
  color: var(--app-muted);
  font-size: 13px;
  line-height: 1.5;
}

.candamo-install-steps {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.candamo-install-step {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 55px;
  padding: 10px 12px;
  border: 1px solid var(--app-line);
  border-radius: 15px;
  background: #f8faf7;
  font-size: 12px;
}

.candamo-install-step b {
  width: 28px;
  height: 28px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  background: var(--app-green-100);
  color: var(--app-green-900);
}

#candamo-install-close {
  width: 100%;
  min-height: 51px;
  border: 0;
  border-radius: 15px;
  background: var(--app-green-800);
  color: #fff;
  font-weight: 800;
}

@media (min-width: 760px) {
  body.mode-auth {
    padding-block: 28px !important;
  }

  .menu {
    place-items: center !important;
    padding: 24px !important;
  }

  .menu > .card,
  #candamo-install-card {
    width: min(92vw, 440px) !important;
    border: 1px solid rgba(15, 68, 45, .12) !important;
    border-radius: 28px !important;
  }
}

@media (max-width: 360px) {
  body.mode-auth {
    padding-inline: 12px !important;
  }

  body.mode-auth .card {
    padding: 19px !important;
  }

  .auth-trust span {
    font-size: 9px;
  }

  body.mode-app #driverapp .health {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
