:root {
    --primary: #1E463A;
    --secondary: #C0A062;
    --bg-body: #eeeeee;
    --bg-surface: #ffffff;
    --text-main: #000000;
    --text-muted: #555555;
    --border: #cccccc;
    --nav-height: 60px;
    --sidebar-width: 250px;
}

* {
    box-sizing: border-box;
    border-radius: 0 !important; /* The Flat Mandate */
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    padding-bottom: var(--nav-height); /* Space for bottom nav */
}

/* UTILS */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
    margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* LAYOUT */
.app-layout { display: flex; min-height: 100vh; }

/* SIDEBAR (Desktop) */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: white;
    display: none; /* Hidden on mobile */
    flex-direction: column;
    position: fixed; height: 100%;
    padding: 0;
    border-right: 1px solid rgba(0,0,0,0.2);
}
.sidebar-logo {
    padding: 20px;
    background: rgba(0,0,0,0.2);
    font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    display: flex; align-items: center; gap: 10px;
    color: var(--secondary);
}
.sidebar-nav-item {
    padding: 15px 20px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s;
    display: flex; align-items: center; gap: 10px;
    font-size: 0.9rem;
}
.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}
.sidebar-nav-item.active {
    background: var(--secondary);
    color: var(--primary);
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    padding: 10px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

@media (min-width: 768px) {
    .sidebar { display: flex; }
    .main-content { margin-left: var(--sidebar-width); padding: 30px; }
    .bottom-nav { display: none !important; }
    body { padding-bottom: 0; }
}

/* HEADERS */
.header {
    margin-bottom: 15px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 4px solid var(--primary);
    background: var(--bg-surface);
    padding: 15px;
    /* Full width on mobile */
    margin-left: -10px; margin-right: -10px; margin-top: -10px;
}
@media (min-width: 768px) {
    .header { margin: 0 0 20px 0; border: none; padding: 0; background: transparent; border-bottom: 4px solid var(--primary); padding-bottom: 10px; }
}
.header h2 { margin: 0; font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 800; }

/* CARDS */
.grid-2 { display: grid; gap: 15px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 15px;
}
.card-header {
    border-bottom: 2px solid var(--primary);
    padding-bottom: 10px; margin-bottom: 20px;
    font-weight: 700; text-transform: uppercase; color: var(--primary);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.9rem;
}
.card-header h4 { margin: 0; }

/* FORMS */
.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #999;
    background: #fff;
    font-family: inherit; font-size: 1rem;
    color: var(--text-main);
    appearance: none; -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    background: #f0fdf4;
    outline: 1px solid var(--primary);
}

/* BUTTONS */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    height: 36px; /* Uniform Height */
    padding: 0 20px;
    border: none;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.2s, transform 0.1s;
    line-height: 1;
}
.btn:active { transform: translateY(1px); }

.btn-block { 
    width: 100%; 
    display: flex; 
    margin-top: 15px; 
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #16362d; }

.btn-secondary { background: var(--secondary); color: var(--primary); }
.btn-secondary:hover { background: #b09055; }

.btn-danger { background: #d32f2f; color: white; }
.btn-danger:hover { background: #b71c1c; }

.btn-outline { background: transparent; border: 1px solid #999; color: var(--text-main); }
.btn-outline:hover { background: rgba(0,0,0,0.05); }

/* Standardize Icon Buttons to match Text Buttons */
.btn-icon-sm {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 0;
}

.btn-icon-only {
    width: 36px;
    height: 36px;
    padding: 0;
}

/* List specific adjustments */
.list-actions .btn {
    margin-left: 5px;
}

/* LISTS */
.list-item {
    border: 1px solid var(--border);
    background: #fff;
    padding: 12px;
    margin-bottom: -1px; /* Collapsed borders */
    display: flex; justify-content: space-between; align-items: center;
}
.list-item:first-child { margin-top: 0; }
.list-item:hover { background: #f9f9f9; }
.list-item.active { background: #e8f5e9; border-left: 4px solid var(--primary); padding-left: 8px; }

.list-content { flex: 1; padding-right: 10px; min-width: 0; }
.list-title { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.list-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* SWITCH */
.switch-group { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #eee; }
.switch-group span { font-weight: 600; font-size: 0.9rem; }
.switch { position: relative; display: inline-block; width: 46px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .2s; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 4px; bottom: 4px; background-color: white; transition: .2s; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(22px); }

/* BOTTOM NAV */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--primary);
    display: flex;
    z-index: 1000;
    height: var(--nav-height);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}
.nav-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    border-top: 4px solid transparent;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.nav-item.active {
    color: var(--secondary);
    background: rgba(0,0,0,0.2);
    border-top-color: var(--secondary);
}
.nav-item span.material-symbols-outlined { font-size: 24px; margin-bottom: 2px; }
.nav-item span:last-child { font-size: 10px; text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px; }

/* THEME CARDS */
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.theme-preview { height: 80px; border: 1px solid #ccc; display: flex; align-items: center; justify-content: center; background: #eee; font-weight: bold; font-size: 0.8rem; color: #555; transition: all 0.2s; }
.theme-option { cursor: pointer; }
.theme-option input { position: absolute; opacity: 0; }
.theme-option input:checked + .theme-preview { border: 4px solid var(--primary); color: var(--primary); background: #fff; position: relative; }
.theme-option input:checked + .theme-preview::after { content: "✓"; position: absolute; top: 0; right: 0; background: var(--primary); color: white; padding: 2px 6px; font-size: 10px; }

/* LOGIN */
.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--primary); padding: 20px; }
.login-card { background: white; padding: 40px; width: 100%; max-width: 400px; text-align: center; border: 1px solid var(--border); box-shadow: 10px 10px 0 rgba(0,0,0,0.1); }

/* VISIBILITY */
.tab-content { display: none; }
.tab-content.active { display: block; animation: none; }

/* CUSTOM RADIO TILES */
.radio-tile-label { flex: 1; cursor: pointer; }
.radio-tile-label input { display: none; }
.radio-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 2px solid var(--border); border-radius: 8px; padding: 15px;
    color: var(--text-muted); transition: 0.2s; background: #fff;
}
.radio-tile-label input:checked + .radio-tile {
    border-color: var(--primary); background: #e8f5e9; color: var(--primary); font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.radio-tile span.material-symbols-outlined { font-size: 32px; margin-bottom: 5px; }

/* MOBILE HEADER OPTIMIZATION */
.btn-label { margin-left: 5px; }

@media (max-width: 768px) {
    /* Header adjustments */
    .header {
        flex-wrap: wrap;
        gap: 10px;
    }
    .btn-label {
        display: none;
    }
    /* Turn specific buttons into icon-only mode on mobile */
    #btn-salla-trigger, #btn-audio-modal {
        padding: 0;
        width: 36px;
        height: 36px;
        justify-content: center;
    }

    /* Sidebar logic */
    .sidebar {
        position: fixed;
        height: 100%;
        margin-left: -260px;
        z-index: 1100;
    }
    .sidebar.open { margin-left: 0; box-shadow: 5px 0 15px rgba(0,0,0,0.2); }
    .mobile-toggle { display: block; }
    .content-scroll { padding: 1rem; }
    .top-bar { padding: 0 1rem; }
}