/* RodaX - hoja de estilos compartida (escritorio + movil) */

:root {
  --rx-accent: #f2551f;
  --rx-accent-dark: #cf3f10;
  --rx-ink: #14171c;
  --rx-ink-soft: #5b6472;
  --rx-line: #e2e6ee;
  --rx-bg: #f5f7fb;
  --rx-panel: #ffffff;
  --rx-panel-dark: #1b2029;
  --rx-ok: #12a150;
  --rx-warn: #d98800;
  --rx-bad: #d92d20;
  --rx-info: #1d4ed8;
  --rx-radius: 14px;
  --rx-shadow: 0 6px 22px rgba(18, 26, 40, .10);
  --rx-font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--rx-font);
  background: var(--rx-bg);
  color: var(--rx-ink);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
a { color: var(--rx-info); }
small { color: var(--rx-ink-soft); }

.rx-is-hidden { display: none !important; }
/* el atributo hidden gana solo si ninguna clase de display lo pisa (p.ej. .rx-login) */
[hidden] { display: none !important; }
.rx-muted { color: var(--rx-ink-soft); }
.rx-right { margin-left: auto; }
.rx-center { text-align: center; }
.rx-mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Consolas, monospace; }

/* ------------------------------------------------------------- estructura */

.rx-app { min-height: 100vh; display: flex; flex-direction: column; }

.rx-topbar {
  display: flex; align-items: center; gap: .8rem;
  padding: .7rem 1rem; background: var(--rx-panel-dark); color: #fff;
  position: sticky; top: 0; z-index: 900;
}
.rx-brand { font-weight: 800; letter-spacing: .06em; font-size: 1.1rem; }
.rx-brand span { color: var(--rx-accent); }
.rx-topbar .rx-tag { font-size: .72rem; opacity: .7; }
.rx-user { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.rx-dot-live { width: 9px; height: 9px; border-radius: 50%; background: #6b7280; display: inline-block; }
.rx-dot-live.is-on { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, .22); }

.rx-main { flex: 1; padding: 1rem; max-width: 1440px; width: 100%; margin: 0 auto; }
.rx-main--wide { max-width: none; }

.rx-grid { display: grid; gap: 1rem; }
.rx-grid--2 { grid-template-columns: 1fr; }
.rx-grid--3 { grid-template-columns: 1fr; }
.rx-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rx-split { display: grid; gap: 1rem; grid-template-columns: 1fr; }

@media (min-width: 860px) {
  .rx-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rx-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rx-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .rx-split--side { grid-template-columns: 360px minmax(0, 1fr); }
  .rx-split--map { grid-template-columns: minmax(0, 1fr) 380px; }
}

/* ---------------------------------------------------------------- tarjetas */

.rx-card {
  background: var(--rx-panel); border: 1px solid var(--rx-line);
  border-radius: var(--rx-radius); box-shadow: var(--rx-shadow);
  overflow: hidden;
}
.rx-card__title {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .75rem 1rem; border-bottom: 1px solid var(--rx-line);
  font-weight: 700; font-size: .95rem; background: #fbfcfe;
}
.rx-card__body { padding: 1rem; }
.rx-card__body--tight { padding: .55rem .8rem; }
.rx-card__actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.rx-kpi { display: flex; flex-direction: column; gap: .15rem; }
.rx-kpi__value { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.rx-kpi__label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--rx-ink-soft); }

/* ---------------------------------------------------------------- botones */

.rx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--rx-line); background: #fff; color: var(--rx-ink);
  padding: .55rem .9rem; border-radius: 10px; font: inherit; font-weight: 600;
  cursor: pointer; transition: transform .06s ease, background .15s ease;
}
.rx-btn:hover { background: #f1f4fa; }
.rx-btn:active { transform: translateY(1px); }
.rx-btn--primary { background: var(--rx-accent); border-color: var(--rx-accent); color: #fff; }
.rx-btn--primary:hover { background: var(--rx-accent-dark); }
.rx-btn--dark { background: var(--rx-panel-dark); border-color: var(--rx-panel-dark); color: #fff; }
.rx-btn--success { background: var(--rx-ok); border-color: var(--rx-ok); color: #fff; }
.rx-btn--danger { background: var(--rx-bad); border-color: var(--rx-bad); color: #fff; }
.rx-btn--warn { background: var(--rx-warn); border-color: var(--rx-warn); color: #fff; }
.rx-btn--ghost { background: transparent; }
.rx-btn--sm { padding: .3rem .6rem; font-size: .8rem; border-radius: 8px; }
.rx-btn--block { width: 100%; }
.rx-btn[disabled] { opacity: .45; cursor: not-allowed; }
.rx-btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- formularios */

.rx-field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .7rem; }
.rx-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--rx-ink-soft); font-weight: 700; }
.rx-input, .rx-select, .rx-textarea {
  font: inherit; padding: .55rem .7rem; border: 1px solid var(--rx-line);
  border-radius: 10px; background: #fff; width: 100%; color: var(--rx-ink);
}
.rx-textarea { min-height: 110px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }
.rx-input:focus, .rx-select:focus, .rx-textarea:focus {
  outline: 2px solid rgba(242, 85, 31, .28); border-color: var(--rx-accent);
}
.rx-check { display: flex; align-items: center; gap: .45rem; font-size: .88rem; }
.rx-check input { width: 18px; height: 18px; accent-color: var(--rx-accent); }
.rx-form-row { display: grid; gap: .7rem; grid-template-columns: 1fr; }
@media (min-width: 700px) {
  .rx-form-row--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rx-form-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.rx-hint { font-size: .78rem; color: var(--rx-ink-soft); }
.rx-error { font-size: .8rem; color: var(--rx-bad); }

/* ---------------------------------------------------------------- tabs */

.rx-tabs { display: flex; gap: .3rem; flex-wrap: wrap; padding: .5rem 1rem 0; background: #fbfcfe; border-bottom: 1px solid var(--rx-line); }
.rx-tab {
  border: 1px solid transparent; border-bottom: 0; background: transparent;
  padding: .5rem .85rem; border-radius: 10px 10px 0 0; font: inherit; font-weight: 600;
  color: var(--rx-ink-soft); cursor: pointer;
}
.rx-tab.is-active { background: #fff; border-color: var(--rx-line); color: var(--rx-ink); }
.rx-panel { padding: 1rem; display: none; }
.rx-panel.is-active { display: block; }

/* ---------------------------------------------------------------- tablas */

.rx-table-wrap { overflow: auto; border-radius: var(--rx-radius); }
.rx-table { border-collapse: collapse; width: 100%; font-size: .88rem; background: #fff; }
.rx-table th, .rx-table td { padding: .5rem .65rem; border-bottom: 1px solid var(--rx-line); text-align: left; white-space: nowrap; }
.rx-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--rx-ink-soft); background: #f7f9fd; position: sticky; top: 0; }
.rx-table tbody tr:hover { background: #fbfcfe; }
.rx-table td.rx-num, .rx-table th.rx-num { text-align: right; font-variant-numeric: tabular-nums; }
.rx-row--leader td { background: rgba(242, 85, 31, .07); font-weight: 700; }
.rx-row--me td { background: rgba(29, 78, 216, .10); }

/* ---------------------------------------------------------------- badges */

.rx-badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .16rem .5rem;
  border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em;
  background: #eef1f7; color: var(--rx-ink-soft);
}
.rx-badge--live { background: rgba(18, 161, 80, .14); color: #0b7a3c; }
.rx-badge--paused { background: rgba(217, 136, 0, .16); color: #96610a; }
.rx-badge--done { background: rgba(29, 78, 216, .13); color: #1b3fa8; }
.rx-badge--warn { background: rgba(217, 45, 32, .13); color: #a91d14; }
.rx-badge--accent { background: rgba(242, 85, 31, .14); color: var(--rx-accent-dark); }
.rx-chips { display: flex; gap: .3rem; flex-wrap: wrap; }
.rx-chip { border: 1px solid var(--rx-line); border-radius: 999px; padding: .2rem .6rem; font-size: .78rem; background: #fff; cursor: pointer; }
.rx-chip.is-on { background: var(--rx-accent); border-color: var(--rx-accent); color: #fff; }

/* ---------------------------------------------------------------- listas */

.rx-list { display: flex; flex-direction: column; gap: .5rem; }
.rx-row { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--rx-line); border-radius: 10px; background: #fff; }
.rx-row__main { flex: 1; min-width: 0; }
.rx-row__title { font-weight: 700; font-size: .92rem; }
.rx-row__meta { font-size: .78rem; color: var(--rx-ink-soft); }
.rx-empty { padding: 1.4rem; text-align: center; color: var(--rx-ink-soft); border: 1px dashed var(--rx-line); border-radius: var(--rx-radius); background: #fcfdff; }
.rx-spinner { width: 18px; height: 18px; border: 2px solid var(--rx-line); border-top-color: var(--rx-accent); border-radius: 50%; animation: rx-spin .8s linear infinite; display: inline-block; }
@keyframes rx-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- modal */

.rx-modal { position: fixed; inset: 0; background: rgba(15, 20, 30, .55); display: flex; align-items: center; justify-content: center; z-index: 1200; padding: 1rem; }
.rx-modal__box { background: #fff; border-radius: var(--rx-radius); max-width: 720px; width: 100%; max-height: 88vh; overflow: auto; box-shadow: var(--rx-shadow); }
.rx-modal__head { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-bottom: 1px solid var(--rx-line); }
.rx-modal__body { padding: 1rem; }
.rx-modal__foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .8rem 1rem; border-top: 1px solid var(--rx-line); }

/* ---------------------------------------------------------------- toasts */

.rx-toasts { position: fixed; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: .4rem; z-index: 1500; max-width: min(92vw, 420px); }
.rx-toast { background: var(--rx-panel-dark); color: #fff; padding: .6rem .85rem; border-radius: 10px; font-size: .86rem; box-shadow: var(--rx-shadow); opacity: .96; }
.rx-toast--ok { background: #0b7a3c; }
.rx-toast--error { background: var(--rx-bad); }
.rx-toast--warn { background: var(--rx-warn); color: #1b1200; }
.rx-toast.is-out { opacity: 0; transform: translateY(6px); transition: .3s ease; }

/* ---------------------------------------------------------------- mapa */

.rx-map { height: 320px; border-radius: var(--rx-radius); background: #dfe6f0; z-index: 1; }
.rx-map--tall { height: 460px; }
.rx-map--full { height: calc(100vh - 190px); }
.rx-map--phone { height: 42vh; min-height: 240px; border-radius: 0; }

.rx-pin-wrap { background: transparent; border: 0; }
.rx-pin { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: #fff; }
.rx-pin__dot {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; border-radius: 50%;
  background: var(--pin, #1d4ed8); border: 2px solid #fff;
  box-shadow: 0 3px 10px rgba(16, 24, 40, .35);
}
.rx-pin--self .rx-pin__dot { background: var(--rx-accent); }
.rx-pin__tag {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 2px; font-size: 10px; font-weight: 800; color: var(--rx-ink);
  background: rgba(255, 255, 255, .92); border-radius: 6px; padding: 0 4px; white-space: nowrap;
}
.rx-pin--blink .rx-pin__dot { animation: rx-blink 1s steps(2, start) infinite; }
.rx-pin--off { opacity: .38; }
.rx-pin--hidden { display: none; }
@keyframes rx-blink { 50% { opacity: .15; } }

.rx-sos {
  width: 40px; height: 40px; border-radius: 50%; background: var(--rx-bad); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: .72rem;
  border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(217, 45, 32, .28);
  animation: rx-sos 1.1s ease-in-out infinite;
}
@keyframes rx-sos { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.16); } }

.rx-map-legend { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .78rem; color: var(--rx-ink-soft); }

/* ------------------------------------------------------- pantalla ciclista */

.rx-phone { max-width: 480px; margin: 0 auto; background: #fff; min-height: 100vh; display: flex; flex-direction: column; box-shadow: 0 0 40px rgba(16, 24, 40, .12); }
@media (min-width: 900px) {
  .rx-phone { min-height: calc(100vh - 3rem); margin: 1.5rem auto; border-radius: 22px; overflow: hidden; border: 1px solid var(--rx-line); }
  body.rx-body-phone { background: #eef1f7; }
}

.rx-statusbar { background: var(--rx-accent); color: #fff; padding: .7rem 1rem; display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.rx-statusbar--paused { background: var(--rx-warn); }
.rx-statusbar--off { background: #6b7280; }
.rx-statusbar__icon { font-size: 1.1rem; }

.rx-stats { display: grid; grid-template-columns: 1fr 1fr; }
.rx-stat { padding: .9rem .8rem .7rem; text-align: center; border-bottom: 1px solid var(--rx-line); }
.rx-stat:nth-child(odd) { border-right: 1px solid var(--rx-line); }
.rx-stat__label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--rx-ink-soft); font-weight: 700; }
.rx-stat__value { font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.rx-stat__value--big { font-size: 2.4rem; }

.rx-actions { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: 1rem; }
.rx-round {
  width: 62px; height: 62px; border-radius: 50%; border: 2px solid var(--rx-accent);
  background: #fff; color: var(--rx-accent); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: .15s ease;
}
.rx-round svg { width: 24px; height: 24px; }
.rx-round:hover { background: rgba(242, 85, 31, .08); }
.rx-round--main { background: var(--rx-accent); color: #fff; }
.rx-round--sm { width: 46px; height: 46px; }
.rx-round--danger { border-color: var(--rx-bad); color: var(--rx-bad); }
.rx-round--danger.rx-round--main { background: var(--rx-bad); color: #fff; }
.rx-round.is-blinking { animation: rx-blink .8s steps(2, start) infinite; }

.rx-substats { display: flex; border-bottom: 1px solid var(--rx-line); }
.rx-substat { flex: 1; padding: .6rem; text-align: center; }
.rx-substat + .rx-substat { border-left: 1px solid var(--rx-line); }

.rx-sheet { padding: .9rem; overflow-y: auto; flex: 1; }
.rx-sheet--fixed { max-height: 34vh; }

.rx-chat { display: flex; flex-direction: column; gap: .45rem; }
.rx-chat__msg { background: #f1f4fa; border-radius: 12px; padding: .45rem .65rem; font-size: .86rem; }
.rx-chat__msg.is-me { background: rgba(242, 85, 31, .14); }
.rx-chat__who { font-size: .72rem; font-weight: 800; color: var(--rx-ink-soft); display: block; }
.rx-chat__form { display: flex; gap: .4rem; margin-top: .5rem; }

.rx-sos-card { border: 1px solid var(--rx-bad); border-radius: var(--rx-radius); padding: .7rem .8rem; background: rgba(217, 45, 32, .06); display: flex; flex-direction: column; gap: .5rem; }
.rx-sos-card__title { font-weight: 800; color: var(--rx-bad); }

/* ---------------------------------------------------------------- portal */

.rx-portal { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.2rem; background: radial-gradient(1200px 600px at 15% -5%, #ffe9df, transparent), var(--rx-bg); }
.rx-portal__card { width: 100%; max-width: 980px; background: #fff; border-radius: 22px; box-shadow: var(--rx-shadow); overflow: hidden; }
.rx-portal__head { padding: 1.6rem; background: var(--rx-panel-dark); color: #fff; }
.rx-portal__head h1 { font-size: 2rem; margin: 0; }
.rx-portal__head h1 span { color: var(--rx-accent); }
.rx-portal__body { padding: 1.4rem; display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 820px) {
  .rx-portal__body { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.rx-login { border: 1px solid var(--rx-line); border-radius: var(--rx-radius); padding: 1.1rem; display: flex; flex-direction: column; gap: .5rem; }
.rx-login h3 { display: flex; align-items: center; gap: .5rem; }
.rx-login__icon { width: 34px; height: 34px; border-radius: 9px; background: rgba(242, 85, 31, .12); color: var(--rx-accent-dark); display: flex; align-items: center; justify-content: center; font-weight: 900; }
.rx-login--mobile { border-style: dashed; }

.rx-alert { border-left: 4px solid var(--rx-accent); background: #fff6f2; padding: .7rem .9rem; border-radius: 8px; font-size: .88rem; }
.rx-alert--warn { border-color: var(--rx-warn); background: #fffaf0; }
.rx-alert--bad { border-color: var(--rx-bad); background: #fff3f2; }
.rx-alert--ok { border-color: var(--rx-ok); background: #f1fbf5; }

.rx-scroll { max-height: 320px; overflow: auto; }
