/* =========================================================
   PRIMA PALIWA – MAIN.CSS
   Light Modern Theme, Mobile-First
   ========================================================= */

/* --- CSS VARIABLES --- */
:root {
    --primary: #e63012;
    /* Orlen red accent */
    --primary-light: #ff6b4a;
    --primary-dark: #c0290f;
    --accent: #f59e0b;
    /* Amber for discounts */
    --accent-light: #fde68a;
    --success: #10b981;
    /* Green for best deal */
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;

    /* Light palette */
    --bg-base: #f5f6fa;
    --bg-card: #ffffff;
    --bg-card-hover: #fafbff;
    --bg-subtle: #f0f1f6;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-on-primary: #ffffff;

    /* Borders */
    --border: #e8eaf0;
    --border-subtle: #f0f1f6;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10), 0 4px 8px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.07);

    /* Layout */
    --header-height: 140px;
    --bottom-nav-height: 68px;
    --transition: 0.2s ease;
}

/* --- RESET & BASE --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100%;
}

body {
    background: var(--bg-base);
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* =========================================================
   HEADER
   ========================================================= */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    z-index: 100;
    flex-shrink: 0;
}

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

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

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(230, 48, 18, 0.3);
}

.brand-text h1 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.brand-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

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

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    transition: all var(--transition);
}

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

.icon-btn.spinning i {
    animation: spin 1s linear infinite;
}

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

.trend-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.trend-badge.up {
    background: var(--danger-light);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.trend-badge.hidden {
    display: none;
}

.header-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 8px;
    gap: 8px;
}

.status-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.orlen-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #fff1f0, #fff);
    border: 1px solid rgba(230, 48, 18, 0.15);
    border-radius: var(--radius-full);
    padding: 3px 10px 3px 6px;
}

.badge-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

.badge-price-group {
    display: flex;
    flex-direction: column;
    text-align: right;
    line-height: 1.15;
}

.badge-price-main {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.badge-price-sub {
    font-size: 0.58rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Price Mode Toggle Bar */
.price-mode-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-base);
    gap: 8px;
}

.price-mode-left {
    display: flex;
    gap: 4px;
    background: var(--bg-subtle);
    border-radius: var(--radius-full);
    padding: 3px;
    border: 1px solid var(--border);
}

.price-mode-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    border: none;
    background: transparent;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.price-mode-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.price-mode-btn.active[data-mode="regional"] {
    color: #0284c7;
}

.price-mode-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.price-mode-source {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    text-align: right;
    max-width: 140px;
    line-height: 1.3;
}

.regional-loading {
    display: inline-flex;
    animation: spin 1s linear infinite;
    font-size: 0.75rem;
}

.regional-loading.hidden {
    display: none;
}

/* Fuel Filter Chips */
.fuel-filter-bar {

    border-top: 1px solid var(--border-subtle);
    padding: 6px 0;
    overflow: hidden;
}

.fuel-filter-scroll {
    display: flex;
    gap: 6px;
    padding: 0 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.fuel-filter-scroll::-webkit-scrollbar {
    display: none;
}

.fuel-chip {
    flex-shrink: 0;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.fuel-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.fuel-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 6px rgba(230, 48, 18, 0.3);
}

/* =========================================================
   MAIN VIEWS
   ========================================================= */
.view-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.view {
    position: absolute;
    inset: 0;
    bottom: var(--bottom-nav-height);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.view.active {
    opacity: 1;
    pointer-events: auto;
}

.view.hidden {
    display: none;
}

/* =========================================================
   MAP VIEW
   ========================================================= */
#view-map {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.map-filter-chips {
    display: flex;
    gap: 6px;
    padding: 10px 12px 8px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    -webkit-overflow-scrolling: touch;
}

.map-filter-chips::-webkit-scrollbar { display: none; }

.map-chip {
    flex-shrink: 0;
    padding: 5px 13px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--border);
    background: var(--surface);
    font-size: 0.78rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.map-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.map-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

#map {
    flex: 1;
    min-height: 0;
}

.map-legend {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
    z-index: 500;
    box-shadow: var(--shadow-sm);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 6px;
}

.legend-dot.all {
    background: #6b7280;
}

.legend-dot.cheap {
    background: #10b981;
}

.legend-dot.moderate {
    background: #f59e0b;
}

.legend-dot.expensive {
    background: #ef4444;
}

/* Clickable legend buttons */
.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1.5px solid transparent;
    border-radius: var(--radius-full);
    padding: 3px 8px 3px 4px;
    font-size: 0.7rem;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.legend-item:hover {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.legend-item.active {
    background: var(--bg-card);
    border-color: var(--border);
    color: var(--text-primary);
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

/* Info modal */
.info-modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 80px 12px 12px;
    backdrop-filter: blur(3px);
}

.info-modal.hidden {
    display: none;
}

.info-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.info-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-primary);
    gap: 8px;
}

.info-close-btn {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0 2px;
    transition: color 0.15s;
}

.info-close-btn:hover {
    color: var(--text-primary);
}

.info-modal-body {
    padding: 16px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.55;
    max-height: 70vh;
    overflow-y: auto;
}

.info-modal-body p {
    margin-bottom: 10px;
}

.info-section-title {
    font-weight: 700;
    color: var(--text-primary) !important;
    font-size: 0.84rem !important;
    margin-top: 14px !important;
    margin-bottom: 4px !important;
}

.info-section-title:first-child {
    margin-top: 0 !important;
}

.info-modal-body code {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--primary);
}

.info-table {
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0 10px;
    font-size: 0.79rem;
}

.info-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.info-table td:first-child {
    color: var(--text-muted);
}

.info-table td:last-child {
    text-align: right;
}

.info-note {
    background: #fffbeb;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-size: 0.76rem;
    color: #92400e;
    display: flex;
    gap: 6px;
    align-items: flex-start;
    margin-top: 12px !important;
    margin-bottom: 0 !important;
}


/* Custom Map Markers */
.station-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.marker-logo-wrap {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-logo-wrap img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.marker-price {
    background: white;
    border: 2px solid #ddd;
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    font-size: 0.68rem;
    font-weight: 800;
    margin-top: 2px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.marker-price.cheap {
    border-color: #10b981;
    color: #059669;
    background: #ecfdf5;
}

.marker-price.moderate {
    border-color: #f59e0b;
    color: #d97706;
    background: #fffbeb;
}

.marker-price.expensive {
    border-color: #ef4444;
    color: #dc2626;
    background: #fef2f2;
}

/* Map Popup */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    border: none !important;
    padding: 0 !important;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0 !important;
    width: auto !important;
    min-width: 240px;
}

.leaflet-popup-tip-container {
    display: none;
}

.map-popup {
    padding: 16px;
    background: white;
}

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

.popup-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 3px;
    background: white;
}

.popup-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.popup-addr {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.popup-price-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.popup-price-item {
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    padding: 8px;
}

.popup-price-item.highlight {
    background: linear-gradient(135deg, var(--success-light), #f0fdf4);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.popup-price-item.highlight.moya {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.popup-price-label {
    font-size: 0.64rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.popup-price-val {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 2px;
}

.popup-price-item.highlight .popup-price-val {
    color: var(--success);
}

.popup-price-item.highlight.moya .popup-price-val {
    color: #d97706;
}

.popup-discount-row {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    margin-bottom: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #92400e;
}

.popup-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition);
    font-family: inherit;
}

.popup-nav-btn:hover {
    background: var(--primary-dark);
}

/* =========================================================
   LIST VIEW
   ========================================================= */
#view-list {
    padding: 0 0 16px;
}

.section-header {
    padding: 20px 16px 12px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.section-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 400;
}

/* Best Deal Banner */
.best-deal-card {
    margin: 12px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    color: white;
    box-shadow: 0 4px 16px rgba(230, 48, 18, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.best-deal-card.hidden {
    display: none;
}

.best-deal-label {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
}

.best-deal-name {
    font-size: 1rem;
    font-weight: 700;
}

.best-deal-price {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1;
}

.best-deal-price span {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.85;
}

/* Price Reference Row */
.price-reference-row {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    gap: 0;
}

.ref-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.ref-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ref-val {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 2px;
}

.ref-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
    margin: 0 8px;
}

/* Station Cards */
.station-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.station-card {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    padding: 14px 16px;
    transition: background var(--transition);
    position: relative;
    overflow: hidden;
}

.station-card:first-child {
    border-top: none;
}

.station-card:hover {
    background: var(--bg-card-hover);
}

.station-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--border);
}

.station-card.top-deal::before {
    background: var(--success);
}

.station-card.good-deal::before {
    background: var(--accent);
}

.station-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.station-logo-wrap {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.station-logo-wrap img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.station-meta {
    flex: 1;
    min-width: 0;
}

.station-num {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.station-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.station-city {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 1px;
}

.station-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 700;
    margin-top: 4px;
}

.station-badge.best {
    background: var(--success-light);
    color: #059669;
}

.station-badge.discount {
    background: var(--accent-light);
    color: #92400e;
}

/* Price Breakdown Table in Station Card */
.price-breakdown {
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}

.price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

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

.price-row-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.price-row-val {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
}

.price-row.discount-row {
    background: #fffbf0;
}

.price-row.discount-row .price-row-label {
    color: #b45309;
}

.price-row.discount-row .price-row-val {
    color: #d97706;
}

.price-row.final-row {
    background: var(--success-light);
}

.price-row.final-row .price-row-label {
    color: #065f46;
    font-weight: 700;
}

.price-row.final-row .price-row-val {
    font-size: 1.05rem;
    font-weight: 900;
    color: var(--success);
}

/* =========================================================
   ARCHIVE VIEW
   ========================================================= */
#view-archive {
    padding: 0 0 16px;
}

.archive-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.archive-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.archive-select {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-card);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 32px;
    transition: border-color var(--transition);
}

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

.primary-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition);
    font-family: inherit;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(230, 48, 18, 0.25);
}

.primary-btn:hover {
    background: var(--primary-dark);
}

.chart-controls {
    padding: 0 16px 12px;
    background: var(--bg-card);
}

.range-slider-group {
    background: var(--bg-subtle);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.range-slider-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.range-slider-group label span {
    color: var(--primary);
    font-weight: 800;
}

.range-slider {
    width: 100%;
    height: 6px;
    appearance: none;
    background: var(--border);
    border-radius: var(--radius-full);
    outline: none;
}

.range-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.chart-wrapper {
    margin: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 16px;
    height: 220px;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.archive-table-wrap {
    margin: 0 16px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.archive-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.archive-table thead {
    background: var(--bg-subtle);
}

.archive-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}

.archive-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-weight: 500;
}

.archive-table tr:last-child td {
    border-bottom: none;
}

.archive-table tbody tr:hover {
    background: var(--bg-subtle);
}

.archive-table .latest-row td {
    font-weight: 800;
}

.archive-table .latest-row td:first-child::after {
    content: ' (dziś)';
    font-size: 0.65rem;
    color: var(--primary);
    font-weight: 700;
}

.change-up {
    color: var(--danger);
    font-weight: 700;
}

.change-down {
    color: var(--success);
    font-weight: 700;
}

.change-none {
    color: var(--text-muted);
}

.table-loading {
    text-align: center;
    padding: 24px !important;
    color: var(--text-muted);
}

/* =========================================================
   CALCULATOR VIEW
   ========================================================= */
#view-calc {
    padding: 0 16px 24px;
}

#view-calc .section-header {
    margin: 0 -16px 0;
    padding: 20px 16px 12px;
}

.calc-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-card);
}

.calc-input-group {
    margin-bottom: 16px;
}

.calc-input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.number-input-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.num-btn {
    width: 44px;
    height: 44px;
    background: var(--bg-subtle);
    border: none;
    font-size: 1.3rem;
    font-weight: 300;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: inherit;
}

.num-btn:hover {
    background: var(--border);
}

.calc-input {
    flex: 1;
    border: none;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    padding: 8px;
    min-width: 0;
    background: white;
}

.calc-select {
    width: 100%;
    padding: 12px 40px 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-primary);
    background-color: var(--bg-card);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    transition: border-color var(--transition);
}

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

.calc-results {
    margin-top: 16px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.calc-result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.calc-result-row:last-of-type {
    border-bottom: none;
}

.calc-result-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.calc-result-val {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
}

.calc-result-row.discount {
    background: #fffbf0;
}

.calc-result-row.discount .calc-result-label {
    color: #b45309;
}

.calc-result-row.discount .calc-result-val {
    color: #d97706;
}

.calc-result-row.after-disc {
    background: var(--success-light);
}

.calc-result-row.after-disc .calc-result-label {
    color: #065f46;
    font-weight: 700;
}

.calc-result-row.after-disc .calc-result-val {
    color: var(--success);
    font-size: 1rem;
}

.calc-savings-box {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 18px;
    text-align: center;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.savings-label {
    font-size: 0.78rem;
    font-weight: 600;
    opacity: 0.85;
    margin-bottom: 6px;
}

.savings-amount {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1;
}

.savings-info {
    font-size: 0.72rem;
    opacity: 0.75;
    margin-top: 6px;
}

/* Stats Card */
.stats-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 16px;
    box-shadow: var(--shadow-card);
}

.stats-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-item {
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    display: block;
    margin-bottom: 4px;
}

.stat-val {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-primary);
    display: block;
}

/* =========================================================
   BOTTOM NAVIGATION
   ========================================================= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 200;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition);
    padding: 6px 0;
    position: relative;
}

.nav-item i {
    font-size: 22px;
    transition: all var(--transition);
}

.nav-item:hover {
    color: var(--primary);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 25%;
    right: 25%;
    height: 2px;
    background: var(--primary);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* =========================================================
   LOADING OVERLAY
   ========================================================= */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spinner-ring {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.loading-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 700;
}

.loading-brand i {
    color: var(--primary);
    font-size: 24px;
}

/* =========================================================
   RESPONSIVE (DESKTOP)
   ========================================================= */
@media (min-width: 640px) {
    .station-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0;
    }

    .archive-controls {
        flex-wrap: nowrap;
    }

    .view-container .view {
        padding-left: 0;
        padding-right: 0;
    }
}

@media (min-width: 1024px) {
    .station-list {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    #view-list,
    #view-archive,
    #view-calc {
        max-width: 900px;
        margin: 0 auto;
        width: 100%;
    }
}

/* =========================================================
   ALERTS VIEW
   ========================================================= */

.alerts-header {
    padding: 16px 16px 4px;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.section-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}

.alert-settings-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin: 10px 16px 12px;
    box-shadow: var(--shadow-sm);
}

.alert-setting {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.alert-setting label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-group input[type="number"] {
    width: 60px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 4px;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-base);
    outline: none;
}

.input-group input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(230, 48, 18, 0.1);
}

/* hide number spinners */
.input-group input[type="number"]::-webkit-inner-spin-button,
.input-group input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-group input[type="number"] {
    -moz-appearance: textfield;
}

.btn-sm {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-base);
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-sm:hover {
    background: var(--border);
    color: var(--text-primary);
}

.toggle-group {
    display: flex;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 2px;
    gap: 2px;
}

.toggle-btn {
    padding: 5px 12px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.toggle-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* Alert Tiles */
#alert-tiles {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 16px 100px;
}

.alert-tile {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s ease;
}

.alert-tile-ok {
    border-left: 4px solid #22c55e;
}

.alert-tile-warn {
    border-left: 4px solid #f59e0b;
}

.alert-tile-alarm {
    border-left: 4px solid #ef4444;
}

.alert-tile-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.alert-tile-header i {
    font-size: 20px;
    color: var(--primary);
}

.alert-tile-price {
    margin-left: auto;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.alert-section {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.alert-section:last-child {
    border-bottom: none;
}

.alert-section-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.alert-badge {
    padding: 2px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 800;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.alert-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.alert-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    background: var(--bg-base);
    border-radius: var(--radius-sm);
}

.alert-metric-wide {
    grid-column: span 3;
}

.alert-metric-label {
    font-size: 0.64rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.alert-metric-value {
    font-size: 0.88rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.alert-risk-cost {
    font-size: 1.05rem;
}

.alert-banner {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
}

.alert-collecting {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
}

.alert-collecting i {
    font-size: 20px;
    animation: spin 2s linear infinite;
}

#view-alerts {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* =========================================================
   UTILITIES
   =========================================================*/
.hidden {
    display: none !important;
}

::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}