:root {
  --bg: #0b1329;
  --card: #131f3f;
  --card-2: #182648;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef2fb;
  --muted: #8d99b8;
  --blue: #4f8cff;
  --cyan: #35e0f5;
  --coral: #ff5d5d;
  --violet: #a78bfa;
  --amber: #fbbf24;
  --green: #34d399;
  --orange: #fb923c;
  --red: #ff6b6b;
  --gray: #9aa7c7;
  --radius: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { min-height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(900px 480px at 50% -180px, #16255c 0%, rgba(22, 37, 92, 0) 70%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  position: relative;
}

.hidden { display: none !important; }

/* ============ HEADER ============ */
.app-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

.sun-icon {
  width: 42px; height: 42px; flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd76a, #ff9f43);
  box-shadow: 0 6px 18px rgba(255, 165, 60, 0.35);
  display: grid; place-items: center;
}

.welcome { display: block; font-size: 12px; color: var(--muted); }
.brand { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; }

/* ============ MODAL INSTALACION ============ */
.modal-icon {
  width: 76px; height: 76px;
  margin: 0 auto 12px;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(79, 140, 255, 0.35);
  border: 1px solid var(--border);
}
.modal-icon img { display: block; width: 100%; height: 100%; }

/* ============ SECCION ============ */
.section { margin-top: 24px; }
.section-title { font-size: 16px; font-weight: 800; margin-bottom: 12px; }

/* ============ SYNC CARD ============ */
.sync-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.cal-icon {
  width: 38px; height: 38px; flex: none;
  border-radius: 10px;
  background: rgba(53, 224, 245, 0.13);
  color: var(--cyan);
  display: grid; place-items: center;
}
.sync-card .t { font-size: 11px; color: var(--muted); }
.sync-card .v { font-size: 13px; font-weight: 600; line-height: 1.35; }

/* ============ FUEL GRID / CARDS ============ */
.fuel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.fuel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.fuel-main {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  width: 100%;
}
.fuel-icon { flex: none; line-height: 0; }
.fuel-icon svg { width: 38px; height: 38px; }
.fuel-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.fuel-badge {
  font-size: 10px;
  font-weight: 800;
  color: var(--fc);
  background: color-mix(in srgb, var(--fc) 16%, transparent);
  border-radius: 999px;
  padding: 4px 9px;
  letter-spacing: 0.02em;
}
.fuel-price {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
.fuel-price small { font-size: 11px; font-weight: 600; color: var(--muted); margin-right: 2px; }
.diff { font-size: 11.5px; font-weight: 800; }
.diff.up { color: var(--green); }
.diff.down { color: var(--red); }
.diff.flat { color: var(--muted); }

.btn-all {
  width: 100%;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ff6b6b, #f43f5e);
  border: none;
  border-radius: 999px;
  padding: 13px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(244, 63, 94, 0.3);
  transition: transform 0.1s;
}
.btn-all:active { transform: scale(0.98); }

/* ============ SUB HEADERS ============ */
.sub-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.back-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: grid; place-items: center;
}
.sub-header h2 { font-size: 18px; font-weight: 800; }

/* ============ ACCORDION HISTORICO ============ */
.accordion { display: flex; flex-direction: column; gap: 10px; }
.acc-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.acc-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.acc-head .acc-meta { display: flex; align-items: center; gap: 10px; }
.acc-head .count { font-size: 11px; color: var(--muted); font-weight: 600; }
.chev { color: var(--muted); transition: transform 0.25s ease; }
.acc-item.open .chev { transform: rotate(180deg); }
.acc-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}
.acc-item.open .acc-body { grid-template-rows: 1fr; }
.acc-inner { overflow: hidden; min-height: 0; }
.acc-inner .fuel-grid { padding: 0 14px 14px; }
.acc-inner .fuel-card { background: var(--card-2); }

/* ============ GRUPO DE BOTONES ============ */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.btn-nav {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 800;
  border-radius: 999px;
  padding: 14px 10px;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
}
.btn-nav:active { transform: scale(0.97); }
.btn-nav-history {
  color: #bcd2ff;
  background: rgba(79, 140, 255, 0.16);
  border: 1px solid rgba(79, 140, 255, 0.5);
}
.btn-nav-history:active { background: rgba(79, 140, 255, 0.3); }
.btn-nav-support {
  color: #06222b;
  background: linear-gradient(135deg, #35e0f5, #22b8d6);
  border: none;
  box-shadow: 0 10px 24px rgba(34, 184, 214, 0.35);
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 22, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: linear-gradient(170deg, #16234d, #0e1834);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px 20px 18px;
  text-align: center;
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.modal h3 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.modal-lead { font-size: 13px; color: var(--muted); line-height: 1.5; margin-bottom: 16px; }
.modal-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.modal-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px;
  text-decoration: none;
}
.btn-sync {
  width: 100%;
  font-size: 13.5px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #4f8cff, #3b6fe0);
  border: none;
  border-radius: 999px;
  padding: 13px;
  cursor: pointer;
}
.btn-sync:disabled { opacity: 0.55; cursor: wait; }
.sync-msg { min-height: 18px; font-size: 12px; margin-top: 10px; }
.sync-msg.ok { color: var(--green); }
.sync-msg.err { color: var(--red); }
.modal-foot { margin-top: 14px; font-size: 10.5px; color: var(--muted); line-height: 1.6; }
.modal-foot a { color: var(--blue); }

/* ============ ESTADOS ============ */
.loading { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; grid-column: 1 / -1; }
.error-box {
  color: var(--red);
  background: rgba(255, 93, 93, 0.1);
  border: 1px solid rgba(255, 93, 93, 0.35);
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
  text-align: center;
  grid-column: 1 / -1;
}
