/* ============================================
   RUTERO — estilos
   Mobile-first, temas claro/oscuro, alto contraste
   ============================================ */

/* --- Variables: tema claro (default) --- */
:root,
[data-theme="light"] {
  --bg: #f4f6f8;
  --bg-card: #ffffff;
  --bg-card-done: #e8eaf0;
  --bg-header: #ffffff;
  --bg-bottom: #ffffff;
  --bg-pill: #eef1f5;
  --bg-pill-active: #1e88e5;
  --bg-progress: #e0e3e8;
  --bg-progress-fill: #1e88e5;
  --bg-session: #ffffff;
  --bg-modal: #ffffff;
  --bg-toast: #1a1a1a;

  --text: #1a1a1a;
  --text-sub: #5a6470;
  --text-muted: #8a94a0;
  --text-card: #0d1b2a;
  --text-card-done: #8a94a0;
  --text-pill: #2a3540;
  --text-pill-active: #ffffff;
  --text-on-accent: #ffffff;
  --text-toast: #ffffff;

  --border: #d8dde3;
  --border-strong: #b0b8c2;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 10px 40px rgba(0, 0, 0, 0.2);

  --accent: #1e88e5;
  --accent-dark: #0d47a1;
  --accent-text: #1e88e5;        /* color del texto "producto" (alias grande y bold) */
  --success: #2e7d32;
  --warning: #f57c00;
  --danger: #c62828;
  --swipe-ok: #2e7d32;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Tema oscuro --- */
[data-theme="dark"] {
  --bg: #0e1117;
  --bg-card: #1a2030;
  --bg-card-done: #1a203088;
  --bg-header: #161b25;
  --bg-bottom: #161b25;
  --bg-pill: #1a2030;
  --bg-pill-active: #1e88e5;
  --bg-progress: #2a3242;
  --bg-progress-fill: #42a5f5;
  --bg-session: #161b25;
  --bg-modal: #1a2030;
  --bg-toast: #f0f0f0;

  --text: #f0f3f7;
  --text-sub: #b0b8c2;
  --text-muted: #6a7480;
  --text-card: #f0f3f7;
  --text-card-done: #6a7480;
  --text-pill: #d0d6de;
  --text-pill-active: #ffffff;
  --text-on-accent: #ffffff;
  --text-toast: #0e1117;

  --border: #2a3242;
  --border-strong: #4a5462;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-modal: 0 10px 40px rgba(0, 0, 0, 0.6);

  --accent: #42a5f5;
  --accent-dark: #1976d2;
  --accent-text: #82b1ff;        /* azul claro brillante para max contraste en dark */
  --success: #66bb6a;
  --warning: #ffa726;
  --danger: #ef5350;
  --swipe-ok: #66bb6a;
}

/* --- Reset y base --- */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
}

body {
  overscroll-behavior: none;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}

.hidden { display: none !important; }

/* --- Pantallas --- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#loading {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.loading-inner {
  text-align: center;
  color: var(--text-sub);
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 16px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Cabecera --- */
.app-header {
  flex: 0 0 auto;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  padding: calc(var(--safe-top) + 8px) 12px 8px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.header-title h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.header-title .subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--text-sub);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-pill);
  color: var(--text-sub);
  transition: background 0.15s;
}

.icon-btn:active {
  background: var(--border);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

/* --- Filtro de días --- */
.day-filter {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.day-filter::-webkit-scrollbar { display: none; }

.day-pill {
  flex: 0 0 auto;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: 19px;
  background: var(--bg-pill);
  color: var(--text-pill);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.day-pill:active {
  transform: scale(0.95);
}

.day-pill.active {
  background: var(--bg-pill-active);
  color: var(--text-pill-active);
}

.day-pill-all {
  font-size: 12px;
  padding: 0 14px;
}

/* --- Progreso --- */
.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 8px;
}

.progress-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex: 0 0 auto;
}

.progress-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.progress-pct {
  font-size: 12px;
  color: var(--text-sub);
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-progress);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--bg-progress-fill);
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease-out;
}

/* --- Cronómetro de sesión --- */
.session-bar {
  background: var(--bg-session);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 6px;
}

.session-times {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.session-time {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.time-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.time-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.session-btn {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}

.session-btn:active { transform: scale(0.98); }

.session-btn.start {
  background: var(--success);
  color: white;
}

.session-btn.end {
  background: var(--danger);
  color: white;
}

.session-btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* --- Lista de tarjetas --- */
.card-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.card-list::-webkit-scrollbar { width: 0; }

/* --- Tarjeta --- */
.card {
  position: relative;
  background: var(--bg-card);
  border-radius: 14px;
  padding: 14px 14px 14px 68px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  min-height: 108px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
  touch-action: pan-y;
  transition: transform 0.2s ease-out, opacity 0.2s;
  will-change: transform;
}

/* Todos los textos de la tarjeta deben respetar el espacio de los botones (✓/🗺) */
.card-alias,
.card-direccion,
.card-producto,
.card-donde,
.card-loc,
.card-done-time {
  padding-right: 90px;
}

.card.swiping {
  transition: none;
}

.card.done {
  background: var(--bg-card-done);
  /* sin opacity global: cada elemento se atenúa individualmente */
}

.card.done .card-alias,
.card.done .card-producto {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: var(--text-muted);
}

.card.done .card-alias {
  color: var(--text-card);
  opacity: 0.55;
}

.card.done .card-producto {
  opacity: 0.55;
}

.card.done .card-direccion {
  color: var(--text-muted);
  /* sin strikethrough, sigue legible */
}

.card-orden {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.card.done .card-orden {
  background: var(--text-muted);
}

.card-alias {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-card);
  line-height: 1.15;
  letter-spacing: -0.3px;
}

.card-producto {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-text);
  line-height: 1.2;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.card-direccion {
  font-size: 17px;
  color: var(--text);
  line-height: 1.3;
  margin-top: 8px;
}

.card-donde {
  font-size: 15px;
  color: var(--text-sub);
  line-height: 1.3;
  margin-top: 4px;
}

.card-loc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.card-dias {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 1px;
  margin-top: 4px;
}

.card-loc-sep {
  margin: 0 4px;
  opacity: 0.6;
}

/* Hora de completado (estado "hecha") */
.card-done-time {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

.card-done-time::before {
  content: "";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  color: var(--bg-card);
  content: "✓";
  font-size: 11px;
  font-weight: 700;
  flex: 0 0 auto;
}

.card-actions {
  position: absolute;
  right: 8px;
  top: 8px;
  display: flex;
  gap: 4px;
}

.card-action-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-pill);
  color: var(--text-sub);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.card-action-btn svg {
  display: block;
  width: 20px;
  height: 20px;
}

.card-action-btn:active {
  background: var(--border);
}

.card-action-btn.undo {
  background: var(--text-muted);
  color: var(--bg-card);
}

/* Swipe overlay */
.card-swipe-bg {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding-left: 70px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-on-accent);
  background: var(--swipe-ok);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: -1;
}

.card.swiping-right .card-swipe-bg {
  opacity: 1;
}

/* --- Lista vacía --- */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-sub);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon svg,
.icon-lg {
  width: 48px;
  height: 48px;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.empty-msg {
  font-size: 14px;
  line-height: 1.4;
}

/* --- Barra inferior --- */
.bottom-bar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-bottom);
  border-top: 1px solid var(--border);
  padding: 8px 4px calc(var(--safe-bottom) + 8px);
  z-index: 10;
}

.bottom-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 8px;
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 600;
  transition: color 0.15s, background 0.15s;
  min-height: 56px;
}

.bottom-btn:active { background: var(--bg-pill); }

.bottom-btn.active {
  color: var(--accent);
}

.bottom-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.bottom-icon svg {
  width: 22px;
  height: 22px;
}

.bottom-label {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 12px;
}

.badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--border);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.bottom-btn.active .badge {
  background: var(--accent);
  color: var(--text-on-accent);
}

/* --- Modales --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: var(--bg-modal);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-modal);
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin: 0 0 8px;
  font-size: 20px;
  color: var(--text);
}

.modal-subtitle {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text-sub);
}

#note-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  resize: none;
  margin-bottom: 16px;
}

#note-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Input de km (odómetro) */
.km-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  transition: border-color 0.15s;
}

.km-input-wrap:focus-within {
  border-color: var(--accent);
}

#km-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 0;
  font-family: inherit;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  width: 100%;
  min-width: 0;
  /* Quitar spinners del input number en algunos navegadores */
  -moz-appearance: textfield;
}

#km-input::-webkit-outer-spin-button,
#km-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#km-input:focus {
  outline: none;
}

#km-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.km-suffix {
  margin-left: 10px;
  font-size: 16px;
  color: var(--text-sub);
  font-weight: 500;
  flex: 0 0 auto;
}

.km-hint {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Campo de consumo (l/100km) — solo visible en finalizar ruta */
.consumo-row {
  margin: 16px 0 0;
}
.consumo-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  margin: 0 0 8px;
  text-align: left;
}
#consumo-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 0;
  font-family: inherit;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
  width: 100%;
  min-width: 0;
  -moz-appearance: textfield;
}
#consumo-input::-webkit-outer-spin-button,
#consumo-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#consumo-input:focus {
  outline: none;
}
#consumo-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-primary, .btn-secondary {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  min-width: 100px;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
}

.btn-secondary {
  background: var(--bg-pill);
  color: var(--text);
}

.btn-primary:active, .btn-secondary:active {
  opacity: 0.85;
}

/* Summary content */
#summary-content {
  margin: 16px 0;
  font-size: 15px;
  color: var(--text);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.summary-row:last-child { border-bottom: none; }

.summary-label { color: var(--text-sub); }
.summary-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.summary-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 80px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-toast);
  color: var(--text-toast);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 80vw;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 4px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.toast-action {
  background: transparent;
  border: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  margin-left: 10px;
  padding: 0 4px;
  cursor: pointer;
  font-family: inherit;
  pointer-events: auto;
}

/* --- Animaciones --- */
@keyframes slideOutRight {
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

.card.slide-out {
  animation: slideOutRight 0.3s ease-out forwards;
  pointer-events: none;
}

@keyframes slideInTop {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.card.new {
  animation: slideInTop 0.3s ease-out;
}

/* --- Ajustes iOS safe areas y standalone --- */
@supports (padding: max(0px)) {
  .app-header {
    padding-top: max(var(--safe-top), 8px);
  }
  .bottom-bar {
    padding-bottom: max(var(--safe-bottom), 6px);
  }
}

/* --- Small screens (iPhone SE etc.) --- */
@media (max-height: 600px) {
  .header-title h1 { font-size: 19px; }
  .header-title .subtitle { font-size: 12px; }
  .day-pill { min-width: 34px; height: 34px; font-size: 13px; }
  .card { min-height: 100px; padding: 12px 12px 12px 58px; }
  .card-orden { width: 36px; height: 36px; font-size: 13px; }
  .card-alias { font-size: 20px; }
  .card-producto { font-size: 19px; }
  .card-direccion { font-size: 15px; margin-top: 5px; }
  .card-donde { font-size: 14px; }
  .card-dias { font-size: 12px; }
  .card-loc { font-size: 12px; }
  .card-done-time { font-size: 13px; }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Vista Hechas
   ============================================ */

#view-done {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.done-header {
  padding: 16px 16px 8px;
  position: sticky;
  top: 0;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.done-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.done-header .subtitle {
  font-size: 13px;
  color: var(--text-sub);
  margin: 2px 0 0;
}

/* ============================================
   Vista Histórico
   ============================================ */

.history-view {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

.history-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 4px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.history-tab {
  flex: 1;
  padding: 10px 8px;
  background: var(--bg-pill);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-pill);
  transition: background 0.15s, color 0.15s;
}

.history-tab.active {
  background: var(--accent);
  color: var(--text-on-accent);
}

.history-section {
  padding: 8px 12px 12px;
}

#history-sub-search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 10px;
}

#history-sub-search:focus {
  outline: none;
  border-color: var(--accent);
}

/* Lista de días */
.history-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 0.1s;
}

.history-day:active {
  transform: scale(0.98);
  background: var(--bg-pill);
}

.history-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.history-day-date {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.history-day-fest {
  font-size: 11px;
  color: var(--accent);
  background: var(--bg-pill);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
  text-transform: uppercase;
}

.history-day-dow {
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 500;
}

.history-day-metrics {
  display: flex;
  gap: 8px 14px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-sub);
  align-items: center;
}

.history-day-metrics .metric {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.history-day-metrics .metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.history-day-metrics .metric-icon svg {
  width: 14px;
  height: 14px;
}

.history-day-metrics strong {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.history-day-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 20px;
  font-size: 14px;
}

/* Lista de suscriptores */
.history-sub {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: transform 0.1s;
}

.history-sub:active {
  transform: scale(0.98);
}

.history-sub-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.history-sub-num {
  font-size: 12px;
  font-weight: 700;
  color: white;
  background: var(--accent);
  padding: 2px 7px;
  border-radius: 50%;
  min-width: 26px;
  text-align: center;
}

.history-sub-alias {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.history-sub-meta {
  font-size: 12px;
  color: var(--text-sub);
  display: flex;
  gap: 6px 12px;
  flex-wrap: wrap;
  align-items: center;
}

.history-sub-meta .metric {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.history-sub-meta .metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.history-sub-meta .metric-icon svg {
  width: 12px;
  height: 12px;
}

.history-sub-meta strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Vista resumen */
.range-presets {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.range-preset {
  padding: 8px 12px;
  background: var(--bg-pill);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-pill);
}

.range-preset.active {
  background: var(--accent);
  color: var(--text-on-accent);
}

.summary-totals {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.summary-tot {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}

.summary-tot-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.summary-tot-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.summary-tot-sub {
  font-size: 10px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

.summary-chart {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px 8px;
  margin-bottom: 10px;
}

.summary-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
  padding-top: 6px;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.bar {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.3s;
}

.bar-label {
  font-size: 10px;
  color: var(--text-sub);
  font-weight: 600;
  text-align: center;
}

.line-chart {
  width: 100%;
  height: 100px;
}

.line-chart .axis {
  stroke: var(--border);
  stroke-width: 1;
}

.line-chart .line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
}

.line-chart .dot {
  fill: var(--accent);
}

.line-chart .lbl {
  font-size: 9px;
  fill: var(--text-muted);
}

/* ============================================
   Vista Ajustes
   ============================================ */

.settings-view {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
}

.settings-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 16px;
}

.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

.settings-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 8px;
}

.settings-help {
  font-size: 13px;
  color: var(--text-sub);
  margin: 0 0 12px;
  line-height: 1.45;
}

.settings-help code {
  font-size: 12px;
  background: var(--bg-pill);
  padding: 1px 5px;
  border-radius: 3px;
}

.settings-row {
  margin: 8px 0 12px;
}

.settings-row strong {
  font-size: 13px;
  color: var(--text);
  display: block;
}

.settings-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin: 2px 0 0;
}

.settings-warn {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.warn-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.warn-icon svg {
  width: 16px;
  height: 16px;
}

.full {
  width: 100%;
  margin-top: 4px;
}

/* ============================================
   Modales: export, view-filter, day-detail, etc.
   ============================================ */

.export-options,
.view-filter-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.export-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: left;
  transition: background 0.1s, transform 0.1s;
}

.export-option:active {
  transform: scale(0.98);
  background: var(--bg-pill);
}

.exp-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--accent);
}

.exp-icon svg {
  width: 22px;
  height: 22px;
}

.exp-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.exp-text strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.exp-text small {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.3;
}

.view-filter-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  transition: background 0.1s, transform 0.1s;
}

.view-filter-btn:active {
  transform: scale(0.98);
  background: var(--bg-pill);
}

.vfo-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.vfo-icon svg {
  width: 20px;
  height: 20px;
}

.vfo-label {
  flex: 1;
}

.vfo-count {
  background: var(--bg-pill);
  color: var(--text);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.import-stats {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.import-stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.day-detail-stats {
  display: flex;
  gap: 8px 14px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-sub);
  align-items: center;
}

.day-detail-stats .metric {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.day-detail-stats .metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.day-detail-stats .metric-icon svg {
  width: 14px;
  height: 14px;
}

.day-detail-stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.day-detail-list,
.sub-detail-list {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row-time {
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 46px;
}

.detail-row-text {
  flex: 1;
  color: var(--text);
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-row-dow {
  font-size: 11px;
  color: var(--text-muted);
}

/* --- Progress / day-filter: ocultos en Hechas, Histórico y Ajustes --- */
body.tab-done #day-filter-wrap,
body.tab-done #progress-row,
body.tab-done #session-bar,
body.tab-history #day-filter-wrap,
body.tab-history #progress-row,
body.tab-history #session-bar,
body.tab-settings #day-filter-wrap,
body.tab-settings #progress-row,
body.tab-settings #session-bar {
  display: none;
}

body.tab-done .app-header,
body.tab-history .app-header,
body.tab-settings .app-header {
  /* En Hechas/Histórico/Ajustes, la cabecera solo muestra el título y el tema */
  padding-bottom: 8px;
}

body.tab-done .app-header .header-top,
body.tab-history .app-header .header-top,
body.tab-settings .app-header .header-top {
  margin-bottom: 0;
}
