* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-hover: #222;
    --border: #2a2a2a;
    --text: #e5e5e5;
    --text-secondary: #888;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #60a5fa;
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

#app {
    max-width: 900px;
    margin: 0 auto;
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top, 0);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 24px;
}
.logo-icon-img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.logo h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.update-time {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.loading svg { animation: spin 1s linear infinite; }

.btn-secondary {
    background: #333;
    color: var(--text-secondary);
}

.btn-secondary:hover { background: #444; color: var(--text); }

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

/* Tabs */
.tabs {
    display: flex;
    padding: 0 8px;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 12px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }

.badge {
    background: var(--primary);
    color: white;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* Controls */
.controls {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--border);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

.search-box input::placeholder { color: var(--text-secondary); }

.filter-row {
    display: flex;
    gap: 8px;
}

.filter-row select {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.filter-row select:focus { border-color: var(--primary); }

/* Radius control */
.radius-control {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.radius-control label { white-space: nowrap; }

.radius-control input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.radius-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg);
}

.radius-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--bg);
}

#radius-label {
    font-weight: 600;
    color: var(--primary-light);
    min-width: 80px;
    text-align: right;
}

/* Tank control */
.tank-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.tank-control label { white-space: nowrap; }

.tank-input {
    width: 70px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}

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

.tank-input:focus { border-color: var(--primary); }

.tank-unit { color: var(--text-secondary); font-size: 13px; }

/* Savings tip */
.savings-tip {
    font-size: 12px;
    color: var(--green);
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 6px;
    padding: 6px 10px;
    text-align: center;
}

/* Install banner */
.install-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(59,130,246,0.05));
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    gap: 8px;
}

.install-banner .btn-sm { padding: 5px 10px; font-size: 12px; }

/* Quick actions */
.quick-actions {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.quick-actions::-webkit-scrollbar { display: none; }

.quick-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: transform 0.15s;
}

.quick-btn:active { transform: scale(0.95); }

/* Station card actions */
.station-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.card-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.card-action-btn:hover { color: var(--primary-light); border-color: var(--primary); }

/* Trend indicators */
.trend-up { color: var(--red); font-size: 10px; font-weight: 700; }
.trend-down { color: var(--green); font-size: 10px; font-weight: 700; }
.trend-up-badge { color: var(--red); font-weight: 600; font-size: 11px; }
.trend-down-badge { color: var(--green); font-weight: 600; font-size: 11px; }
.trend-summary { margin-left: 4px; }

/* Map popup nav button */
.popup-actions { display: flex; gap: 6px; margin-top: 8px; }

.popup-nav-btn {
    flex: 1;
    padding: 6px;
    background: var(--green);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.popup-nav-btn:hover { opacity: 0.9; }
.popup-fav-btn { flex: 1; }

/* Tools panel */
.tools-panel { padding: 12px; }

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

.tool-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.tool-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }

.tool-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.tool-row label { white-space: nowrap; min-width: 65px; }

.trip-result {
    font-size: 13px;
    color: var(--text);
    padding: 8px 0 0;
    line-height: 1.5;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Load more */
.load-more-btn {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 12px;
}

/* Cost info */
.cost-info {
    display: flex;
    gap: 16px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.cost-info span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cost-info svg { opacity: 0.6; }

/* Region filters */
.region-filters {
    display: flex;
    gap: 8px;
}

.ccaa-select {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    min-width: 0;
}

#province-filter {
    flex: 1;
    min-width: 0;
}

.province-select {
    width: 100%;
    font-size: 14px;
    font-weight: 500;
}

/* Discounts */
.discount-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

.discount-input:focus { border-color: var(--primary); }
.discount-input::placeholder { color: var(--text-secondary); }

.discount-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.discount-item:last-child { border-bottom: none; }

.discount-brand-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
}

.discount-amount-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--green);
    background: rgba(34, 197, 94, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.discount-remove {
    background: none;
    border: none;
    color: var(--red);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.discount-badge {
    font-size: 10px;
    font-weight: 600;
    color: var(--green);
    background: rgba(34, 197, 94, 0.15);
    padding: 1px 5px;
    border-radius: 4px;
}

.original-price {
    text-decoration: line-through;
    opacity: 0.5;
    font-size: 10px;
    margin-right: 2px;
}

[data-theme="light"] .discount-input { background: #f8f8f8; }

/* User / Auth */
#user-area { position: relative; }

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--primary);
    object-fit: cover;
}

.user-profile { display: inline-block; }

#user-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
}
.user-menu {
    position: fixed;
    top: 50px;
    right: 12px;
    background: #1e1e1e;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    min-width: 260px;
    max-width: calc(100vw - 24px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.7);
    z-index: 10000;
    backdrop-filter: none;
}
[data-theme="light"] .user-menu {
    background: #ffffff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
[data-theme="light"] #user-menu-overlay {
    background: rgba(0,0,0,0.2);
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.menu-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.menu-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.menu-email {
    font-size: 11px;
    color: var(--text-secondary);
}

.user-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    padding: 8px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.menu-action-btn:hover { background: var(--bg); }
.menu-action-danger { color: var(--red); }
.menu-action-danger:hover { background: rgba(239, 68, 68, 0.1); }

.sync-status {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: center;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.sync-status:empty { display: none; padding: 0; border: none; margin: 0; }

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}

.loading.hidden { display: none; }

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Station list */
.station-list { padding: 8px; }

.station-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1);
}

.station-card:hover {
    border-color: #3a3a3a;
    background: var(--bg-hover);
}

.station-card:active {
    transform: scale(0.99);
}

.station-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 8px;
}

.station-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.station-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    min-width: 28px;
    height: 20px;
    padding: 0 5px;
    border-radius: 4px;
    flex-shrink: 0;
    cursor: help;
    line-height: 1;
}

.station-distance {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-light);
    background: rgba(59, 130, 246, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
}

.station-fav {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.station-fav:hover { transform: scale(1.2); }
.station-fav svg { width: 20px; height: 20px; }

.station-address {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.station-locality {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.station-schedule {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.station-prices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.price-tag {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #111;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
}

.price-tag .fuel-name { color: var(--text-secondary); }
.price-tag .fuel-price { font-weight: 600; color: var(--text); }
.price-tag.highlight { border-color: var(--primary); background: rgba(59, 130, 246, 0.1); }
.price-tag.highlight .fuel-price { color: var(--primary-light); }
.price-cheap .fuel-price { color: var(--green) !important; }
.price-mid .fuel-price { color: var(--yellow) !important; }
.price-expensive .fuel-price { color: var(--red) !important; }

/* Map */
#map {
    height: calc(100vh - 220px);
    min-height: 400px;
}

#map-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 8px 12px;
    gap: 8px;
    background: var(--bg);
}

.map-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--primary-light);
    cursor: pointer;
    transition: all 0.2s;
}

.map-btn:hover { background: var(--bg-hover); border-color: var(--primary); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 12px;
    text-align: center;
}

.empty-state p { font-size: 16px; font-weight: 500; color: var(--text-secondary); }
.empty-state span { font-size: 13px; color: #666; }

/* Leaflet popup */
.leaflet-popup-content-wrapper {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.leaflet-popup-tip { background: var(--bg-card); }

.leaflet-popup-content {
    margin: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    line-height: 1.5;
}

.popup-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.popup-address { color: var(--text-secondary); margin-bottom: 8px; }
.popup-prices { display: flex; flex-direction: column; gap: 3px; }
.popup-price-row { display: flex; justify-content: space-between; gap: 12px; }
.popup-fuel { color: var(--text-secondary); }
.popup-value { font-weight: 600; color: var(--primary-light); }

.popup-fav-btn {
    margin-top: 8px;
    width: 100%;
    padding: 6px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.popup-fav-btn:hover { background: var(--primary-hover); }
.popup-fav-btn.is-fav { background: #333; color: var(--yellow); }

/* Stats bar */
.stats-bar {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 4px;
}

.stats-bar .stat-highlight { color: var(--green); font-weight: 600; }

/* No results */
.no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

/* Alerts panel */
.alerts-panel {
    padding: 20px 16px;
}

.alerts-panel h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.alerts-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

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

.alert-form label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.alert-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.alert-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
    outline: none;
}

.alert-input:focus { border-color: var(--primary); }

.alert-currency {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.alert-actions {
    display: flex;
    gap: 8px;
}

.alert-info {
    font-size: 12px;
    color: #555;
    line-height: 1.6;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s;
    white-space: nowrap;
    max-width: 90vw;
}

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

/* Responsive */
@media (max-width: 600px) {
    .header-content {
        flex-wrap: wrap;
        gap: 8px;
    }

    .logo h1 { font-size: 16px; }

    .filter-row { flex-direction: column; }

    .station-prices { gap: 4px; }
    .price-tag { font-size: 11px; padding: 3px 6px; }

    .stats-bar { font-size: 11px; justify-content: center; }

    #map { height: calc(100vh - 240px); }

    .radius-control { flex-wrap: wrap; }
}

@media (max-width: 380px) {
    .tabs { gap: 0; }
    .tab { padding: 10px 8px; font-size: 12px; }
    .tab svg { display: none; }
}

/* Theme toggle button */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

/* Light theme */
[data-theme="light"] {
    --bg: #f5f5f5;
    --bg-card: #ffffff;
    --bg-hover: #f0f0f0;
    --border: #e0e0e0;
    --text: #1a1a1a;
    --text-secondary: #666;
}

[data-theme="light"] .price-tag {
    background: #f8f8f8;
    border-color: #ddd;
}

[data-theme="light"] .price-tag.highlight {
    background: rgba(59, 130, 246, 0.08);
    border-color: var(--primary);
}

[data-theme="light"] .search-box input::placeholder { color: #999; }
[data-theme="light"] .filter-row select {
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

[data-theme="light"] .alert-input { background: #f8f8f8; }

[data-theme="light"] .leaflet-popup-content-wrapper {
    background: #fff;
    color: #1a1a1a;
    border-color: #e0e0e0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

[data-theme="light"] .leaflet-popup-tip { background: #fff; }
[data-theme="light"] .popup-address { color: #666; }
[data-theme="light"] .popup-fuel { color: #666; }

[data-theme="light"] .toast {
    background: #fff;
    border-color: #e0e0e0;
    color: #1a1a1a;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

[data-theme="light"] .radius-control input[type="range"] { background: #ddd; }
[data-theme="light"] .radius-control input[type="range"]::-webkit-slider-thumb { border-color: #fff; }

[data-theme="light"] .savings-tip {
    background: rgba(34, 197, 94, 0.06);
    border-color: rgba(34, 197, 94, 0.15);
}

/* Price History Modal */
.ph-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.ph-modal-content {
    background: var(--card-bg, #1a1a1a);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border, #333);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.ph-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, #333);
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card-bg, #1a1a1a);
}
.ph-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text, #fff);
}
.ph-close {
    background: none;
    border: none;
    color: var(--text-secondary, #888);
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.ph-close:hover { color: var(--text, #fff); }

.ph-period-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border, #333);
}
.ph-tab {
    flex: 1;
    padding: 8px 4px;
    border: 1px solid var(--border, #333);
    background: transparent;
    color: var(--text-secondary, #888);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.ph-tab:hover { border-color: var(--primary, #3b82f6); color: var(--text, #fff); }
.ph-tab.active {
    background: var(--primary, #3b82f6);
    border-color: var(--primary, #3b82f6);
    color: #fff;
}

.ph-chart-container {
    padding: 16px;
    flex: 1;
    min-height: 280px;
    position: relative;
}

.ph-loading, .ph-no-data {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary, #888);
}
.ph-no-data p { margin: 4px 0; }
.ph-no-data-sub { font-size: 13px; color: var(--text-secondary, #666); }

/* History button in station card */
.btn-history {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border, #333);
    background: transparent;
    color: var(--primary-light, #60a5fa);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-history:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--primary, #3b82f6);
}

[data-theme="light"] .ph-modal-content {
    background: #fff;
    border-color: #e0e0e0;
}
[data-theme="light"] .ph-modal-header { border-color: #eee; background: #fff; }
[data-theme="light"] .ph-period-tabs { border-color: #eee; }
[data-theme="light"] .ph-tab { border-color: #ddd; color: #666; }
[data-theme="light"] .ph-tab:hover { color: #333; }

/* ═══════════════════════════════════════════════════════════
   MI GARAJE
   ═══════════════════════════════════════════════════════════ */

.garage-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
}
.garage-tab {
    flex: 1;
    padding: 10px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.garage-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.garage-tab:hover { color: var(--text); }

.garage-section { display: none; }
.garage-section.active { display: block; }

.garage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.garage-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.garage-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* Car cards */
.cars-list { display: flex; flex-direction: column; gap: 10px; }
.car-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.car-card.car-default { border-color: var(--primary); }
.car-card-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 200px; }
.car-icon { font-size: 28px; }
.car-info { flex: 1; }
.car-title { font-size: 15px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.car-badge-default {
    font-size: 10px;
    background: rgba(59,130,246,0.15);
    color: var(--primary);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}
.car-details { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.car-meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; opacity: 0.8; }
.car-actions { display: flex; gap: 6px; align-items: center; }

.btn-icon-sm {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon-sm:hover { background: rgba(255,255,255,0.12); color: var(--text); }
.btn-danger-sm:hover { background: rgba(239,68,68,0.15); color: #ef4444; border-color: #ef4444; }

/* Fillups */
.fillups-list { display: flex; flex-direction: column; gap: 8px; }
.fillup-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.fillup-left { flex: 1; min-width: 0; }
.fillup-date { font-size: 11px; color: var(--primary-light); font-weight: 600; margin-bottom: 2px; }
.fillup-station { font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.fillup-meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.fillup-notes { font-size: 11px; color: var(--text-secondary); font-style: italic; margin-top: 2px; }
.fillup-right { text-align: right; flex-shrink: 0; }
.fillup-total { font-size: 16px; font-weight: 700; color: var(--text); }
.fillup-detail { font-size: 11px; color: var(--text-secondary); }
.fillup-full {
    font-size: 9px;
    background: rgba(34,197,94,0.15);
    color: #22c55e;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 600;
    display: inline-block;
    margin-top: 2px;
}
.fillup-actions { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.fillup-filter-select {
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-size: 12px;
}

/* Stats */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}
.stat-value { font-size: 20px; font-weight: 700; color: var(--primary-light); }
.stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

.stats-chart-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
}
.stats-chart-container h4 { margin: 0 0 12px; font-size: 14px; color: var(--text); }

.top-station {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text);
}
.top-station:last-child { border-bottom: none; }
.top-station-count { margin-left: auto; color: var(--text-secondary); font-size: 12px; }

#stats-top-stations h4 { font-size: 14px; color: var(--text); margin: 16px 0 8px; }

/* Forms */
.garage-form { padding: 16px 0 0; }
.ph-modal .garage-form { padding: 16px 20px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}
.form-group input:focus, .form-group select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.form-check label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); cursor: pointer; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }

.btn-full { width: 100%; padding: 12px; font-size: 15px; }

/* Fillup button in station card */
.btn-fillup {
    background: rgba(34,197,94,0.1) !important;
    border-color: rgba(34,197,94,0.3) !important;
    color: #22c55e !important;
}
.btn-fillup:hover {
    background: rgba(34,197,94,0.2) !important;
}

/* Light theme overrides for garage */
[data-theme="light"] .car-card { background: #fff; border-color: #eee; }
[data-theme="light"] .car-card.car-default { border-color: var(--primary); }
[data-theme="light"] .fillup-card { background: #fff; border-color: #eee; }
[data-theme="light"] .stat-card { background: #fff; border-color: #eee; }
[data-theme="light"] .stats-chart-container { background: #fff; border-color: #eee; }
[data-theme="light"] .btn-icon-sm { background: #f5f5f5; border-color: #ddd; }
[data-theme="light"] .btn-icon-sm:hover { background: #eee; }
[data-theme="light"] .form-group input, [data-theme="light"] .form-group select { background: #fff; border-color: #ddd; }
[data-theme="light"] .fillup-filter-select { background: #fff; border-color: #ddd; }
[data-theme="light"] .garage-tabs { border-color: #eee; }
[data-theme="light"] .top-station { border-color: #eee; }

/* Search clear button */
.search-clear {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
}
.search-clear:hover { opacity: 1; color: var(--text); }

/* Nav app picker */
.nav-picker-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.6); display: flex;
    align-items: flex-end; justify-content: center;
    animation: fadeIn 0.15s;
}
.nav-picker-box {
    background: var(--bg-card); border-radius: 16px 16px 0 0;
    padding: 20px; width: 100%; max-width: 400px;
    display: flex; flex-direction: column; gap: 8px;
}
.nav-picker-box h4 { text-align: center; margin: 0 0 8px; color: var(--text); font-size: 16px; }
.nav-picker-box button {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border: 1px solid var(--border);
    border-radius: 10px; background: var(--bg); color: var(--text);
    font-size: 15px; cursor: pointer; transition: background 0.15s;
}
.nav-picker-box button:hover { background: var(--border); }
.nav-icon {
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.nav-remember {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--text-secondary); padding: 4px 0;
    cursor: pointer;
}
.nav-picker-cancel {
    border: none !important; color: var(--text-secondary) !important;
    justify-content: center !important; font-size: 14px !important;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Fillup form improvements */
.fillup-station-info { margin-top: 4px; }
.fillup-station-info small { color: var(--text-secondary); font-size: 12px; }
.fillup-calc-section { margin: 4px 0; }
.fillup-calc-hint { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.fillup-calc-or {
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: var(--text-secondary); font-weight: 600;
    padding-top: 20px;
}
.fillup-km-row { display: flex; align-items: center; gap: 8px; }
.fillup-km-row input { flex: 1; }
.fillup-km-hint { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.fillup-summary {
    background: rgba(59, 130, 246, 0.08); border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px; padding: 10px; margin-bottom: 12px; text-align: center;
}
.fillup-summary:empty { display: none; }
.fillup-summary-row { font-size: 13px; color: var(--text-secondary); }
.fillup-summary-row strong { color: var(--text); font-size: 15px; }

/* Skeleton loading */
.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 8px;
}
.skeleton-line {
    height: 14px;
    background: linear-gradient(90deg, var(--border) 25%, transparent 50%, var(--border) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-line.w30 { width: 30%; height: 10px; }
@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Achievements ─── */
.achievements-summary {
    margin-bottom: 16px;
}
.ach-progress-ring { text-align: center; margin-bottom: 12px; }
.ach-progress-circle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 80px; height: 80px; border-radius: 50%;
    background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--border) 0%);
    position: relative;
}
.ach-progress-circle::before {
    content: ''; position: absolute;
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--bg-card);
}
.ach-progress-num {
    position: relative; z-index: 1;
    font-weight: 700; font-size: 16px; color: var(--text);
}
.ach-stats-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    margin-bottom: 12px;
}
.ach-stat {
    text-align: center; padding: 8px 4px;
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
}
.ach-stat-val { display: block; font-weight: 700; font-size: 15px; color: var(--text); }
.ach-stat-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.ach-best {
    text-align: center; padding: 8px; font-size: 13px;
    color: var(--text-secondary); background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px;
}
.ach-best strong { color: #22c55e; }

.achievements-list { display: flex; flex-direction: column; gap: 8px; }
.ach-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: 10px;
    transition: all 0.2s;
}
.ach-unlocked { border-color: rgba(59, 130, 246, 0.3); }
.ach-unlocked .ach-icon { filter: none; }
.ach-locked { opacity: 0.5; }
.ach-locked .ach-icon { filter: grayscale(1); }
.ach-icon { font-size: 28px; flex-shrink: 0; width: 40px; text-align: center; }
.ach-info { flex: 1; min-width: 0; }
.ach-name { font-weight: 600; font-size: 14px; color: var(--text); }
.ach-desc { font-size: 12px; color: var(--text-secondary); margin: 2px 0 6px; }
.ach-bar {
    height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.ach-bar-fill {
    height: 100%; background: var(--primary); border-radius: 3px;
    transition: width 0.5s ease;
}
.ach-bar-label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.ach-check {
    color: #22c55e; font-size: 18px; font-weight: 700; flex-shrink: 0;
}

/* Quick Filters - Chips */
.quick-filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}
.filter-chips-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}
.brand-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.chip:hover {
    border-color: var(--primary);
    color: var(--text);
}
.chip.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--primary);
    color: var(--primary-light);
    font-weight: 600;
}
.chip-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-secondary);
    transition: background 0.15s;
}
.chip.active .chip-dot {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

/* Status badge en station card */
.station-status {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}
.station-status.open {
    color: var(--green);
    background: rgba(34, 197, 94, 0.12);
}
.station-status.closed {
    color: var(--red);
    background: rgba(239, 68, 68, 0.12);
}
.station-status.h24 {
    color: var(--primary-light);
    background: rgba(59, 130, 246, 0.12);
}

/* ─── MarkerCluster custom ─── */
.cluster-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.cluster-small {
    background: radial-gradient(circle, #22c55e 60%, #16a34a);
    width: 30px; height: 30px;
}
.cluster-medium {
    background: radial-gradient(circle, #eab308 60%, #ca8a04);
    width: 36px; height: 36px;
    font-size: 13px;
}
.cluster-large {
    background: radial-gradient(circle, #ef4444 60%, #dc2626);
    width: 44px; height: 44px;
    font-size: 14px;
}
.leaflet-cluster-anim .leaflet-marker-icon, .leaflet-cluster-anim .leaflet-marker-shadow {
    transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}
.map-price-marker {
    padding: 2px 6px;
    border-radius: 10px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
    line-height: 16px;
}
.btn-compare {
    color: var(--primary-light) !important;
    border-color: var(--primary) !important;
}

/* ─── Predicción de precios ─── */
.prediction-box {
    padding: 12px 0;
}
.prediction-trend {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}
.prediction-rec {
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 8px;
    padding: 10px;
    background: var(--bg-hover);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}
.prediction-best {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 10px;
}
.prediction-dow-title {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.dow-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 90px;
    padding: 4px 0;
}
.dow-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.dow-bar {
    width: 100%;
    min-height: 20px;
    background: var(--primary);
    border-radius: 4px 4px 0 0;
    opacity: 0.6;
    position: relative;
    transition: opacity 0.2s;
}
.dow-bar:hover { opacity: 1; }
.dow-bar-best {
    background: var(--green);
    opacity: 1;
}
.dow-bar-worst {
    background: var(--red);
    opacity: 0.8;
}
.dow-price {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: var(--text-secondary);
    white-space: nowrap;
    display: none;
}
.dow-bar:hover .dow-price { display: block; }
.dow-label {
    font-size: 10px;
    color: var(--text-secondary);
}

/* ─── Estimación nivel de depósito ─── */
.tank-gauge {
    margin: 10px 0;
}
.tank-gauge-bg {
    height: 24px;
    background: var(--bg-hover);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.tank-gauge-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.4s ease;
    min-width: 2px;
}
.tank-gauge-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.tank-estimate {
    display: flex;
    gap: 6px;
    font-size: 13px;
    color: var(--text);
    margin-top: 6px;
}
.tank-warning {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.12);
    color: var(--red);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

/* ─── Optimizador de ruta ─── */
.route-summary {
    padding: 10px 0;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}
.route-summary strong { color: var(--text); }
.route-stations { display: flex; flex-direction: column; gap: 6px; }
.route-station-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-hover);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.route-station-card:hover { background: var(--border); }
.route-station-rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}
.route-station-info { flex: 1; min-width: 0; }
.route-station-info > div:first-child { font-size: 13px; }
.route-station-meta { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.route-station-price { text-align: right; flex-shrink: 0; }
.route-price-val { font-size: 15px; font-weight: 600; color: var(--green); }
.route-price-total { font-size: 11px; color: var(--text-secondary); }

/* ─── Pestaña Análisis ─── */
.analysis-panel { padding: 12px; display: flex; flex-direction: column; gap: 12px; }

/* Brand ranking */
.brand-rank-sort {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 8px 0;
    font-size: 12px;
    color: var(--text-secondary);
}
.brand-sort-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 11px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.brand-sort-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.brand-ranking-list { display: flex; flex-direction: column; gap: 2px; }
.brand-rank-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.brand-rank-row:hover { background: var(--bg-hover); transform: translateX(2px); }
.brand-rank-row:active { transform: scale(0.98); }
.brand-rank-pos {
    width: 22px;
    text-align: center;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 13px;
    flex-shrink: 0;
}
.brand-rank-row:nth-child(1) .brand-rank-pos { color: #eab308; }
.brand-rank-row:nth-child(2) .brand-rank-pos { color: #a0a0a0; }
.brand-rank-row:nth-child(3) .brand-rank-pos { color: #cd7f32; }
.brand-rank-info { flex: 1; min-width: 0; }
.brand-rank-name { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; margin-bottom: 3px; }
.brand-rank-bar-bg { height: 6px; background: var(--bg-hover); border-radius: 3px; overflow: hidden; }
.brand-rank-bar { height: 100%; border-radius: 3px; min-width: 4px; }
@keyframes barGrow { from { width: 0; } }
.brand-rank-bar-anim { animation: barGrow 0.6s ease-out forwards; width: var(--bar-width); }
.brand-rank-prices { text-align: right; flex-shrink: 0; }
.brand-rank-price { font-weight: 600; font-size: 14px; display: block; }
.brand-rank-min { font-size: 10px; color: var(--green); display: block; }
.brand-rank-diff { font-size: 11px; color: var(--red); flex-shrink: 0; width: 55px; text-align: center; }
.brand-rank-best { font-size: 10px; color: var(--green); font-weight: 600; flex-shrink: 0; width: 55px; text-align: center; }
.brand-rank-count {
    font-size: 11px;
    color: var(--text-secondary);
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-hover);
    border-radius: 50%;
}

/* CCAA ranking */
.ccaa-ranking-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.ccaa-rank-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.ccaa-rank-row:hover { background: var(--bg-hover); }
.ccaa-rank-current { background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.3); }
.ccaa-rank-name { width: 120px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Comparador */
.compare-search { position: relative; margin-bottom: 10px; }
.compare-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
}
.compare-sug {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.1s;
}
.compare-sug:hover { background: var(--bg-hover); }
.compare-cards { margin-top: 8px; }
.compare-grid { display: grid; gap: 10px; }
.compare-card {
    background: var(--bg-hover);
    border-radius: 10px;
    padding: 12px;
    position: relative;
}
.compare-remove {
    position: absolute;
    top: 6px;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}
.compare-remove:hover { color: var(--red); }
.compare-header { display: flex; align-items: center; gap: 6px; font-size: 14px; margin-bottom: 4px; }
.compare-loc { font-size: 12px; color: var(--text-secondary); }
.compare-dist { font-size: 11px; color: var(--primary-light); margin-top: 2px; }
.compare-prices { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.compare-fuel-label { font-size: 11px; color: var(--text-secondary); padding: 2px 0; }
.compare-price { font-size: 13px; padding: 2px 0; }
.compare-best { color: var(--green); font-weight: 600; }

/* ─── Top cards dashboard ─── */
.top-cards {
    display: flex;
    gap: 6px;
    padding: 6px 12px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: center;
}
.top-cards::-webkit-scrollbar { display: none; }
.top-cards:empty { display: none; }
.top-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
    max-width: 320px;
}
.top-card:hover { background: var(--bg-hover); }
.top-card-icon {
    font-size: 16px;
    flex-shrink: 0;
}
.top-card-body {
    flex: 1;
    min-width: 0;
}
.top-card-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
    font-weight: 600;
}
.top-card-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-card-meta {
    font-size: 11px;
    color: var(--text-secondary);
}
.top-card-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--green);
    flex-shrink: 0;
}
@media (max-width: 600px) {
    .top-cards {
        flex-direction: column;
        align-items: center;
    }
    .top-card {
        width: 100%;
        max-width: none;
    }
}

/* ─── Vista toggle ─── */
.view-toggle {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    justify-content: flex-end;
}
.view-btn {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.view-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ─── Vista compacta ─── */
.compact-view .station-card {
    padding: 8px 12px;
}
.compact-view .station-header {
    gap: 6px;
}
.compact-view .station-address,
.compact-view .station-locality,
.compact-view .station-schedule,
.compact-view .cost-info,
.compact-view .station-card > div:last-child {
    display: none;
}
.compact-view .station-prices {
    margin-top: 4px;
}
.compact-view .price-tag {
    padding: 2px 6px;
    font-size: 11px;
}

/* ─── Histograma de precios ─── */
.histogram {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 120px;
    margin-top: 10px;
    padding: 0 4px;
}
.histo-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}
.histo-bar {
    width: 100%;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
    opacity: 0.7;
    position: relative;
    min-height: 2px;
    transition: opacity 0.15s;
}
.histo-bar:hover { opacity: 1; }
.histo-avg { background: var(--yellow); opacity: 1; }
.histo-fav { border: 2px solid #eab308; }
.histo-count {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: var(--text-secondary);
    display: none;
}
.histo-col:hover .histo-count { display: block; }
.histo-label {
    font-size: 8px;
    color: var(--text-secondary);
    margin-top: 3px;
    transform: rotate(-45deg);
    white-space: nowrap;
}
.histo-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ─── Animaciones y transiciones ─── */
.station-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.station-card:active {
    transform: scale(0.98);
}
@media (hover: hover) {
    .station-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    }
}
.tab {
    transition: color 0.2s, border-color 0.2s;
}
.tool-card {
    transition: transform 0.15s;
}
@media (hover: hover) {
    .tool-card:hover {
        transform: translateY(-1px);
    }
}
.btn {
    transition: background 0.15s, transform 0.1s;
}
.btn:active {
    transform: scale(0.96);
}
.toast {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* ─── Stats bar animation ─── */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.stats-bar {
    animation: slideIn 0.3s ease;
}

/* ─── Tarjeta de ahorro ─── */
.savings-card {
    margin-top: 16px;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
}
.savings-positive {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.savings-negative {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.savings-card h4 { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.savings-amount {
    font-size: 28px;
    font-weight: 700;
}
.savings-positive .savings-amount { color: var(--green); }
.savings-negative .savings-amount { color: var(--red); }
.savings-detail {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.6;
}

/* ─── Popup invitación registro ─── */
.signup-invite {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: signup-fade 0.25s ease-out;
}
.signup-invite-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.signup-invite-card {
    position: relative;
    max-width: 420px;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px 24px 22px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: signup-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: calc(100vh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0) - 32px);
    overflow-y: auto;
}
.signup-invite-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.15s;
}
.signup-invite-close:hover { background: var(--bg-hover); color: var(--text); }
.signup-invite-icon {
    font-size: 40px;
    text-align: center;
    margin-bottom: 6px;
}
.signup-invite-card h2 {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
    color: var(--text);
}
.signup-invite-sub {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 18px;
}
.signup-invite-list {
    list-style: none;
    padding: 0;
    margin: 0 0 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.signup-invite-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
}
.signup-invite-list li span {
    flex: 0 0 22px;
    font-size: 18px;
    line-height: 1.3;
}
.signup-invite-list li b { color: var(--primary-light); font-weight: 600; }
.signup-invite-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}
.signup-invite-actions .btn-primary {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
}
.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: color 0.15s;
}
.btn-ghost:hover { color: var(--text); }
.signup-invite-legal {
    text-align: center;
    color: var(--text-secondary);
    font-size: 11px;
    opacity: 0.7;
}
@keyframes signup-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes signup-pop {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
