/* --- Global Reset & Base Styles --- */
* {
    box-sizing: border-box;
    margin: 0;
}

:root {
    --bg-primary: #f5fbfb;
    --bg-secondary: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
    --header-bg: #ffffff;
    --input-bg: #ffffff;
    --shadow-color: rgba(15, 23, 42, 0.08);
}

body.dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --card-bg: #1e293b;
    --header-bg: #1e293b;
    --input-bg: #334155;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-primary);
    background-image:
        radial-gradient(900px 520px at 12% 8%, rgba(20, 184, 166, 0.18), transparent 65%),
        radial-gradient(900px 520px at 88% 12%, rgba(59, 130, 246, 0.16), transparent 65%),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 45%, var(--bg-primary) 100%);
    color: var(--text-primary);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode {
    background-image:
        radial-gradient(900px 520px at 12% 8%, rgba(20, 184, 166, 0.08), transparent 65%),
        radial-gradient(900px 520px at 88% 12%, rgba(59, 130, 246, 0.08), transparent 65%);
}

.container {
    width: 100%;
    max-width: 1100px;
    padding: 1.5rem;
    margin: 0 auto;
}

@media (max-width: 640px) {
    body.has-selection .container {
        padding: 3px 0.5rem;
        padding-bottom: 12px;
    }
    
    body.has-selection .site-header {
        margin-bottom: 3px;
        border-bottom: none;
        background: #ffffff;
    }
    
    body.has-selection {
        background: #ffffff;
        background-image: none;
    }
}

/* --- Hero Layout --- */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 40px;
    align-items: center;
    margin: 20px 0 40px;
}

.hero-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hero-badge {
    align-self: flex-start;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(20, 184, 166, 0.12);
    color: #0f766e;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

body.dark-mode .hero-badge {
    background: rgba(20, 184, 166, 0.2);
    color: #5eead4;
}

.hero-title {
    font-size: 2.6rem;
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.hero-title span {
    color: #14b8a6;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 520px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.hero-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hero-btn.primary {
    background: #14b8a6;
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(20, 184, 166, 0.28);
}

.hero-btn.primary:hover {
    transform: translateY(-1px);
}

.hero-btn.ghost {
    background: #ffffff;
    color: #0f766e;
    border: 1px solid #d2eee7;
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 4px;
}

.hero-stat {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: background 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .hero-stat {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(51, 65, 85, 0.8);
}

.hero-stat span {
    color: #14b8a6;
}

.hero-stat strong {
    display: block;
    font-size: 14px;
    color: #0f172a;
}

body.dark-mode .hero-stat strong {
    color: #f1f5f9;
}

.hero-stat p {
    font-size: 12px;
    color: #64748b;
    margin: 2px 0 0;
}

.hero-art {
    display: flex;
    justify-content: center;
}

.hero-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    position: relative;
    width: min(100%, 360px);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.hero-pill {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(20, 184, 166, 0.18), rgba(59, 130, 246, 0.18));
    top: -30px;
    right: -20px;
    z-index: 0;
}

.hero-illustration {
    width: 100%;
    height: auto;
    position: relative;
    z-index: 1;
}

.hero-main-rect {
    fill: #f8fafc;
    stroke: #cbd5e1;
    stroke-width: 1;
    transition: fill 0.3s ease, stroke 0.3s ease;
}

body.dark-mode .hero-main-rect {
    fill: #334155;
    stroke: #475569;
}

.hero-bar {
    fill: #cbd5e1;
    transition: fill 0.3s ease;
}

body.dark-mode .hero-bar {
    fill: #64748b;
}

/* --- Header Section --- */
.site-header {
    background: transparent;
    width: 100%;
    padding: 16px 0;
    margin-bottom: 32px;
    display: flex;
    justify-content: center;
}

.header-container {
    padding: 0 24px;
    width: 100%;
    max-width: 1200px;
}

.header-content {
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
    position: relative;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-content:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.logo-shell {
    display: flex;
    align-items: center;
    min-width: 0;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px 6px 6px;
    border-radius: 50px;
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.08) 0%, rgba(6, 182, 212, 0.06) 100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.logo-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.logo-wrapper:hover::before {
    left: 100%;
}

.logo-wrapper:hover {
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.12) 0%, rgba(6, 182, 212, 0.1) 100%);
    transform: scale(1.02);
}

.icon-box {
    background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(8, 145, 178, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.logo-wrapper:hover .icon-box {
    box-shadow: 0 6px 20px rgba(8, 145, 178, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: rotate(10deg);
}

.header-icon {
    font-size: 22px !important;
    font-weight: 500;
}

.text-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-right: 8px;
}

.main-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.sub-title {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    opacity: 0.7;
}

.header-nav {
    display: flex;
    gap: 4px;
    align-items: center;
}

.nav-link {
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 10px 18px;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 18px;
    right: 18px;
    height: 2px;
    background: linear-gradient(90deg, #0891b2, #06b6d4);
    border-radius: 2px;
    transform: scaleX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.nav-link:hover::after {
    transform: scaleX(1);
}

.nav-link.active {
    color: #0891b2;
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.1) 0%, rgba(6, 182, 212, 0.08) 100%);
}

.nav-link.active::after {
    transform: scaleX(1);
}

.dark-mode-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    margin-left: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.logo-shell .dark-mode-toggle {
    margin-left: 10px;
}

@media (min-width: 641px) {
    .header-nav {
        margin-right: 56px;
    }

    .logo-shell .dark-mode-toggle {
        margin-left: 0;
        position: absolute;
        top: 50%;
        right: 24px;
        transform: translateY(-50%);
    }

    .logo-shell .dark-mode-toggle:hover {
        transform: translateY(-50%) rotate(180deg) scale(1.05);
    }
}

.dark-mode-toggle:hover {
    background: linear-gradient(135deg, rgba(8, 145, 178, 0.1) 0%, rgba(6, 182, 212, 0.08) 100%);
    border-color: #0891b2;
    transform: rotate(180deg) scale(1.05);
    box-shadow: 0 4px 12px rgba(8, 145, 178, 0.2);
}

.dark-mode-toggle .material-symbols-outlined {
    font-size: 20px;
}

@media (max-width: 768px) {
    .header-container {
        padding: 0 16px;
    }
    
    .header-content {
        padding: 12px 20px;
        gap: 24px;
    }
    
    .logo-wrapper {
        gap: 10px;
        padding: 5px 10px 5px 5px;
    }
    
    .icon-box {
        width: 36px;
        height: 36px;
    }
    
    .main-title {
        font-size: 16px;
    }
    
    .sub-title {
        font-size: 10px;
    }
    
    .nav-link {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .dark-mode-toggle {
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 640px) {
    .site-header {
        padding: 12px 0;
        margin-bottom: 24px;
    }
    
    .header-content {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }

    .logo-shell {
        width: 100%;
        position: relative;
        display: block;
    }
    
    .logo-wrapper {
        width: 100%;
        justify-content: center;
        padding-right: 54px;
    }
    
    .header-nav {
        gap: 6px;
        width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .nav-link {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .nav-link::after {
        bottom: 6px;
        left: 12px;
        right: 12px;
    }
    
    .logo-shell .dark-mode-toggle {
        margin-left: 0;
        position: absolute;
        top: 50%;
        right: 8px;
        transform: translateY(-50%);
        width: 36px;
        height: 36px;
    }

    .logo-shell .dark-mode-toggle:hover {
        transform: translateY(-50%) rotate(180deg) scale(1.05);
    }
}

/* --- Search & Filter Controls --- */
.search-section {
    position: relative;
    width: 100%;
    margin-bottom: 0;
}

.search-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
    max-width: 100%;
}

.input-group {
    position: relative;
    flex-grow: 1;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 14px 30px var(--shadow-color);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: #94a3b8;
    font-size: 20px;
}

.clear-search-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.clear-search-btn:hover {
    color: #64748b;
    background: #f1f5f9;
}

.clear-search-btn .material-symbols-outlined {
    font-size: 20px;
}

.month-group {
    width: 180px;
    flex-shrink: 0;
}

.time-filter-group {
    margin-top: 15px;
    width: 100%;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    color: #475569;
    font-size: 0.9rem;
}

input, #month-select-main, #time-period-select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 16px;
    background: var(--bg-secondary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

#sub-input {
    border: none;
    box-shadow: none;
    padding: 14px 12px 14px 34px;
    font-size: 16px;
    background: transparent;
    color: var(--text-primary);
}

input:focus, #month-select-main:focus, #time-period-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#sub-input:focus {
    box-shadow: none;
}

.search-bar:focus-within {
    border-color: #14b8a6;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.18), 0 14px 30px rgba(15, 23, 42, 0.08);
}

.popular-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    color: #64748b;
    font-size: 0.85rem;
}

.popular-label {
    margin-right: 4px;
}

.popular-chip {
    background: #e8f6f2;
    border: 1px solid #d2eee7;
    color: #14806f;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

@media (max-width: 900px) {
    .hero {
        grid-template-columns: 1fr;
    }

    .hero-art {
        order: -1;
        display: none;
    }
}

.popular-chip:hover {
    background: #e4f4f0;
    border-color: #bfe3dc;
}

/* --- Search Bar Container --- */
.search-bar-container {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.search-bar-container .search-bar {
    flex: 1;
}

/* --- Month Picker Button --- */
.month-picker-btn {
    display: none;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.month-picker-btn:hover {
    background: var(--bg-primary);
    border-color: #cbd5e1;
}

.month-picker-btn .material-symbols-outlined {
    font-size: 24px;
    color: #0891b2;
}

/* --- Month Picker Calendar Dropdown --- */
.month-picker-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    overflow: hidden;
}

.month-picker-calendar {
    padding: 20px;
}

.month-picker-year-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.year-nav-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0;
}

.year-nav-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.year-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.year-nav-btn .material-symbols-outlined {
    font-size: 20px;
    color: #475569;
}

.month-picker-year {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.month-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.month-picker-month {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.15s;
    border: 1px solid transparent;
}

.month-picker-month:hover {
    background: var(--bg-primary);
    border-color: var(--border-color);
}

.month-picker-month.selected {
    background: #0891b2;
    color: white;
    font-weight: 600;
}

.month-picker-month.unavailable {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.month-picker-month.prelim {
    border: 1px dashed #fbbf24;
    background: #fffbeb;
    color: #92400e;
}

.month-picker-month.prelim.selected {
    background: #f59e0b;
    color: white;
    border-color: #f59e0b;
}

/* --- Dropdown Results --- */
.custom-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 10px 15px -3px var(--shadow-color);
    display: none;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.dropdown-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.3s ease;
}

.dropdown-item:hover { 
    background: var(--bg-primary); 
}

.item-line1 { 
    font-weight: 700; 
    font-size: 13px; 
    text-transform: uppercase; 
    display: block; 
    color: var(--text-primary); 
}

.item-line2 { 
    font-size: 12px; 
    color: var(--text-secondary); 
    display: block; 
    margin-top: 2px; 
}

/* --- Price Card (Hero Section) --- */
.price-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 6px -1px var(--shadow-color);
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.pv-badge-container { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.pv-title { background: #eff6ff; color: #2563eb; padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.lowest-price-badge { background: #dcfce7; color: #15803d; padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; }
.product-name { margin: 8px 0; font-size: 1.6rem; color: var(--text-primary); }
.sub-info { color: var(--text-secondary); margin: 0; font-size: 0.95rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 20px; }
.info-item { display: flex; align-items: center; gap: 12px; }
.info-item .label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; }
.info-item .value { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }

/* --- Comparison Table --- */
.reserves-container {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 20px;
    padding: 0 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    padding: 24px 20px !important; 
    box-sizing: border-box !important;
}

.reserves-header { padding: 16px 20px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; font-weight: 700; color: #334155; }
.reserves-table { width: 100%; border-collapse: collapse; }
.reserves-table th { text-align: left; padding: 12px 16px; background: #ffffff; color: #64748b; font-weight: 600; font-size: 0.75rem; text-transform: uppercase; border-bottom: 1px solid #f1f5f9; }
.reserves-table td { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; font-size: 0.9rem; }

/* Status & Row Styling */
.status-badge { padding: 4px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; }
.status-pv { background: #dcfce7; color: #166534; }
.status-r { background: #fef3c7; color: #92400e; }
.status-other { background: #f1f5f9; color: #475569; }

.pv-row { background-color: #eff6ff !important; }
.reserve-row { background-color: #fffbeb !important; }
.cheapest-row { background-color: #f0fdf4 !important; border-left: 4px solid; border-image: linear-gradient(to bottom, #10b981, #2dd4bf) 1 100%; position: relative; }

body.dark-mode .pv-row { background-color: var(--card-bg) !important; }
body.dark-mode .reserve-row { background-color: var(--card-bg) !important; }
body.dark-mode .cheapest-row { background-color: var(--card-bg) !important; }

.best-value-tag { font-size: 0.65rem; background: #10b981; color: white; padding: 2px 6px; border-radius: 4px; margin-left: 8px; vertical-align: middle; text-transform: uppercase; font-weight: 700; }

.price-wrapper { display: flex; flex-direction: column; align-items: flex-end; }
.diff-subtext { font-size: 0.75rem; font-weight: 700; }
.company-subtext { display: none; }
.col-company-desktop { display: table-cell; }

#chart-container {
    width: 100%;           /* Fills the 1100px container */
    min-height: 500px;         /* Desktop height */
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-top: 20px;
    box-shadow: 0 4px 6px -1px var(--shadow-color);
    position: relative;    /* Crucial for Chart.js responsiveness */
    transition: background 0.3s ease, border-color 0.3s ease;
}

#chart-filter-wrapper {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
}

#chart-filter-wrapper label {
    margin: 0;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}

#chart-filter-wrapper select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

#chart-filter-wrapper select:hover {
    border-color: #0891b2;
}

/* --- Förbättrad Empty State (Startbox) --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    text-align: center;
    background: #f8fafc;
    border-radius: 24px;
    border: none;
    margin-top: 20px;
    box-shadow: none;
    transition: all 0.3s ease;
}

/* Cirkeln runt pillret */
.empty-icon-circle {
    width: 80px;
    height: 80px;
    background-color: #f1f5f9; /* Ljusgrå/blå bakgrund */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.empty-icon-circle .material-symbols-outlined {
    font-size: 40px;
    color: #64748b; /* Gråblå ikonfärg */
}

.empty-state h2 {
    margin: 0 0 12px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.prelim-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    border: 1px solid #f59e0b;
    border-radius: 9999px;
    color: #f59e0b;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    position: relative;
}

.prelim-info::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #0f172a;
    color: #f8fafc;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 10;
}

@media (max-width: 640px) {
    .prelim-info::after {
        white-space: normal;
        max-width: 150px;
        left: auto;
        right: 0;
        transform: none;
    }
}

.prelim-info:hover::after,
.prelim-info:focus::after {
    opacity: 1;
}
.empty-state p {
    margin: 0;
    color: #64748b;
    font-size: 1rem;
    line-height: 1.6;
    max-width: 400px; /* Håller texten centrerad och läsbar */
}
/* --- Expansion Button --- */
.expansion-btn {
    background: none; border: none; color: #2563eb; padding: 12px 20px; cursor: pointer; font-weight: 600; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; margin: 0 auto;
}
.expansion-btn:hover { color: #1d4ed8; background-color: #eff6ff; }
#pagination-footer { text-align: center; padding: 10px; border-top: 1px solid #f1f5f9; }

/* Container for the tooltip */
.tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Hidden tooltip text */
.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #1e293b;
    color: #fff;
    text-align: left;
    border-radius: 8px;
    padding: 10px;
    position: absolute;
    z-index: 10;
    bottom: 125%; /* Position above the badge */
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.8rem;
    line-height: 1.4;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

/* Tooltip arrow */
.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #1e293b transparent transparent transparent;
}

/* Show tooltip on hover */
.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

.card-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.price-info-side {
    text-align: right;
}

.price-value {
    font-size: 32px;
    margin: 0;
    color: var(--text-primary);
    font-weight: 800;
    line-height: 1;
}

.price-trends {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.price-trends p {
    margin: 0;
    line-height: 1.4;
}


.past-price-text {
    font-size: 13px;
    color: #64748b;
}

.info-summary-card {
    transition: all 0.2s ease;
}

/* Ta bort standard-pilen från webbläsaren */
.info-accordion summary::-webkit-details-marker {
    display: none;
}
.info-accordion summary {
    outline: none;
}

/* Rotera vår egen pil när details är öppen */
.info-accordion[open] .expand-icon {
    transform: rotate(180deg);
}

/* Lite hover-effekt på rubriken */
.info-accordion summary:hover {
    background-color: #f8fafc;
}

.rec-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.rec-icon-circle {
    background: var(--bg-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.price-card-body {
    padding: 24px;
}

.price-card-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
}

.price-main-content {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.price-display-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
}

.current-price-block {
    flex: 1;
    min-width: 200px;
}

.price-large {
    font-size: 42px;
    font-weight: 800;
    color: var(--text-primary);
    display: block;
    margin-top: 4px;
}

/* --- Savings Alert --- */
.savings-alert-box {
    flex: 1.2;
    min-width: 250px;
    background: #f0fdf4;
    border: 1px solid rgba(22, 163, 74, 0.19);
    border-left: 4px solid #16a34a;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: background 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .savings-alert-box {
    background: rgba(22, 163, 74, 0.1);
    border: 1px solid rgba(22, 163, 74, 0.3);
    border-left: 4px solid #22c55e;
}

.savings-alert-box .material-symbols-outlined {
    color: #16a34a;
    font-size: 28px;
}

body.dark-mode .savings-alert-box .material-symbols-outlined {
    color: #22c55e;
}

.savings-alert-title {
    display: block;
    font-size: 16px;
    color: #134e4a;
    margin-bottom: 4px;
}

body.dark-mode .savings-alert-title {
    color: #86efac;
}

.savings-alert-text {
    margin: 0;
    font-size: 13px;
    color: #166534;
    line-height: 1.5;
}

body.dark-mode .savings-alert-text {
    color: #bbf7d0;
}

/* --- Stability Insight Box --- */
.stability-insight-box {
    border-radius: 12px;
    padding: 16px 20px;
    margin-top: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: background 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .stability-insight-box {
    background: var(--card-bg) !important;
}

.stability-insight-icon {
    font-size: 24px;
}

.stability-insight-title {
    display: block;
    font-size: 15px;
    margin-bottom: 4px;
}

body.dark-mode .stability-insight-title {
    color: var(--text-primary) !important;
}

.stability-insight-text {
    margin: 0;
    font-size: 13px;
    color: #64748b;
    line-height: 1.5;
}

body.dark-mode .stability-insight-text {
    color: var(--text-secondary);
}

/* --- Stat Blocks (Next/Prev Month) --- */
.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.stat-block {
    flex: 1;
    min-width: 140px;
}

.stat-label {
    margin: 0;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.trend-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 2px;
}

/* --- Comparison List (Table Area) --- */
.comparison-container {
    padding: 24px 0;
}

.comparison-header {
    padding: 0 1rem;
}

.comparison-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 1rem;
}

.comparison-row {
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid;
}

.row-content {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.row-details-grid {
    margin: 0 12px 12px 12px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, border-color 0.3s ease;
    border: 1px solid #f1f5f9;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.detail-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.detail-label {
    display: block;
    color: #64748b;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.detail-value {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 12px;
}

/* Table Layout & Spacing */
.comparison-container {
    padding: 24px 0;
}

.comparison-inner-padding {
    padding: 0 1rem;
}

.comparison-title {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
}

.comparison-subtitle {
    margin: 8px 0 24px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.comparison-subtitle strong {
    color: var(--text-primary);
}

/* The dynamic list of medicines */
.comparison-list-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 1rem;
}

/* TLV Info Box at the bottom */
.tlv-info-box {
    margin: 24px 1rem 0 1rem;
    background: #f0fdf4;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 12px;
    border: 1px solid #ccfbf1;
}

.tlv-info-box.hidden {
    display: none !important;
}

/* Month warning banner */
.month-warning-banner {
    display: none;
    background: #fef9c3;
    border-radius: 0;
    margin: 0;
    padding: 16px 24px;
    align-items: center;
    gap: 16px;
}

.month-banner-icon-wrapper {
    background: var(--bg-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.month-banner-icon {
    font-size: 20px;
    color: #ca8a04;
}

.month-banner-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.month-banner-label {
    margin: 0;
    font-weight: 700;
    font-size: 15px;
    color: #713f12;
}

.month-banner-action {
    margin: 0;
    font-size: 13px;
    color: #854d0e;
    line-height: 1.3;
}

.month-banner-action b {
    color: #713f12;
    cursor: pointer;
    text-decoration: none;
}

.tlv-info-icon {
    color: #14b8a6;
    font-size: 20px;
}

.tlv-info-title {
    margin: 0;
    font-weight: 700;
    color: #134e4a;
    font-size: 14px;
}

.tlv-info-text {
    margin: 4px 0 0 0;
    color: #115e59;
    font-size: 13px;
    line-height: 1.5;
}

/* Base Badge Style */
.status-badge-mini {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    margin-right: 8px;
    vertical-align: middle;
    background: var(--bg-secondary);
}

/* Modifier: Periodens Vara (Blue) */
.badge-pv {
    color: #2563eb;
    border: 1px solid #3b82f6;
}

/* Modifier: Reserve (Amber/Yellow) */
.badge-reserve {
    color: #d97706;
    border: 1px solid #f59e0b;
}

/* Om du vill att det ska se extra proffsigt ut på mobilen */
@media (max-width: 600px) {
    .info-summary-card {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
    }
    .info-icon {
        width: 32px;
        height: 32px;
    }
    .info-icon .material-symbols-outlined {
        font-size: 20px !important;
    }
}
/* Grundregler för alla kort på Desktop */
.bleed-card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px var(--shadow-color);
    margin-bottom: 20px;
    overflow: hidden; /* För att bakgrundsfärger i header inte ska gå över runda hörn */
    width: 100%;
    transition: background 0.3s ease, border-color 0.3s ease;
}
@media screen and (max-width: 768px) {
    /* Gemensam breakout-logik för alla bleed-kort */
    .bleed-card {
        width: 100vw !important;
        position: relative !important;
        left: 50% !important;
        margin-left: -50vw !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        box-shadow: none !important;
        padding: 24px 12px !important;
        box-sizing: border-box !important;
    }

    .search-controls {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    /* INFORMATION I TVÅ KOLUMNER */
    .info-grid-mobile {
        flex: 1 1 100% !important;
        max-width: 100% !important;
        margin-top: 15px !important;
    }

    .info-grid-mobile div[style*="display: flex; flex-direction: column"] {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 16px 12px !important;
    }

    .current-price-deal {
        border: 1px solid #e2e8f0 !important;
        border-radius: 10px !important;
    }

    .cheaper-exists-badge {
        margin-left: 0 !important;
    }

    /* 1. Gör den grå boxen till fullbredd under priset */
    .info-grid-mobile {
        flex: 1 1 100% !important; /* Tar upp hela bredden i priskortet */
        max-width: 100% !important;
        margin-top: 15px !important;
    }

    /* 2. Targeta containern för informationspunkterna och gör dem till två kolumner */
    .info-grid-mobile div[style*="display: flex; flex-direction: column"] {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important; /* Skapar två lika stora kolumner */
        gap: 16px 12px !important; /* Justerar avstånd mellan rader och kolumner */
    }

    /* 3. Se till att ikon och text ligger bra bredvid varandra i de nya kolumnerna */
    .info-grid-mobile div[style*="display: flex; align-items: flex-start"] {
        gap: 8px !important;
    }

    .savings-alert-box {
        flex: 1 1 100% !important;
        margin: 10px 0 !important;
        box-sizing: border-box;
    }
    
    /* Behåll två kolumner för informationspunkterna inuti boxen */
    .info-grid-mobile div[style*="display: flex; flex-direction: column"] {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 16px 12px !important;
    }
}

/* --- Price Display Container --- */
.price-display-container {
    text-align: right;
    min-width: fit-content;
}

.price-display-container .price-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
}

.price-display-container .price-diff {
    font-size: 13px;
    font-weight: 600;
    color: #94a3b8;
}

/* --- Expanded Row Details --- */
.row-details-container {
    margin: 0 12px 12px 12px;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 16px;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.row-detail-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.row-detail-item .material-symbols-outlined {
    font-size: 16px;
    color: #94a3b8;
}

.row-detail-content {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 640px) {
    .row-details-container {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.row-detail-label {
    display: block;
    color: #64748b;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
}

.row-detail-value {
    font-weight: 700;
    color: var(--text-primary);
}

/* --- Comparison Row Container --- */
.comparison-row {
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
    background: var(--card-bg);
}

.comparison-row.cheapest-row {
    background: #f0fdf4 !important;
    border: 2px solid #10b981 !important;
}

body.dark-mode .comparison-row.cheapest-row {
    background: var(--card-bg) !important;
    border: 2px solid #10b981 !important;
}

.comparison-row.pv-row {
    background: #eff6ff !important;
    border: 2px solid #3b82f6 !important;
}

body.dark-mode .comparison-row.pv-row {
    background: var(--card-bg) !important;
    border: 2px solid #3b82f6 !important;
}

.comparison-row.reserve-row {
    background: #fffbeb;
    border: 2px solid #f59e0b;
}

body.dark-mode .comparison-row.reserve-row {
    background: var(--card-bg);
    border: 2px solid #f59e0b;
}

.comparison-row.default-row {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
}

/* --- Comparison Row Header --- */
.comparison-row-header {
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.comparison-row-left {
    min-width: 0;
    flex: 1;
}

.comparison-row-product {
    display: flex;
    align-items: center;
    line-height: 1.3;
}

.comparison-row-name {
    font-size: 20px;
    color: var(--text-primary);
}

.comparison-row-info {
    margin: 2px 0 0 0;
    color: var(--text-secondary);
    font-size: 12px;
}
.alt-package-sizes-card {
    margin-top: 0;
    padding: 16px;
}
.alt-package-sizes-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.alt-package-sizes-title {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
}
.alt-view-toggle {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 10px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
}

.alt-view-toggle:hover {
    border-color: #0891b2;
    color: #0891b2;
}

.alt-view-toggle .material-symbols-outlined {
    font-size: 20px;
}
.alt-package-sizes-subtitle {
    margin: 6px 0 12px 0;
    font-size: 13px;
    color: var(--text-secondary);
}
.alt-package-sizes-list {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
}
.alt-package-size-row {
    width: 280px;
    min-width: 280px;
    flex: 0 0 auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
    cursor: pointer;
    text-align: left;
    scroll-snap-align: start;
}
.alt-package-size-row:hover {
    border-color: #0891b2;
    background: rgba(8, 145, 178, 0.08);
}

.alt-package-size-row.is-current {
    border-color: #0891b2;
    box-shadow: inset 0 0 0 1px #0891b2;
}
.alt-package-size-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.alt-package-size-topline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.alt-package-size-main span {
    font-size: 12px;
    color: var(--text-secondary);
}

.alt-current-badge {
    display: inline-flex;
    align-self: flex-start;
    font-size: 11px;
    font-weight: 700;
    color: #0f766e;
    background: rgba(20, 184, 166, 0.14);
    border: 1px solid rgba(20, 184, 166, 0.3);
    border-radius: 999px;
    padding: 2px 8px;
}
.alt-package-size-prices {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
}
.alt-price {
    font-weight: 700;
    color: var(--text-primary);
}
.alt-compare {
    font-size: 12px;
    color: var(--text-secondary);
}

.alt-compare-lowest {
    color: #15803d;
    font-weight: 700;
}

.alt-compare-highest {
    color: #dc2626;
    font-weight: 700;
}

.alt-package-sizes-table-wrap {
    overflow-x: auto;
}

.alt-package-sizes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.alt-package-sizes-table th,
.alt-package-sizes-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    text-align: left;
    vertical-align: middle;
}

.alt-package-sizes-table th {
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.alt-package-size-table-row {
    cursor: pointer;
}

.alt-package-size-table-row:hover {
    background: rgba(8, 145, 178, 0.08);
}

.alt-package-size-table-row.is-current {
    background: rgba(8, 145, 178, 0.10);
}

.alt-table-compare.alt-compare-lowest {
    color: #15803d;
    font-weight: 700;
}

.alt-table-compare.alt-compare-highest {
    color: #dc2626;
    font-weight: 700;
}

.is-hidden {
    display: none !important;
}

@media (max-width: 640px) {
    .alt-package-size-row {
        width: 240px;
        min-width: 240px;
    }

    .alt-package-sizes-heading {
        align-items: flex-start;
    }
}

/* --- Price Card Layout --- */
.price-card-header {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.price-card-icon {
    background: var(--bg-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.price-card-icon .material-symbols-outlined {
    font-size: 20px;
}

.price-card-header-text p:first-child {
    margin-bottom: 2px;
}

.price-card-header-text .subtext {
    font-weight: 400;
    opacity: 0.8;
    font-size: 13px;
}

.price-card-content {
    padding: 24px;
}

.price-card-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
}

.price-card-main {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.price-card-price-section {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
}

.price-card-current {
    flex: 1;
    min-width: 200px;
}

.price-card-current-label {
    margin: 0;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.price-card-current-value {
    font-size: 42px;
    font-weight: 800;
    color: #1e293b;
    display: block;
    margin-top: 4px;
}

.price-card-comparison {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.price-card-info-panel {
    flex: 0 0 280px;
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, border-color 0.3s ease;
}

@media (max-width: 640px) {
    .price-card-info-panel {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        margin-top: 12px;
        max-height: 175px;
    }
}

.price-card-info-title {
    margin: 0 0 16px 0;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.price-card-info-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.price-info-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.price-info-item .material-symbols-outlined {
    font-size: 20px;
    color: #94a3b8;
}

.price-info-item-content {
    font-size: 13px;
}

.price-info-item-label {
    display: block;
    color: #64748b;
    font-size: 10px;
}

.price-info-item-value {
    font-weight: 700;
    color: var(--text-primary);
}

/* --- Stat Blocks (Previous/Next) --- */
.stat-blocks-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 24px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.stat-block {
    flex: 1;
    min-width: 120px;
}

.stat-block-label {
    margin: 0;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-block-content {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.stat-block-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-block-trend {
    background: 15;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 2px;
}

.stat-block-trend span {
    font-size: 16px;
}

/* --- Price Card Header & Layout --- */
.price-card-header-bar {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-radius: 15px 15px 0 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

.price-card-icon-wrapper {
    background: var(--bg-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.price-card-icon {
    font-size: 20px;
    color: var(--text-secondary);
    display: block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    font-weight: normal;
    font-style: normal;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
}

.price-card-header-text {
    display: flex;
    flex-direction: column;
}

.price-card-header-label {
    margin: 0;
    font-weight: 700;
    font-size: 15px;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-primary);
}

.price-card-header-subtext {
    margin: 2px 0 0 0;
    opacity: 0.8;
    font-size: 13px;
    line-height: 1.3;
    color: var(--text-primary);
}

.price-card-header-bar.is-alert-red {
    background: #fef2f2;
    border-color: #fecaca;
}

.price-card-header-bar.is-alert-red .price-card-icon-wrapper {
    background: #fee2e2;
}

.price-card-header-bar.is-alert-red .price-card-icon,
.price-card-header-bar.is-alert-red .price-card-header-label,
.price-card-header-bar.is-alert-red .price-card-header-subtext {
    color: #b91c1c;
}

.price-card-header-bar.is-alert-red .price-card-icon {
    font-variation-settings: 'FILL' 1;
}

body.dark-mode .price-card-header-bar.is-alert-red {
    background: rgba(220, 38, 38, 0.14);
    border-color: rgba(248, 113, 113, 0.45);
}

body.dark-mode .price-card-header-bar.is-alert-red .price-card-icon-wrapper {
    background: rgba(185, 28, 28, 0.25);
}

body.dark-mode .price-card-header-bar.is-alert-red .price-card-icon,
body.dark-mode .price-card-header-bar.is-alert-red .price-card-header-label,
body.dark-mode .price-card-header-bar.is-alert-red .price-card-header-subtext {
    color: #fecaca;
}

body.dark-mode .price-card-header-bar.is-alert-red .price-card-icon {
    font-variation-settings: 'FILL' 1;
}

.price-card-content-wrapper {
    padding: 24px;
}

.price-card-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
}

@media (max-width: 900px) {
    .price-card-grid {
        flex-direction: column;
    }

    .price-card-left-column {
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
    }

    .price-card-info-panel {
        flex: 0 0 auto;
        width: 100%;
        min-width: 0;
        max-width: none;
        padding: 12px 14px;
        margin-top: 12px;
        max-height: 175px;
    }
}

.price-card-left-column {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.price-card-title-section {
    display: flex;
    flex-direction: column;
}

.price-card-title {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.price-card-subtitle {
    margin: 6px 0 0 0;
    color: #64748b;
    font-size: 15px;
    font-weight: 400;
}

.price-card-price-section {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
}

.price-card-current-wrapper {
    flex: 1;
    min-width: 200px;
}

.price-card-current-label {
    margin: 0;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.price-card-current-value {
    font-size: 42px;
    font-weight: 800;
    color: var(--text-primary);
    display: block;
    margin-top: 4px;
}

.price-card-info-panel {
    flex: 0 0 280px;
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.price-card-info-header {
    margin: 0 0 12px 0;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.price-card-info-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.price-card-info-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.price-card-info-icon {
    font-size: 20px;
    color: var(--text-secondary);
}

.price-card-info-content {
    font-size: 13px;
}

.price-card-info-label {
    display: block;
    color: var(--text-secondary);
    font-size: 10px;
}

.price-card-info-value {
    font-weight: 700;
    color: var(--text-primary);
}

@media (max-width: 900px) {
    .price-card-info-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 14px;
    }
}

@media (max-width: 640px) {
    .price-card-info-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 14px;
    }
}

/* --- Footer Section --- */
.site-footer {
    background: var(--header-bg);
    border-top: 1px solid var(--border-color);
    width: 100%;
    padding: 24px 0;
    margin-top: 40px;
    display: flex;
    justify-content: center;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.footer-container {
    padding: 0 20px;
    width: 100%;
    max-width: 1100px;
}

.footer-content {
    text-align: center;
    color: var(--text-secondary);
}

/* --- Mobile optimizations --- */
@media (max-width: 640px) {
    .comparison-row-header {
        gap: 8px;
    }

    .comparison-row-left {
        flex: 1;
        min-width: 0;
    }

    .comparison-row-name {
        font-size: 16px;
        word-break: break-word;
    }

    .comparison-row-info {
        font-size: 11px;
    }
}

/* --- State Management --- */
body.has-selection .hero-badge {
    display: none;
}

body.has-selection .hero-title {
    display: none;
}

body.has-selection .hero-subtitle {
    display: none;
}

body.has-selection .hero-actions {
    display: none;
}

body.has-selection .hero-stats {
    display: none;
}

body.has-selection .hero-art {
    display: none;
}

body.has-selection .popular-row {
    display: none;
}

body.has-selection .hero {
    background: transparent;
    border: none;
    padding: 8px 0;
    grid-template-columns: 1fr;
}

@media (max-width: 640px) {
    body.has-selection .hero {
        padding: 0;
        margin: 3px 0;
    }
}

/* --- Statistics Page --- */
.stats-page {
    padding-top: 24px;
}

.stats-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    gap: 24px;
    align-items: stretch;
    margin: 24px 0 32px;
}

@media (max-width: 900px) {
    .stats-hero {
        grid-template-columns: 1fr;
    }
}

.stats-hero-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stats-controls {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stats-control-label {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
}

.stats-select {
    width: 100%;
    min-width: 200px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 14px;
}

.stats-hero-note {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.2);
    font-size: 12px;
    color: var(--text-secondary);
}

.stats-hero-note .material-symbols-outlined {
    font-size: 18px;
    color: #2563eb;
}

.stats-range {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stats-summary-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    box-shadow: 0 10px 20px var(--shadow-color);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.stats-summary-icon {
    font-size: 22px;
    color: #2563eb;
    background: rgba(37, 99, 235, 0.12);
    border-radius: 10px;
    padding: 8px;
}

.stats-summary-label {
    margin: 0 0 4px;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.stats-summary-value {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.stats-summary-subtext {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-secondary);
}

.stats-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 24px;
}

.stats-grid-two {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.stats-card {
    padding: 20px;
}

.stats-card-header h3 {
    margin: 0 0 6px;
    font-size: 18px;
    color: var(--text-primary);
}

.stats-card-header p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.stats-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.stats-list-item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

body.dark-mode .stats-list-item {
    background: rgba(15, 23, 42, 0.3);
    border-color: rgba(148, 163, 184, 0.2);
}

.stats-item-title {
    font-weight: 700;
    color: var(--text-primary);
}

.stats-item-subtitle {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-secondary);
}

.stats-item-metrics {
    display: flex;
    align-items: center;
}

.stats-item-metric {
    text-align: right;
}

.stats-item-metric-value {
    display: block;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-positive {
    color: #c2410c;
}

.metric-negative {
    color: #15803d;
}

.stats-item-metric-detail {
    font-size: 12px;
    color: var(--text-secondary);
}

.stats-empty,
.stats-loading {
    padding: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stats-average-wrapper {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 16px;
}

.stats-sparkline {
    color: #2563eb;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 12px;
    padding: 12px;
}

body.dark-mode .stats-sparkline {
    background: rgba(37, 99, 235, 0.15);
}

.stats-average-info {
    min-width: 220px;
}

.stats-average-title {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 700;
}

.stats-average-subtext {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stats-average-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.stats-average-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}