/* SpeedX — tema oscuro azul marino, idéntico al diseño de la plataforma:
   tarjetas azul profundo con borde luminoso, logo SpeedX grande con FEHU
   en la esquina, pestañas en rejilla con iconos y KPIs con chip circular. */
:root {
  color-scheme: dark;
  --navy1: #0d2c6e;
  --navy2: #050f27;
  --card1: #0c2563;
  --card2: #081a42;
  --blue: #2f8bff;
  --blue-dark: #1d6fe0;
  --light-blue: #a9c8f8;
  --tab-active: #9cc6ff;
  --tab-idle: #aebadd;
  --bg: #02091a;
  --text: #eef3ff;
  --muted: #96a9d1;
  --border: rgba(110, 165, 255, .20);
  --border-strong: rgba(110, 165, 255, .35);
  --green: #3ecf74;
  --red: #ff8a7a;
  --amber: #ffc46b;
  --badge: #ffa04d;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(24, 84, 190, .35) 0%, rgba(24, 84, 190, 0) 60%),
    linear-gradient(180deg, #061a3d 0%, var(--bg) 340px);
  background-color: var(--bg);
  min-height: 100vh;
  padding: 14px 12px 30px;
}
.brand-card, main, footer { max-width: 980px; margin-left: auto; margin-right: auto; }

/* ---------- Tarjeta de marca ---------- */
.brand-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--navy1), var(--navy2));
  border: 1px solid rgba(110, 165, 255, .30);
  border-radius: 22px;
  padding: 16px 18px 60px;
  margin-bottom: 14px;
  box-shadow: inset 0 2px 0 rgba(62, 162, 255, .55), 0 12px 30px rgba(0, 3, 16, .5);
}
.brand-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, rgba(62, 162, 255, 0), rgba(62, 162, 255, .9) 30%, #57b6ff 72%, rgba(62, 162, 255, .45));
}
.brand-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-title { font-size: 16px; font-weight: 600; color: var(--light-blue); }
.brand-logo {
  display: block;
  width: min(80%, 540px);
  height: auto;
  margin: 16px auto 2px;
  filter: drop-shadow(0 0 10px rgba(120, 180, 255, .35));
}
.brand-fehu {
  position: absolute;
  right: 14px;
  bottom: 10px;
  width: 72px;
  height: auto;
  opacity: .96;
  filter: drop-shadow(0 0 6px rgba(120, 180, 255, .30));
}
.btn.ghost {
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--border-strong);
  color: #dbe7ff;
  box-shadow: none;
}

/* ---------- Botones ---------- */
.btn {
  background: linear-gradient(180deg, var(--blue), var(--blue-dark));
  color: #fff; border: 0; border-radius: 10px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 14px rgba(31, 111, 224, .35);
}
.btn.secondary {
  background: rgba(140, 175, 255, .12);
  color: #dbe7ff;
  border: 1px solid var(--border-strong);
  box-shadow: none;
}
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: linear-gradient(180deg, #e05a4e, #c0392b); }

/* ---------- Pestañas en rejilla con iconos ---------- */
main { padding: 0; }
.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: linear-gradient(165deg, var(--card1), var(--card2));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px;
  margin: 0 0 14px;
  box-shadow: 0 8px 22px rgba(0, 4, 20, .35);
}
.tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 2px 8px;
  background: transparent; border: 0; border-radius: 14px;
  color: var(--tab-idle); font-size: 13px; cursor: pointer;
  position: relative;
}
.tab-btn .tab-icon { display: block; line-height: 0; }
.tab-btn .tab-icon svg { width: 24px; height: 24px; }
.tab-btn.active { background: rgba(88, 148, 255, .20); color: var(--tab-active); }
.tab-badge {
  position: absolute;
  top: 4px; left: calc(50% + 3px);
  background: var(--badge); color: #fff;
  font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; line-height: 20px;
  border-radius: 999px; padding: 0 5px; text-align: center;
}

/* ---------- Tarjetas y KPIs ---------- */
.card {
  background: linear-gradient(165deg, var(--card1), var(--card2));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 8px 22px rgba(0, 4, 20, .35);
}
.card h2, .card h3 { margin: 0 0 8px; color: #fff; }
.card h2 { font-size: 20px; }
.card h3 { font-size: 17px; }
.card p, .card li { color: #c9d7f5; font-size: 15px; line-height: 1.55; }
.card ul { margin: 6px 0; padding-left: 20px; }
.card li { margin: 7px 0; }
.card p strong, .card li strong { color: #fff; }
h3 { color: #fff; }
strong { color: #fff; }
/* Títulos de sección fuera de tarjeta, como en la plataforma */
.section-title { font-size: 24px; font-weight: 800; color: #fff; margin: 4px 0 4px; }
.section-sub { color: var(--muted); font-size: 14.5px; margin: 0 0 14px; }
/* Tarifas en tres cuadros */
.rates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 12px; }
.rate { background: rgba(70, 130, 255, .14); border-radius: 14px; padding: 16px 6px 13px; text-align: center; }
.rate .amount { font-size: 25px; font-weight: 800; color: #fff; line-height: 1.1; }
.rate .amount.blue { color: #57b6ff; }
.rate .amount.cyan { color: #4fd8ff; }
.rate .cap { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 7px; line-height: 1.5; }
.muted { color: var(--muted); font-size: 13px; }
.pill { display: inline-block; background: rgba(70, 130, 255, .18); color: var(--light-blue); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.pill.tampa { background: rgba(255, 196, 80, .16); color: var(--amber); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 12px; }
.kpi {
  background: linear-gradient(165deg, var(--card1), var(--card2));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(0, 4, 20, .35);
  display: flex; flex-direction: column; gap: 9px;
}
.kpi-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(90, 150, 255, .16); color: #7db4ff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; line-height: 1;
}
.kpi-icon svg { width: 22px; height: 22px; }
.kpi .num { font-size: 30px; font-weight: 800; color: #fff; line-height: 1.05; }
.kpi .lbl { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.collapsed-card { cursor: pointer; }
.collapsed-card .body { display: none; margin-top: 10px; }
.collapsed-card.open .body { display: block; }
.progress { background: rgba(255, 255, 255, .12); border-radius: 999px; height: 10px; overflow: hidden; }
.progress > div { background: linear-gradient(90deg, #25a854, var(--green)); height: 100%; }

/* ---------- Tablas y formularios ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid rgba(110, 165, 255, .12); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
input, select, textarea {
  width: 100%; max-width: 100%; min-width: 0; padding: 9px 10px;
  background: #0a1d42; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px;
  font-size: 14px; margin: 4px 0 10px;
}
/* iOS Safari: el control de fecha nativo se desborda del contenedor y
   centra el texto; se normaliza para que quede alineado como los demás
   campos, dentro de su tarjeta. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-height: 42px;
  text-align: left;
}
input::placeholder, textarea::placeholder { color: #6d82ad; }
label { font-size: 13px; font-weight: 600; color: #c6d5f2; }
.form { max-width: 460px; margin: 26px auto; }
hr { border: 0; border-top: 1px solid rgba(110, 165, 255, .18); margin: 18px 0; }
.hidden { display: none !important; }
.copy-btn { border: 1px solid var(--border-strong); background: rgba(140, 175, 255, .12); color: #cfe1ff; border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer; margin-left: 8px; }
.copy-btn.done { background: rgba(62, 207, 116, .18); border-color: var(--green); color: var(--green); }
.tracking { font-family: ui-monospace, monospace; font-size: 13px; word-break: break-all; }
.subtabs { margin-top: 10px; }
.subtabs summary { cursor: pointer; font-weight: 600; padding: 6px 0; color: #cfe1ff; }

/* ---------- Calendario, avisos y pie ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day { background: #0a1f47; border: 1px solid var(--border); border-radius: 10px; padding: 8px; min-height: 64px; cursor: pointer; font-size: 13px; color: #dbe7ff; }
.cal-day.today { border-color: var(--blue); outline: 2px solid rgba(169, 200, 248, .5); }
.cal-day.empty { background: transparent; border: 0; cursor: default; }
.cal-day .n { font-weight: 700; color: #fff; }
.highlight { outline: 3px solid var(--blue); }
.alert { background: rgba(255, 196, 80, .10); border: 1px solid rgba(255, 196, 80, .4); color: #ffd98a; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; }
.error { background: rgba(255, 110, 90, .10); border: 1px solid rgba(255, 110, 90, .45); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; color: #ff9d8f; }
footer { text-align: center; color: #7186ad; font-size: 12px; padding: 18px 0 4px; }
footer img { height: 30px; width: auto; opacity: .95; filter: drop-shadow(0 0 4px rgba(120, 180, 255, .3)); }
a { color: var(--tab-active); }

/* Route cards (Rutas) — platform layout */
.route-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: linear-gradient(90deg, #1f6bff, #3f9dff);
  color: #fff; border-radius: 999px; padding: 4px 12px;
  font-size: 12px; font-weight: 600; letter-spacing: .08em;
  box-shadow: 0 4px 14px rgba(31, 107, 255, .45);
  vertical-align: middle; white-space: nowrap;
}
.route-pill svg { width: 14px; height: 14px; }
.route-pill strong { font-size: 13.5px; font-weight: 800; letter-spacing: .04em; }
.route-pill.small { padding: 3px 10px; font-size: 11px; }
.route-pill.small strong { font-size: 12.5px; }
.rc-subrow { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-top: 7px; }
.rc-namerow { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.rc-name { font-size: 19px; font-weight: 800; color: #fff; line-height: 1.2; }
.rc-sub { margin-top: 3px; font-size: 11.5px; font-weight: 600; letter-spacing: .07em; color: #8fb0e8; text-transform: uppercase; }
.rc-nums { text-align: right; flex-shrink: 0; }
.rc-nums .rc-paq, .rc-nums .rc-pay { display: block; }
.rc-paq { font-size: 25px; font-weight: 800; color: #fff; line-height: 1.1; }
.rc-pay { font-size: 17px; font-weight: 700; color: #57b6ff; margin-top: 2px; }
.share-bar { background: rgba(255, 255, 255, .08); border-radius: 999px; height: 6px; overflow: hidden; margin-top: 12px; }
.share-bar > div { background: linear-gradient(90deg, #1f6bff, #57b6ff); height: 100%; border-radius: 999px; }
.stat-boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.stat-box { background: rgba(88, 138, 255, .13); border-radius: 14px; padding: 12px 4px 10px; text-align: center; }
.stat-num { font-size: 23px; font-weight: 800; color: #fff; line-height: 1.1; }
.stat-label { margin-top: 4px; font-size: 10px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; color: #8fb0e8; }
.inner-box { background: rgba(88, 138, 255, .10); border-radius: 14px; padding: 12px 14px; margin-top: 12px; }
.ib-head {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  background: none; border: none; padding: 0; margin: 0;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.ib-text { flex: 1; min-width: 0; }
.ib-title { display: block; font-size: 11px; font-weight: 700; letter-spacing: .07em; color: #8fb0e8; }
.ib-title.orange { color: var(--amber); }
.ib-summary { display: block; margin-top: 4px; font-size: 15.5px; font-weight: 650; color: #fff; }
.ib-sub { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.ib-ver { color: #57b6ff; font-weight: 600; font-size: 14.5px; white-space: nowrap; padding-top: 14px; }
.ib-ver .chev { display: inline-block; transition: transform .2s; }
.toggle-box.open .ib-ver .chev { transform: rotate(180deg); }
.ib-body { display: none; margin-top: 10px; }
.toggle-box.open .ib-body { display: block; }
.ib-body table { width: 100%; }
.avance { margin-top: 14px; border-top: 1px solid rgba(255, 255, 255, .07); padding-top: 12px; }
.avance-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.avance-label { font-size: 11px; font-weight: 700; letter-spacing: .07em; color: #8fb0e8; }
.avance-nums { font-size: 14px; color: #c9d7f5; }
.avance-nums strong { color: #fff; }
.pct-blue { color: #57b6ff; font-weight: 700; }
.rc-progress { background: rgba(255, 255, 255, .08); border-radius: 999px; height: 8px; overflow: hidden; margin-top: 8px; }
.rc-progress > div { background: linear-gradient(90deg, #1f6bff, #57b6ff); height: 100%; border-radius: 999px; }
.unconnected-card { border-color: rgba(255, 160, 77, .55); }
.unc-title { color: var(--amber); font-weight: 700; font-size: 16.5px; margin-bottom: 2px; }
.unc-row { padding: 10px 0 8px; border-top: 1px solid rgba(255, 255, 255, .07); }
.unc-row:first-of-type { border-top: none; }
.unc-namerow { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 16px; font-weight: 650; color: #fff; }
.unc-sub { margin-top: 3px; font-size: 14px; color: var(--muted); }
.unconnected-wrap {
  border: 1px solid rgba(255, 160, 77, .55);
  border-radius: 18px;
  padding: 14px 14px 2px;
  margin-bottom: 12px;
}
.unconnected-wrap .unc-title { margin-bottom: 12px; }

/* Aviso de instalación (PWA) */
.install-popup {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60;
  background: linear-gradient(180deg, #0d2c6e, #050f27);
  border: 1px solid rgba(87, 182, 255, .45); border-top: 3px solid #2f8dff;
  border-radius: 16px; padding: 14px 14px 16px; color: #eef4ff;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .55);
  animation: ip-in .28s ease-out;
}
@keyframes ip-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.ip-head { display: flex; gap: 12px; align-items: flex-start; }
.ip-icon { width: 52px; height: 52px; border-radius: 12px; flex: none; }
.ip-titles { flex: 1; min-width: 0; }
.ip-titles strong { display: block; font-size: 17px; }
.ip-titles span { display: block; font-size: 13.5px; color: #bcd4f7; margin-top: 2px; }
.ip-close {
  background: none; border: none; color: #bcd4f7; font-size: 24px; line-height: 1;
  padding: 0 2px; cursor: pointer; flex: none;
}
.ip-actions { display: flex; gap: 10px; margin-top: 14px; }
.ip-actions .btn { flex: 1; }
.ip-steps { margin: 12px 0 14px; padding-left: 20px; font-size: 14.5px; line-height: 1.5; color: #dbe9ff; }
.ip-steps li { margin: 4px 0; }
.ip-ok { width: 100%; }
