:root {
    --bg-dark: #0f1115;
    --panel-bg: rgba(255, 255, 255, 0.04);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #f0f0f5;
    --text-muted: #9aa0a6;
    --accent-gold: #d4af37;
    --accent-gold-hover: #f2c94c;
    --accent-rose: #d49c9c;
    --radius-lg: 16px;
    --radius-md: 8px;
    --transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 1200px;
    min-height: 100vh;
    position: relative;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Background atmospheric glow */
body::before {
    content: '';
    position: fixed;
    top: -20%;
    left: -10%;
    width: 60vw;
    height: 60vh;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.08) 0%, rgba(15, 17, 21, 0) 70%);
    z-index: -1;
}

/* Screens */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
    width: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: translateY(0);
}

/* Glass Panels */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Typography elements */
h1 {
    font-size: 3.5rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 2rem;
    font-weight: 400;
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text-main);
}

p {
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 1.1rem;
}

.accent {
    color: var(--accent-gold);
    font-weight: 500;
}

.text-center { text-align: center; }
.mt-4 { margin-top: 1.5rem; }
.text-small { font-size: 0.9rem; margin-bottom: 1.5rem; }

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-gold), #b8962e);
    color: #000;
    padding: 1rem 2.5rem;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 2rem;
    box-shadow: 0 10px 20px rgba(212, 175, 55, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px rgba(212, 175, 55, 0.3);
    background: linear-gradient(135deg, var(--accent-gold-hover), var(--accent-gold));
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 0.8rem 2rem;
    border-radius: 30px;
    font-size: 1rem;
    border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
}
.btn-text:hover { color: var(--text-main); }

a.btn-download {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-main);
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--panel-border);
    transition: var(--transition);
    font-weight: 500;
}
a.btn-download:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
}
a.btn-download.primary {
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.3);
    color: var(--accent-gold);
}
a.btn-download.primary:hover {
    background: rgba(212, 175, 55, 0.2);
}

/* Utilities */
.hidden { display: none !important; }
.mb-4 { margin-bottom: 1.5rem; }

/* Dashboard layout */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.summary-section {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem 2.5rem;
}

.summary-text {
    flex: 1;
}

.summary-chart {
    width: 300px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
    height: calc(100vh - 350px);
    min-height: 500px;
}

.image-viewer {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 0;
}

.image-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.4s ease;
}

.filter-label {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0,0,0,0.6);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--panel-border);
}

/* Controls */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.filters-section {
    flex-grow: 1;
    overflow-y: auto;
}

.filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.filter-item {
    display: flex;
    flex-direction: column;
}

.filter-btn {
    width: 100%;
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    padding: 0.8rem;
    border-radius: var(--radius-md);
    text-align: left;
    font-size: 0.9rem;
}
.filter-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
}
.filter-btn.active {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.05);
}

.filter-mobile-content {
    display: none; /* hidden on desktop entirely */
}

.filter-description-box {
    padding: 1.2rem;
    background: rgba(0,0,0,0.2);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-gold);
}
.filter-description-box p {
    font-size: 0.95rem;
    color: var(--text-main);
}
.filter-description-box h4 {
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    font-weight: 500;
}

/* Score Section in Filter Descriptions */
.filter-score-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--panel-border);
}
.filter-score-section h4 {
    font-size: 1.05rem;
    margin-bottom: 0.8rem;
    color: var(--text-main);
}
.score-value {
    font-weight: 600;
}
.score-high { color: #4ade80; }
.score-mid { color: #facc15; }
.score-low { color: #f87171; }

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.score-details {
    display: flex;
    gap: 1rem;
}
.metric {
    flex: 1;
    background: rgba(255,255,255,0.03);
    padding: 1rem;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid var(--panel-border);
}
.metric .val {
    display: block;
    font-size: 1.5rem;
    color: var(--accent-gold);
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.metric .lbl {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Scanning Animation */
.flex-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.scan-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 2rem auto;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--panel-border);
}

.scan-container img {
    width: 100%;
    display: block;
    filter: brightness(0.7) contrast(1.2);
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--accent-gold);
    box-shadow: 0 0 20px var(--accent-gold), 0 0 40px var(--accent-gold);
    animation: scan 2s linear infinite;
    z-index: 10;
}

@keyframes scan {
    0% { top: 0%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

/* Camera Placeholder */
.camera-container {
    width: 100%;
    max-width: 500px;
    height: 400px;
    margin: 0 auto 2rem;
    background: rgba(0,0,0,0.2);
    border: 2px dashed var(--panel-border);
    border-radius: var(--radius-lg);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

.camera-container video, .camera-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    opacity: 0.5;
}

.actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Mobile responsive */
@media (max-width: 900px) {
    body, #app {
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
        padding-left: 1rem;
        padding-right: 1rem;
        box-sizing: border-box;
    }
    #app {
        padding: 1rem 0.5rem;
    }
    * {
        max-width: 100%;
        box-sizing: border-box;
    }
    h1 {
        font-size: 2rem;
    }
    h2 {
        font-size: 1.4rem;
    }
    .glass-panel {
        padding: 1rem;
        width: 100%;
        box-sizing: border-box;
    }
    .dashboard-header {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        text-align: center;
    }
    .summary-section {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
        text-align: center;
    }
    .summary-chart {
        width: 100%;
        max-width: 300px;
    }
    .dashboard-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    /* ACCORDION PATTERN for Mobile */
    .image-viewer, .filter-description-box {
        display: none !important;
    }
    .filter-grid {
        grid-template-columns: 1fr; 
        gap: 0.4rem;
    }
    .filter-item.active .filter-mobile-content {
        display: flex;
        flex-direction: column;
        padding: 1rem 0;
        animation: fadeIn 0.3s ease;
    }
    .filter-mobile-content img {
        width: 100%;
        border-radius: var(--radius-md);
        margin-bottom: 0.8rem;
    }
    .filter-mobile-content .mobile-desc h4 {
        color: var(--accent-gold);
        margin-bottom: 0.3rem;
        font-size: 1rem;
    }
    .filter-mobile-content .mobile-desc p {
        font-size: 0.9rem;
        color: var(--text-main);
    }
    
    .camera-container {
        height: min(60vh, 350px);
    }
    .actions {
        flex-direction: column;
        width: 100%;
    }
    .btn-secondary, .btn-primary {
        width: 100%;
        margin-top: 0.5rem;
        text-align: center;
    }
}

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

/* Screen Torch Fallback (Ekran jako lampa) */
body.screen-torch {
    background-color: #ffffff !important;
    background-image: none !important;
}
body.screen-torch::before {
    display: none !important;
}
body.screen-torch .glass-panel {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    box-shadow: 0 0 80px rgba(255,255,255,1);
}
body.screen-torch h1, body.screen-torch h2, body.screen-torch h3, body.screen-torch p, body.screen-torch label {
    color: #000 !important;
}
body.screen-torch .accent {
    color: #b8962e !important;
}
body.screen-torch .btn-secondary, body.screen-torch .btn-primary {
    background: #f0f0f5;
    color: #000 !important;
    border-color: #ccc;
}
body.screen-torch #darkness-warning {
    color: #000 !important;
}
