/* =========================
   GLOBAL STYLING
========================= */

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

:root, :root[data-theme="light"] {
    color-scheme: light;
    --background: #f5f6fa;
    --sidebar: #ffffff;
    --card: #ffffff;
    --primary: #7054d8;
    --primary-hover: #5f42c3;
    --text-primary: #202231;
    --text-secondary: #656b7d;
    --border: #e5e7ef;
    --success: #13815e;
    --danger: #c93f57;
    --hover-surface: #f0eefb;
    --input-surface: #f8f9fc;
    --overlay: rgba(21, 24, 38, .45);
    --ring-track: #e9e9f0;
    --shadow: 0 10px 32px rgba(27, 31, 57, .045);
    --shadow-hover: 0 18px 40px rgba(27, 31, 57, .095);
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #101116;
    --sidebar: #17181f;
    --card: #1c1d26;
    --primary: #9b85f5;
    --primary-hover: #b2a0ff;
    --text-primary: #f4f3fa;
    --text-secondary: #a3a5b7;
    --border: #30313e;
    --success: #67d8ad;
    --danger: #fb8196;
    --hover-surface: #292938;
    --input-surface: #171821;
    --overlay: rgba(0, 0, 0, .72);
    --ring-track: #383946;
    --shadow: 0 10px 32px rgba(0, 0, 0, .12);
    --shadow-hover: 0 18px 40px rgba(0, 0, 0, .23);
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
}


/* =========================
   MAIN LAYOUT
========================= */

.app-container {
    display: flex;
    min-height: 100vh;
}


/* =========================
   SIDEBAR
========================= */

.sidebar {
    width: 250px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);

    padding: 30px 20px;

    display: flex;
    flex-direction: column;
}

.logo {
    margin-bottom: 50px;
}

.logo h2 {
    font-size: 28px;
    font-weight: 700;
}

.logo span {
    color: var(--primary);
}

.navigation {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    padding: 14px 18px;

    text-decoration: none;
    color: var(--text-secondary);

    border-radius: 10px;

    transition: 0.2s ease;
}

.nav-item:hover {
    background: #1f2937;
    color: white;
}

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

.sidebar-footer {
    margin-top: auto;
    color: var(--text-secondary);
    font-size: 12px;
}


/* =========================
   MAIN CONTENT
========================= */

.main-content {
    flex: 1;
    min-width: 0;
    padding: 40px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 40px;
}

.topbar h1 {
    font-size: 32px;
    margin-bottom: 8px;
}

.topbar p {
    color: var(--text-secondary);
}


/* =========================
   BUTTONS
========================= */

.primary-btn {
    background: var(--primary);
    color: white;

    border: none;
    border-radius: 10px;

    padding: 14px 22px;

    font-size: 14px;
    font-weight: 600;

    cursor: pointer;

    transition: 0.2s ease;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}


/* =========================
   SUMMARY CARDS
========================= */

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;

    margin-bottom: 35px;
}

.summary-card {
    background: var(--card);

    padding: 25px;

    border-radius: 16px;
    border: 1px solid var(--border);

    transition: 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.summary-card p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 18px;
}

.summary-card h2 {
    font-size: 28px;
    margin-bottom: 12px;
}

.summary-card span {
    color: var(--text-secondary);
    font-size: 12px;
}

.summary-card .positive {
    color: var(--success);
}

.summary-card .negative {
    color: var(--danger);
}


/* =========================
   CONTENT CARDS
========================= */

.content-card {
    background: var(--card);

    border: 1px solid var(--border);
    border-radius: 16px;

    padding: 30px;
}

.section-header {
    margin-bottom: 25px;
}

.section-header h2 {
    font-size: 20px;
}

.empty-state {
    text-align: center;
    padding: 50px;

    color: var(--text-secondary);
}


/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1200px) {

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

}

@media (max-width: 768px) {

    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .main-content {
        padding: 20px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

}

/* =========================
   MODAL
========================= */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;

    background: rgba(0, 0, 0, 0.7);

    justify-content: center;
    align-items: center;

    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);

    width: 450px;
    max-width: 95%;

    padding: 30px;
    border-radius: 18px;

    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 25px;
}

.close-btn {
    background: none;
    border: none;

    color: var(--text-secondary);
    font-size: 28px;

    cursor: pointer;
}

.close-btn:hover {
    color: white;
}

/* =========================
   FORMS
========================= */

.form-group {
    display: flex;
    flex-direction: column;

    margin-bottom: 20px;
}

.form-group label {
    margin-bottom: 8px;

    color: var(--text-secondary);
    font-size: 13px;
}

.form-group input,
.form-group select {
    background: var(--background);

    border: 1px solid var(--border);
    border-radius: 8px;

    padding: 12px;

    color: white;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.submit-btn {
    width: 100%;
    margin-top: 10px;
}

/* =========================
   TRANSACTION LIST
========================= */

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 18px 0;

    border-bottom: 1px solid var(--border);
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-info h4 {
    margin-bottom: 5px;
}

.transaction-info p {
    color: var(--text-secondary);
    font-size: 12px;
}

.transaction-amount {
    font-weight: 600;
    font-size: 16px;
}

.transaction-amount.income {
    color: var(--success);
}

.transaction-amount.expense {
    color: var(--danger);
}

.transaction-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
}

.delete-btn:hover {
    color: var(--danger);
}

/* =========================
   MONTH NAVIGATION
========================= */

.month-navigation {
    display: flex;
    align-items: center;
    gap: 20px;

    margin-bottom: 30px;

    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;

    padding: 20px 25px;
}

.month-btn {
    width: 42px;
    height: 42px;

    border: 1px solid var(--border);
    border-radius: 10px;

    background: var(--background);
    color: white;

    cursor: pointer;
    font-size: 18px;

    transition: 0.2s;
}

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

.month-display {
    min-width: 180px;
    text-align: center;
}

.month-label {
    color: var(--text-secondary);
    font-size: 10px;
    letter-spacing: 1.5px;
}

.month-display h2 {
    margin-top: 5px;
    font-size: 20px;
}

.today-btn {
    margin-left: auto;

    background: transparent;
    border: 1px solid var(--border);

    color: var(--text-secondary);

    padding: 12px 18px;
    border-radius: 10px;

    cursor: pointer;

    transition: 0.2s;
}

.today-btn:hover {
    color: white;
    border-color: var(--primary);
}

@media (max-width: 768px) {
    .month-navigation {
        flex-wrap: wrap;
        justify-content: center;
        gap: 12px;
    }

    .today-btn {
        margin-left: 0;
    }
}

/* =========================
   RECURRING TRANSACTIONS
========================= */

.recurring-option {
    margin: 25px 0;
    padding: 18px;

    background: rgba(99, 102, 241, 0.08);

    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 12px;

    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.checkbox-container input {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-custom {
    display: none;
}

.recurring-description {
    margin-top: 10px;
    margin-left: 30px;

    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

.recurring-badge {
    display: inline-block;

    margin-left: 10px;
    padding: 4px 8px;

    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-hover);

    border-radius: 6px;

    font-size: 10px;
    font-weight: 600;
}

/* =========================
   EDIT TRANSACTION BUTTON
========================= */

.edit-btn {
    background: transparent;
    border: none;

    color: var(--text-secondary);

    font-size: 18px;

    cursor: pointer;

    transition: 0.2s ease;
}

.edit-btn:hover {
    color: var(--primary-hover);
    transform: scale(1.15);
}

.edit-btn:focus-visible,
.delete-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 4px;
}

/* =========================
   BUDGET BACKUP SECTION
========================= */

.backup-section {
    margin-top: 30px;
    padding-top: 24px;

    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.backup-title {
    font-size: 12px;
    font-weight: 600;

    text-transform: uppercase;
    letter-spacing: 1px;

    color: #8b93a7;

    margin-bottom: 14px;
}

.backup-btn {
    width: 100%;

    display: flex;
    align-items: center;
    gap: 12px;

    padding: 12px 14px;
    margin-bottom: 8px;

    background: transparent;

    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;

    color: #cbd5e1;

    font-size: 13px;
    font-weight: 500;

    cursor: pointer;

    transition: all 0.2s ease;
}

.backup-btn:hover {
    background: rgba(139, 92, 246, 0.12);

    border-color: rgba(139, 92, 246, 0.4);

    color: #ffffff;

    transform: translateX(3px);
}

.backup-btn span {
    font-size: 16px;
}

.backup-btn:focus-visible {
    outline: 2px solid #a78bfa;
    outline-offset: 3px;
}

/* =========================
   APP PAGES
========================= */

.app-page {
    display: none;
}

.app-page.active-page {
    display: block;
}


/* =========================
   TRANSACTION FILTERS
========================= */

.transaction-filters {
    display: grid;

    grid-template-columns: 2fr 1fr 1fr;

    gap: 16px;

    margin-top: 25px;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;

    gap: 8px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 500;

    color: #94a3b8;
}

.filter-group input,
.filter-group select {
    width: 100%;

    padding: 12px 14px;

    background: #151b2e;

    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;

    color: #ffffff;

    font-size: 13px;

    outline: none;

    transition: border-color 0.2s ease;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: #8b5cf6;
}

.filter-group input::placeholder {
    color: #64748b;
}

.transaction-results {
    padding: 15px 0;

    border-bottom: 1px solid rgba(255, 255, 255, 0.08);

    margin-bottom: 10px;
}

.transaction-results span {
    font-size: 13px;

    color: #94a3b8;
}

.section-description {
    margin-top: 6px;

    color: #94a3b8;

    font-size: 13px;
}


/* =========================
   RESPONSIVE FILTERS
========================= */

@media (max-width: 900px) {

    .transaction-filters {
        grid-template-columns: 1fr;
    }

}

/* =========================
   TRANSACTION SUMMARY
========================= */

.transaction-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.transaction-summary-grid .summary-card {
    min-width: 0;
}

.transaction-summary-grid .summary-card h2 {
    overflow-wrap: anywhere;
}


/* =========================
   TRANSACTION DATE FILTERS
========================= */

.transaction-date-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {

    .transaction-summary-grid {
        grid-template-columns: 1fr;
    }

    .transaction-date-filters {
        grid-template-columns: 1fr;
    }

}
/* Budget planner – phase 1 */
[hidden] { display: none !important; }
.budget-planner-top,.budget-month-controls,.budget-overview,.budget-card-actions,.budget-editor-actions { display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap; }
.budget-month-controls { justify-content:center; margin:28px 0; }
.budget-month-controls button,.budget-small-btn { background:var(--card); color:var(--text-primary); border:1px solid var(--border); border-radius:9px; padding:10px 14px; cursor:pointer; }
.budget-overview { padding:20px; border:1px solid var(--border); border-radius:12px; margin-bottom:22px; }
.budget-overview div { display:flex; flex-direction:column; gap:8px; }
.budget-overview strong { font-size:25px; }
.budget-category-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:16px; }
.budget-category-card { border:1px solid var(--border); border-top:4px solid var(--category-color); border-radius:14px; padding:20px; background:var(--card); min-width:0; }
.budget-category-card h3 { font-size:18px; overflow-wrap:anywhere; }
.budget-category-value { font-size:24px; font-weight:700; margin:18px 0 6px; }
.budget-category-subtitle { color:var(--text-secondary); font-size:13px; margin-bottom:18px; }
.budget-card-actions { justify-content:flex-start; }
.budget-editor { margin-top:20px; }
.budget-editor h2 { margin-bottom:18px; }
.budget-editor form { max-width:560px; }
.budget-editor-details { display:grid; grid-template-columns:1fr 1fr; gap:15px; }
.budget-editor-actions { justify-content:flex-start; margin-top:18px; }
.budget-category-card button:hover,.budget-month-controls button:hover { filter:brightness(1.2); }
@media(max-width:600px) { .budget-editor-details { grid-template-columns:1fr; } }

/* Budgetly 1.0 – transaction-to-budget linking */
.budget-field-hint { margin-top: 7px; font-size: 12px; color: #94a3b8; }
.budget-category-spending { font-size: 13px; margin: 0 0 9px; color: #b9c5d7; }
.budget-category-spending.budget-over-limit { color: #fb7185; }


/* Budgetly v1.0 – budget donut charts */
.budget-donut {
    --donut-color: #34d399;
    --donut-fill: 0%;
    width: 148px;
    height: 148px;
    margin: 18px auto 6px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--donut-color) 0 var(--donut-fill), rgba(148, 163, 184, .19) var(--donut-fill) 100%);
    flex-shrink: 0;
}
.budget-donut-center {
    width: 116px;
    height: 116px;
    border-radius: 50%;
    background: var(--card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-primary);
}
.budget-donut-center strong { font-size: 28px; line-height: 1.1; }
.budget-donut-center span { font-size: 12px; color: var(--text-secondary); }
.budget-donut-total { width: 180px; height: 180px; margin: 0; }
.budget-donut-total .budget-donut-center { width: 144px; height: 144px; }
.budget-donut-total .budget-donut-center strong { font-size: 34px; }
.budget-overview { justify-content: flex-start; gap: 26px; }
.budget-overview .budget-total-chart { flex: 0 0 auto; }
.budget-overview .budget-total-details { display: flex; flex: 1; min-width: 200px; flex-direction: column; align-items: flex-start; gap: 8px; }
.budget-total-details #budgetTotalAmount { font-size: 28px; }
.budget-total-details #budgetTotalSpent { color: var(--text-secondary); }
.budget-total-remaining { color: #34d399; font-size: 18px !important; }
.budget-total-remaining.budget-over-limit { color: #fb7185; }
.budget-total-details small { color: var(--text-secondary); line-height: 1.5; }
.budget-overview #budgetCategoryCount { align-self: flex-start; margin-left: auto; color: var(--text-secondary); white-space: nowrap; }
.budget-category-card { display: flex; flex-direction: column; align-items: center; text-align: center; }
.budget-category-card h3 { align-self: stretch; }
.budget-category-value { margin: 12px 0 6px; }
.budget-category-subtitle { margin-top: auto; }
.budget-card-actions { width: 100%; justify-content: center; }
@media (max-width: 600px) {
    .budget-overview { justify-content: center; text-align: center; }
    .budget-overview .budget-total-details { align-items: center; }
    .budget-overview #budgetCategoryCount { margin-left: 0; }
}

/* =====================================================
   BUDGETLY PREMIUM UI – theme-safe component refinements
   The existing app structure and JavaScript remain intact.
===================================================== */
html { scroll-behavior: smooth; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif; font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.sidebar { width: 258px; flex: 0 0 258px; padding: 34px 20px 24px; }
.logo { margin-bottom: 42px; padding-left: 12px; }
.logo h2 { font-size: 27px; letter-spacing: -1.2px; font-weight: 760; }
.navigation { gap: 5px; }
.nav-item { padding: 12px 15px; font-weight: 550; border-radius: 12px; }
.nav-item:hover { background: var(--hover-surface); color: var(--text-primary); }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 5px 14px rgba(109, 85, 214, .17); }
:root[data-theme="dark"] .nav-item.active { color: #15121f; }
.main-content { padding: 42px clamp(22px, 4vw, 68px); max-width: 1800px; }
.topbar { margin-bottom: 32px; gap: 20px; }
.topbar h1 { font-size: clamp(26px, 2.5vw, 36px); font-weight: 740; letter-spacing: -1.2px; }
.topbar p { font-size: 13px; }
.primary-btn { border-radius: 12px; padding: 12px 20px; box-shadow: 0 5px 15px rgba(100, 82, 200, .14); }
.primary-btn:hover { transform: translateY(-1px); }
:root[data-theme="dark"] .primary-btn { color: #171322; }
.summary-grid { gap: 16px; margin-bottom: 28px; }
.summary-card, .content-card, .month-navigation, .budget-overview, .budget-category-card, .modal { box-shadow: var(--shadow); border-radius: 19px; }
.summary-card { padding: 24px; }
.summary-card:hover { box-shadow: var(--shadow-hover); border-color: var(--border); transform: translateY(-2px); }
.summary-card h2 { font-size: clamp(22px, 2vw, 29px); letter-spacing: -.6px; font-variant-numeric: tabular-nums; }
.content-card { padding: clamp(20px, 2.4vw, 32px); }
.month-navigation { padding: 18px 24px; }
.month-btn, .today-btn, .budget-month-controls button, .budget-small-btn { background: var(--input-surface); color: var(--text-primary); border: 1px solid var(--border); }
.month-btn:hover, .today-btn:hover, .budget-small-btn:hover { background: var(--hover-surface); color: var(--text-primary); }
.modal-overlay { background: var(--overlay); backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); padding: 16px; }
.modal { max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: var(--shadow-hover); }
.close-btn:hover { color: var(--text-primary); }
.form-group input, .form-group select, .filter-group input, .filter-group select { background: var(--input-surface); color: var(--text-primary); border: 1px solid var(--border); border-radius: 11px; }
.form-group input::placeholder, .filter-group input::placeholder { color: var(--text-secondary); opacity: .8; }
.filter-group label, .transaction-results span, .section-description, .budget-field-hint, .budget-category-spending { color: var(--text-secondary); }
.transaction-results { border-bottom: 1px solid var(--border); }
.backup-section { border-top: 1px solid var(--border); }
.backup-title { color: var(--text-secondary); }
.backup-btn { color: var(--text-secondary); border: 1px solid var(--border); border-radius: 11px; }
.backup-btn:hover { color: var(--text-primary); background: var(--hover-surface); border-color: var(--primary); transform: translateX(2px); }
.recurring-option { background: var(--hover-surface); border-color: var(--border); }
.recurring-badge { background: var(--hover-surface); color: var(--primary); }
.budget-category-card { transition: box-shadow .2s ease, transform .2s ease; }
.budget-category-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.budget-donut { background: conic-gradient(var(--donut-color) 0 var(--donut-fill), var(--ring-track) var(--donut-fill) 100%); }
.budget-category-spending.budget-over-limit, .budget-total-remaining.budget-over-limit { color: var(--danger); }
.budget-total-remaining { color: var(--success); }
.budget-donut-center { background: var(--card); }
.theme-settings { margin-top: 32px; padding: 18px 4px 0; border-top: 1px solid var(--border); }
.theme-settings label { display: block; font-size: 11px; letter-spacing: .7px; text-transform: uppercase; font-weight: 700; color: var(--text-secondary); margin-bottom: 10px; }
.theme-control { display: flex; align-items: center; gap: 10px; padding: 9px 11px; background: var(--input-surface); border: 1px solid var(--border); border-radius: 12px; }
#themeIcon { font-size: 18px; width: 20px; text-align: center; color: var(--primary); }
#themePreference { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--text-primary); cursor: pointer; font-size: 13px; outline-offset: 4px; }
.sidebar-footer { margin-top: 20px; padding-left: 4px; }
@media (max-width: 768px) { .sidebar { width: 100%; flex: auto; padding: 22px 18px; } .logo { margin-bottom: 20px; } .navigation { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); } .main-content { padding: 22px 16px; } .theme-settings { margin-top: 18px; } .topbar { align-items: stretch; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Premium analytics – uses the existing light/dark theme tokens */
.analytics-panel { padding: 28px; }
.analytics-heading, .analytics-chart-header { display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.analytics-heading h2 { margin-bottom:6px; }
.analytics-year-controls { display:flex; align-items:center; gap:18px; }
.analytics-year-controls button { background:var(--input-surface); border:1px solid var(--border); color:var(--text-primary); border-radius:10px; padding:9px 13px; cursor:pointer; }
.analytics-year-controls button:hover { background:var(--hover-surface); }
.analytics-summary { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin:24px 0 32px; }
.analytics-metric { background:var(--input-surface); border:1px solid var(--border); border-radius:16px; padding:20px; display:flex; flex-direction:column; gap:9px; }
.analytics-metric span { color:var(--text-secondary); font-size:13px; }
.analytics-metric strong { font-size:clamp(18px,2vw,26px); overflow-wrap:anywhere; }
.analytics-chart-header { margin-bottom:18px; }
.analytics-legend { display:flex; gap:18px; color:var(--text-secondary); font-size:13px; }
.analytics-legend span { display:flex; align-items:center; gap:7px; }
.analytics-key { display:inline-block; width:10px; height:10px; border-radius:3px; }
.analytics-key.income,.analytics-bar.income { background:var(--primary); }
.analytics-key.expense,.analytics-bar.expense { background:var(--danger); }
.analytics-chart { height:280px; display:grid; grid-template-columns:repeat(12,minmax(0,1fr)); gap:8px; border-bottom:1px solid var(--border); }
.analytics-bar-group { min-width:0; display:flex; flex-direction:column; align-items:center; gap:10px; font-size:12px; color:var(--text-secondary); }
.analytics-bars { flex:1; width:100%; display:flex; align-items:flex-end; justify-content:center; gap:3px; min-height:0; }
.analytics-bar { width:min(42%,24px); border-radius:5px 5px 0 0; min-height:0; transition:height .25s ease; }
.analytics-note { color:var(--text-secondary); font-size:12px; line-height:1.6; margin:22px 0 28px; }
.analytics-table-title { margin-bottom:14px; }
.analytics-table-wrap { overflow-x:auto; }
.analytics-table { width:100%; border-collapse:collapse; text-align:right; font-size:14px; white-space:nowrap; }
.analytics-table th:first-child,.analytics-table td:first-child { text-align:left; }
.analytics-table th { color:var(--text-secondary); font-weight:600; }
.analytics-table th,.analytics-table td { padding:13px 12px; border-bottom:1px solid var(--border); }
.analytics-negative { color:var(--danger); }
@media(max-width:700px) { .analytics-panel { padding:18px; } .analytics-summary { grid-template-columns:1fr; } .analytics-chart { gap:3px; height:220px; } .analytics-bar-group { font-size:10px; } }

/* Budgetly – savings page, theme-aware */
.savings-panel { display:grid; gap:24px; }
.savings-heading { display:flex; justify-content:space-between; align-items:center; gap:18px; flex-wrap:wrap; }
.savings-goal-card { background:var(--bg-secondary,var(--card-bg)); border:1px solid var(--border); border-radius:18px; padding:22px; display:grid; gap:14px; }
.savings-goal-card h3 { margin:0; }
.savings-goal-form { display:flex; align-items:end; gap:14px; flex-wrap:wrap; }
.savings-goal-form .form-group { flex:1; min-width:170px; margin:0; }
.savings-track { height:12px; border-radius:999px; background:var(--border); overflow:hidden; }
.savings-track > div { height:100%; width:0; border-radius:inherit; background:var(--primary); transition:width .25s ease; }
.savings-legacy { border:1px solid var(--border); padding:16px; border-radius:12px; color:var(--text-secondary); line-height:1.6; }

/* Statistik – månadssammanställning */
.analytics-detail { margin: 36px 0 32px; padding-top: 26px; border-top: 1px solid var(--border); }
.analytics-detail .analytics-heading { margin-bottom: 14px; }
.analytics-detail h3 { margin-bottom: 8px; }
.analytics-metric small { color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.analysis-categories { display: grid; gap: 16px; margin-top: 22px; }
.analysis-category { padding: 15px 17px; background: var(--input-surface); border: 1px solid var(--border); border-radius: 14px; }
.analysis-category-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 12px; font-size: 14px; }
.analysis-category-heading strong { text-align: right; font-size: 13px; }
.analysis-category-track { height: 9px; background: var(--border); border-radius: 20px; overflow: hidden; }
.analysis-category-fill { height: 100%; background: var(--primary); border-radius: inherit; transition: width .25s ease; }
@media (max-width: 600px) { .analysis-category-heading { align-items: flex-start; flex-direction: column; gap: 5px; } }

/* Sparande och prognos – följer Premium-teman */
.savings-total-number {font-size:clamp(26px,4vw,40px);color:var(--success);letter-spacing:-.035em;}
#forecastHorizon {background:var(--input-surface);color:var(--text-primary);border:1px solid var(--border);border-radius:11px;padding:10px;}


/* Budgetly 2.1 – export filename, accessible notifications and compact screens */
.backup-file-label { display:block; margin:12px 0 6px; color:var(--text-primary); font-size:12px; font-weight:600; }
.backup-file-input { width:100%; box-sizing:border-box; min-width:0; padding:11px 12px; border:1px solid var(--border); border-radius:11px; background:var(--input-surface); color:var(--text-primary); font:inherit; font-size:13px; }
.backup-file-input:focus-visible { outline:2px solid var(--primary); outline-offset:2px; }
.backup-file-help { color:var(--text-secondary); font-size:11px; line-height:1.45; margin:6px 0 12px; }
.budgetly-toast { position:fixed; z-index:10000; bottom:24px; right:24px; max-width:min(360px,calc(100vw - 32px)); padding:14px 18px; border:1px solid var(--border); border-radius:14px; color:var(--text-primary); background:var(--card-bg, var(--input-surface)); box-shadow:0 12px 36px rgba(0,0,0,.18); font-size:14px; }
.budgetly-toast[hidden] { display:none; }
@media(max-width:600px) {
    .budgetly-toast { left:16px; right:16px; bottom:16px; max-width:none; }
    .analytics-summary { grid-template-columns:repeat(auto-fit,minmax(min(100%,160px),1fr)); }
    .analytics-year-controls { flex-wrap:wrap; }
    input,select,textarea { max-width:100%; box-sizing:border-box; }
}
@media(prefers-reduced-motion:reduce) {
    .budgetly-toast, .analysis-category-fill { transition:none !important; }
}
