:root {
    /* --- Clean & Crisp Palette --- */
    /* Primary Color: Noir (Black) */
    --primary: #000000;
    /* Black */
    --primary-dark: #111111;
    /* Rich Black */
    --primary-light: #e2e8f0;
    /* Slate 200 (Backgrounds) */

    /* Functional Colors */
    --success: #10b981;
    /* Emerald 500 */
    --warning: #f59e0b;
    /* Amber 500 */
    --danger: #ef4444;
    /* Red 500 */
    --info: #3b82f6;
    /* Blue 500 */

    /* Neutral Colors (Light Mode Default) */
    --bg-main: #f8fafc;
    /* Slate 50 - Ana Arkaplan */
    --bg-panel: #ffffff;
    /* White - Kart/Panel Arkaplanı */
    --bg-secondary: #f1f5f9;
    /* Slate 100 - İkincil Alanlar */

    --border: #e2e8f0;
    /* Slate 200 - İnce Çizgiler */
    --border-hover: #cbd5e1;
    /* Slate 300 */

    --text: #0f172a;
    /* Slate 900 - Ana Metin */
    --text-secondary: #334155;
    /* Slate 700 - İkincil Metin */
    --text-mute: #64748b;
    /* Slate 500 - Pasif Metin */

    /* UI Measurements */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Shadows (Soft & Diffused) */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Animation */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Overrides */
/* Body sınıfına "dark-mode" eklenerek aktif edilecek (JS ile kontrol ediliyor olabilir) 
   Mevcut yapıda 'light-mode' class'ı var, tam tersi mantıkla çalışıyor olabilir.
   Varsayılanı Light yaptık, şimdi Dark için override yazalım.
*/
body:not(.light-mode) {
    --bg-main: #0f172a;
    /* Slate 900 */
    --bg-panel: #1e293b;
    /* Slate 800 */
    --bg-secondary: #334155;
    /* Slate 700 */

    --border: #334155;
    /* Slate 700 */
    --border-hover: #475569;
    /* Slate 600 */

    --text: #f8fafc;
    /* Slate 50 */
    --text-secondary: #cbd5e1;
    /* Slate 300 */
    --text-mute: #94a3b8;
    /* Slate 400 */

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);

    /* Dark Mode High Contrast Override for Black Theme */
    --primary: #ffffff;
    --primary-dark: #e2e8f0;
    --primary-light: #1e293b;
}

/* Theme Colors Overrides */
body.theme-blue {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #dbeafe;
}

body.theme-orange {
    --primary: #f97316;
    --primary-dark: #ea580c;
    --primary-light: #ffedd5;
}

body.theme-green {
    --primary: #22c55e;
    --primary-dark: #16a34a;
    --primary-light: #dcfce7;
}

body.theme-pink {
    --primary: #ec4899;
    --primary-dark: #db2777;
    --primary-light: #fce7f3;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    display: flex;
    transition: var(--transition);
}

/* ========== TYPOGRAPHY ========== */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.5em;
    letter-spacing: -0.02em;
    /* Modern look */
}

h1 {
    font-size: 2.25rem;
}

h2 {
    font-size: 1.875rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* ========== LAYOUT STRUCTURE ========== */
.mobile-header,
.mobile-bottom-nav {
    display: none;
}

#appScreen {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: row;
}

/* --- Sidebar --- */
.sidebar {
    width: 280px;
    /* Biraz daha geniş */
    height: 100vh;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 32px 24px;
    flex-shrink: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 12px;
}

.sidebar-brand img {
    width: 36px;
    height: auto;
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Butonlar arası boşluk */
}

.nav-btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition);
}

.nav-btn i {
    font-size: 1.1rem;
    color: var(--text-mute);
    transition: var(--transition);
    width: 20px;
    text-align: center;
}

.nav-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--text);
}

.nav-btn:hover i {
    color: var(--primary);
}

.nav-btn.active {
    background-color: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}

/* Dark modda active durum farklı olmalı */
body:not(.light-mode) .nav-btn.active {
    background-color: rgba(99, 102, 241, 0.15);
    /* Primary color with opacity */
    color: var(--primary);
}

.nav-btn.active i {
    color: var(--primary);
}

/* Sidebar Footer */
.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Sidebar Collapse Button */
.sidebar-collapse-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-mute);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.75rem;
    margin: 0 12px 16px auto;
}

.sidebar-collapse-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-secondary);
}

/* Sidebar Collapsed State */
.sidebar.collapsed {
    width: 72px;
    padding: 32px 10px;
    align-items: center;
}

.sidebar.collapsed .sidebar-brand-text {
    display: none;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    margin-bottom: 24px;
}

.sidebar.collapsed .sidebar-collapse-btn {
    margin: 0 auto 12px auto;
}

.sidebar.collapsed .nav-btn span {
    display: none;
}

.sidebar.collapsed .nav-btn {
    justify-content: center;
    padding: 12px;
}

.sidebar.collapsed .nav-btn i {
    margin: 0;
}

.sidebar.collapsed .sidebar-footer {
    justify-content: center;
}

.sidebar.collapsed .settings-nav-btn span {
    display: none;
}

.mini-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-mute);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.mini-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-panel);
}

.mini-btn.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    height: 100vh;
    padding: 40px;
    /* Daha ferah padding */
    overflow-y: auto;
    background-color: var(--bg-main);
    position: relative;
    /* Sidebar genişliği style ile verilmişse override gerekebilir, 
       ama flex yapıda otomatik doldurur. JS ile margin veriliyorsa kontrol etmek gerek. */
}

.view-section {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeScale 0.3s ease-out;
}

.view-section.active {
    display: block;
}

@keyframes fadeScale {
    from {
        opacity: 0;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========== COMPONENTS ========== */

/* --- Card/Panel --- */
.panel-card,
.dash-card,
.wallet-sidebar,
.card {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    /* Hafif border */
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    /* Çok hafif gölge */
    transition: var(--transition);
}

.panel-card:hover,
.dash-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

/* --- Buttons --- */
.primary-btn {
    background-color: var(--primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2);
}

.primary-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(99, 102, 241, 0.3);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn.full {
    width: 100%;
}

.primary-btn.small {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.select-btn {
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.select-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.danger-btn {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid transparent;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.danger-btn:hover {
    background-color: var(--danger);
    color: white;
}

/* --- Inputs --- */
.std-input,
.std-select,
.std-textarea {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
    margin-bottom: 16px;
}

.std-input:focus,
.std-select:focus,
.std-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background-color: var(--bg-panel);
}

/* Dark mode focus ring tweak */
body:not(.light-mode) .std-input:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* --- Modals --- */
.modal-overlay {
    background-color: rgba(15, 23, 42, 0.6);
    /* Slate 900 with opacity */
    backdrop-filter: blur(4px);
    /* Hafif blur */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    /* JS ile flex yapılıyor */
    align-items: center;
    justify-content: center;
}

.modal-card {
    background-color: var(--bg-panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 480px;
    max-width: 90%;
    max-height: 90vh;
    padding: 32px;
    overflow-y: auto;
    position: relative;
    border: 1px solid var(--border);
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.wide {
    width: 720px;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(40px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.m-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.m-head h3 {
    margin: 0;
    font-size: 1.25rem;
}

.close-x {
    font-size: 1.5rem;
    color: var(--text-mute);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.close-x:hover {
    background-color: var(--bg-secondary);
    color: var(--text);
}

.m-foot {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* --- Helpers --- */
.mb-2 {
    margin-bottom: 16px;
}

.mt-2 {
    margin-top: 16px;
}

.flex-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-mute);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 800px) {
    .sidebar {
        display: none;
        /* JS ile mobilde açılıyorsa class eklenebilir ama şimdilik gizli */
    }

    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background-color: var(--bg-panel);
        border-bottom: 1px solid var(--border);
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 1000;
        gap: 15px;
        /* Prevent overlap */
    }

    .m-brand {
        flex: 1;
        min-width: 0;
        /* Enable truncation if needed */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .m-tools {
        display: flex;
        gap: 8px;
        flex-shrink: 0;
        /* Prevent icons from squishing */
    }

    .main-content {
        padding: 80px 16px 100px 16px;
        margin-left: 0;
        width: 100%;
    }

    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: var(--bg-panel);
        border-top: 1px solid var(--border);
        padding: 10px 0;
        z-index: 1000;
        justify-content: space-around;
    }

    .m-nav-btn {
        background: none;
        border: none;
        color: var(--text-mute);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        font-size: 0.75rem;
        cursor: pointer;
    }

    .m-nav-btn.active {
        color: var(--primary);
    }

    .m-nav-btn i {
        font-size: 1.25rem;
    }

    .split-layout,
    .wallet-layout,
    .habit-columns {
        display: flex;
        flex-direction: column;
        gap: 24px;
    }
}

/* Kalan kısımlar (Custom Folder Dropdown vs.) */
.custom-folder-select {
    padding: 12px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text);
}

.folder-dropdown {
    position: absolute;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    width: 100%;
    z-index: 50;
    box-shadow: var(--shadow-lg);
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.folder-option {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
}

.folder-option:hover {
    background-color: var(--bg-secondary);
    color: var(--primary);
}

/* Color Picker Circles */
.color-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.c-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}

.c-circle:hover,
.c-circle.active {
    transform: scale(1.1);
    border-color: var(--text);
}