/* =============================================
   FINBOT — PREMIUM DESIGN SYSTEM v2
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* ─── LIGHT THEME (Now Default) ─── */
    --bg: #fdfaf7;
    --surface: #ffffff;
    --surface-2: #f8f3ed;
    --border: rgba(180, 120, 80, 0.08);
    --border-hover: rgba(180, 120, 80, 0.15);

    --text: #2c1a0e;
    --text-sub: #7a6050;
    --text-dim: #c0a898;
    --text-main: #2c1a0e;

    --coral: #c7603e;
    --coral-glow: rgba(199, 96, 62, 0.12);
    --amber: #b87820;
    --amber-glow: rgba(184, 120, 32, 0.12);
    --sage: #4a9447;
    --sage-glow: rgba(74, 148, 71, 0.12);
    --emerald: #3d8c40;
    --red: #c0433e;
    --red-glow: rgba(192, 67, 62, 0.12);
    --muted: #9a7a60;

    --success: var(--sage);
    --danger: var(--red);
    --primary: var(--coral);
    --blue: #4a7ab8;
    --blue-glow: rgba(74, 122, 184, 0.12);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(80, 40, 10, 0.05);
    --shadow-md: 0 12px 32px rgba(80, 40, 10, 0.08);
    --shadow-lg: 0 24px 64px rgba(80, 40, 10, 0.12);
}

/* ─── DARK THEME (Now Secondary) ─── */
[data-theme="dark"] {
    --bg: #110e0b;
    --surface: #1a1612;
    --surface-2: #231e18;
    --border: rgba(255, 220, 180, 0.07);
    --border-hover: rgba(255, 220, 180, 0.14);

    --text: #f5ede4;
    --text-sub: #8a7a6e;
    --text-dim: #4a3f35;
    --text-main: #f5ede4;

    --coral: #d77a5c;
    --coral-glow: rgba(215, 122, 92, 0.25);
    --amber: #e6a04a;
    --amber-glow: rgba(230, 160, 74, 0.22);
    --sage: #7db87a;
    --sage-glow: rgba(125, 184, 122, 0.2);
    --blue: var(--coral);
    --blue-glow: var(--coral-glow);
}

/* Плавный переход между темами */
*,
*::before,
*::after {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.1s ease, box-shadow 0.25s ease;
}

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

html {
    font-size: 16px;
}

/* ─── Светлая тема — переопределения компонентов ─── */
[data-theme="light"] body {
    background-image: none;
}

[data-theme="light"] .blob {
    filter: blur(120px);
    opacity: 0.35;
}

[data-theme="light"] .blob-1 {
    background: radial-gradient(circle, rgba(215, 122, 92, 0.25) 0%, transparent 70%);
}

[data-theme="light"] .blob-2 {
    background: radial-gradient(circle, rgba(230, 160, 74, 0.2) 0%, transparent 70%);
}

[data-theme="light"] .sidebar {
    box-shadow: 2px 0 16px rgba(80, 40, 10, 0.08);
}

[data-theme="light"] body {
    background-image: radial-gradient(at 0% 0%, rgba(199, 96, 62, 0.03) 0, transparent 50%), 
                      radial-gradient(at 100% 100%, rgba(184, 120, 32, 0.03) 0, transparent 50%);
}

.glass-panel {
    background: rgba(255, 255, 255, 0.7) !important;
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border: 1px solid rgba(180, 120, 80, 0.12);
    box-shadow: var(--shadow-md);
    border-radius: 24px;
}

[data-theme="dark"] .glass-panel {
    background: rgba(26, 22, 18, 0.7) !important;
    border: 1px solid rgba(255, 220, 180, 0.08);
}

.stat-card {
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    border: 1px solid var(--border);
}

.stat-icon {
    border-radius: 18px;
    box-shadow: 0 4px 12px var(--coral-glow);
}

body {
    font-family: 'Outfit', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* =============================================
   BACKGROUND ATMOSPHERE
   ============================================= */
.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(140px);
    z-index: 0;
    pointer-events: none;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(215, 122, 92, 0.10) 0%, transparent 70%);
    top: -200px;
    left: -100px;
    animation: drift1 25s ease-in-out infinite alternate;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(230, 160, 74, 0.08) 0%, transparent 70%);
    bottom: -150px;
    right: -100px;
    animation: drift2 30s ease-in-out infinite alternate;
}

@keyframes drift1 {
    to {
        transform: translate(80px, 60px);
    }
}

@keyframes drift2 {
    to {
        transform: translate(-60px, -80px);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

/* =============================================
   LAYOUT
   ============================================= */
.app-container {
    display: flex;
    min-height: 100vh;
    padding: 20px;
    gap: 20px;
    max-width: 1440px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.logo i {
    font-size: 28px;
    color: var(--coral);
    filter: drop-shadow(0 0 8px var(--coral-glow));
}

.logo span {
    font-size: 20px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--coral), var(--amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-sub);
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.nav-links li:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.nav-links li.active {
    background: linear-gradient(135deg, rgba(215, 122, 92, 0.15), rgba(230, 160, 74, 0.08));
    border-color: rgba(215, 122, 92, 0.25);
    color: var(--text);
}

.nav-links li.active i {
    color: var(--coral);
}

.nav-links li i {
    font-size: 18px;
}

.sidebar-footer {
    background: rgba(242, 92, 113, 0.06) !important;
    border: 1px solid rgba(242, 92, 113, 0.15) !important;
    border-radius: 14px;
    padding: 14px 16px;
    margin-top: auto;
}

.sidebar-footer div:first-child {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-sub);
    margin-bottom: 6px;
}

.sidebar-footer #sidebar-monthly {
    font-size: 22px;
    font-weight: 800;
    color: var(--red);
}

/* =============================================
   CONTENT AREA
   ============================================= */
.content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.page {
    display: none;
    flex-direction: column;
    gap: 20px;
    animation: pageIn 0.35s ease;
}

.page.active {
    display: flex;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.user-profile img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid var(--border-hover);
    transition: border-color 0.2s;
}

.user-profile img:hover {
    border-color: var(--blue);
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 10px;
    border: none;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn.primary {
    background: linear-gradient(135deg, var(--coral), var(--amber));
    color: #fff;
    box-shadow: 0 4px 15px rgba(215, 122, 92, 0.35);
}

.btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(215, 122, 92, 0.5);
}

.btn.secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border-hover);
}

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

.btn.full-width {
    width: 100%;
    justify-content: center;
    margin-top: 12px;
}

.btn-sm {
    padding: 6px 13px !important;
    font-size: 12px !important;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-sub);
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.btn.disabled, .btn-icon.disabled {
    cursor: not-allowed;
    opacity: 0.5;
    filter: grayscale(1);
    pointer-events: none;
}

/* =============================================
   STAT CARDS
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color 0.2s, transform 0.2s;
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.stat-card.highlight-balance {
    background: linear-gradient(135deg, rgba(215, 122, 92, 0.12), rgba(230, 160, 74, 0.05));
    border-color: rgba(215, 122, 92, 0.25);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    background: var(--coral-glow);
    color: var(--coral);
}

.stat-icon.green {
    background: var(--green-glow);
    color: var(--green);
}

.stat-icon.red {
    background: var(--red-glow);
    color: var(--red);
}

.stat-info p {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-sub);
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

.stat-info h2 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* =============================================
   CHART PANELS
   ============================================= */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
}

.chart-box h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-sub);
    margin-bottom: 18px;
}

/* =============================================
   AI HINTS
   ============================================= */
.ai-hints {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px 24px;
    background: linear-gradient(135deg, rgba(230, 160, 74, 0.06), var(--surface) 60%);
    border-color: rgba(230, 160, 74, 0.15);
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--amber);
}

.ai-header i {
    font-size: 22px;
    filter: drop-shadow(0 0 8px var(--amber-glow));
}

.ai-header h3 {
    flex: 1;
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.hints-content {
    font-size: 14px;
    color: var(--text-sub);
    line-height: 1.8;
}

.hints-content p {
    margin-bottom: 8px;
}

/* =============================================
   TRANSACTIONS TABLE
   ============================================= */
.table-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: 14px 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-sub);
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    text-align: left;
}

td {
    padding: 14px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.right {
    text-align: right;
}

.amount.income {
    color: var(--green);
    font-weight: 700;
}

.amount.expense {
    color: var(--text);
    font-weight: 600;
}

.category-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(215, 122, 92, 0.1);
    color: var(--muted);
    border: 1px solid rgba(215, 122, 92, 0.18);
}

/* =============================================
   BUDGET PAGE
   ============================================= */
.budget-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.budget-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 22px;
    transition: all 0.2s;
}

.budget-item:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.budget-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.budget-name {
    font-size: 15px;
    font-weight: 700;
}

.budget-amounts {
    display: flex;
    align-items: center;
    gap: 20px;
}

.budget-spent-label {
    font-size: 13px;
    color: var(--text-sub);
}

.budget-left-label {
    font-size: 14px;
    font-weight: 700;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-bar {
    height: 100%;
    border-radius: 100px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 0 8px currentColor;
}

.progress-label {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 500;
}

/* =============================================
   DEBTS PAGE
   ============================================= */
.debts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.debt-tabs {
    display: flex;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 6px;
}

.btn-tab {
    flex: 1;
    padding: 8px 12px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--text-sub);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-tab:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
}

.btn-tab.active {
    background: linear-gradient(135deg, rgba(215, 122, 92, 0.2), rgba(230, 160, 74, 0.12));
    color: var(--text);
    border: 1px solid rgba(215, 122, 92, 0.3);
}

.debt-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.debt-card:hover {
    border-color: var(--border-hover);
    border-left-color: inherit;
    transform: translateX(3px);
}

.debt-card-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.debt-type-icon {
    font-size: 30px;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    background: var(--surface-2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border: 1px solid var(--border);
}

.debt-creditor {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 3px;
}

.debt-meta {
    font-size: 12px;
    color: var(--text-sub);
    margin-top: 2px;
}

.debt-card-right {
    text-align: right;
    flex-shrink: 0;
}

.debt-direction {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.debt-amount {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.debt-monthly {
    font-size: 12px;
    color: var(--text-sub);
    margin: 4px 0 10px;
}

/* =============================================
   INVENTORY
   ============================================= */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.2s;
}

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

.card-content h3 {
    font-size: 15px;
    font-weight: 700;
}

.card-content p {
    font-size: 12px;
    color: var(--text-sub);
    margin-top: 2px;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
}

.badge {
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 700;
}

.badge.ok {
    background: rgba(16, 217, 139, 0.1);
    color: var(--green);
    border: 1px solid rgba(16, 217, 139, 0.2);
}

.badge.low {
    background: rgba(242, 92, 113, 0.1);
    color: var(--red);
    border: 1px solid rgba(242, 92, 113, 0.2);
}

/* =============================================
   MODALS
   ============================================= */
.hidden {
    display: none !important;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 14, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
}

.modal-content {
    background: var(--surface-2);
    border: 1px solid var(--border-hover);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(215, 122, 92, 0.08);
    animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    font-size: 17px;
    font-weight: 700;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-sub);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg);
    border: 1px solid var(--border-hover);
    border-radius: 10px;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--coral);
    box-shadow: 0 0 0 3px rgba(215, 122, 92, 0.12);
}

.form-group select option {
    background: var(--surface-2);
}

/* =============================================
   SPINNER / LOADER
   ============================================= */
.loader-overlay {
    background: var(--surface);
    border: 1px dashed rgba(215, 122, 92, 0.3);
    border-radius: 18px;
    padding: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-sub);
    font-size: 14px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 220, 180, 0.08);
    border-top-color: var(--coral);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner.big {
    width: 42px;
    height: 42px;
    border-width: 4px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =============================================
   WALLET BADGE
   ============================================= */
#wallet-badge {
    background: linear-gradient(135deg, rgba(230, 160, 74, 0.12), rgba(230, 160, 74, 0.04));
    border: 1px solid rgba(230, 160, 74, 0.22);
    border-radius: 100px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 700;
    font-size: 14px;
}

#wallet-badge:hover {
    background: linear-gradient(135deg, rgba(230, 160, 74, 0.2), rgba(230, 160, 74, 0.08));
    box-shadow: 0 0 16px rgba(230, 160, 74, 0.2);
}

#wallet-badge i {
    color: var(--amber);
    filter: drop-shadow(0 0 6px var(--amber-glow));
    font-size: 18px;
}

.compact-only {
    display: none;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
        padding: 12px;
        gap: 12px;
    }

    /* Fixed Slide-out Sidebar for mobile */
    .sidebar {
        position: fixed !important;
        left: -280px; /* Hide sidebar by default on mobile */
        top: 0;
        bottom: 0;
        z-index: 1000;
        width: 280px !important;
        height: 100vh !important;
        flex-direction: column !important;
        background: var(--surface) !important;
        padding: 24px 16px !important;
        gap: 8px !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: 20px 0 50px rgba(0,0,0,0.15);
        transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto !important;
    }

    .sidebar.open {
        left: 0 !important;
    }

    .logo {
        display: flex !important;
        border-bottom: 1px solid var(--border);
        margin-bottom: 8px;
    }

    .sidebar-footer {
        display: block !important;
        margin-top: auto;
    }

    .nav-links {
        flex-direction: column !important;
        flex: 1 !important;
        gap: 4px !important;
    }

    .nav-links li {
        width: 100%;
        flex-direction: row !important;
        padding: 12px 16px !important;
        gap: 12px !important;
        font-size: 14px !important;
        border-radius: 12px !important;
    }

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

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

    header h1 {
        font-size: 20px;
    }

    .debt-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .debt-card-right {
        text-align: left;
    }

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

    .container {
        display: block; /* Stack navigation and content */
    }

    .content {
        margin-left: 0 !important;
        padding: 10px !important;
    }

    .header-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .mobile-only, .compact-only {
        display: flex !important;
    }

    .global-header {
        position: sticky;
        top: 0;
        background: rgba(255,255,255,0.8);
        padding: 10px 0;
        backdrop-filter: blur(10px);
        margin-bottom: 20px !important;
    }

    #user-plan {
        display: none;
    }

    #wallet-balance {
        display: inline !important;
        font-size: 13px !important;
    }
    
    .interactive-badge {
        padding: 8px;
    }

    /* Table responsivenes: scroll instead of squash */
    .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .modal-content {
        margin: 16px;
        max-width: calc(100% - 32px) !important;
    }

    /* Store Grid Column Stacking */
    .store-grid {
        grid-template-columns: 1fr !important;
    }

    .featured-family-block {
        flex-direction: column !important;
        gap: 20px !important;
        align-items: flex-start !important;
        padding: 20px !important;
    }

    /* Compact view for Transactions Table */
    body.compact-view #transactions table th:nth-child(3),
    body.compact-view #transactions table td:nth-child(3),
    body.compact-view #transactions table th:nth-child(4),
    body.compact-view #transactions table td:nth-child(4),
    body.compact-view #transactions table th:nth-child(5),
    body.compact-view #transactions table td:nth-child(5) {
        display: none !important;
    }

    /* Budget Table responsive: smaller spaces to fit right away */
    #budget-categories-list table th, 
    #budget-categories-list table td {
        padding: 8px 10px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
    }

    /* Rounded author avatar fix */
    #transactions td span img, .author-avatar {
        display: inline-block !important;
        border-radius: 50% !important;
        width: 24px !important;
        height: 24px !important;
        object-fit: cover !important;
    }
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr; /* Single column on phones */
    }

    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* ─── THEME TOGGLE BUTTON ─── */
.theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border-hover);
    background: var(--surface-2);
    color: var(--text-sub);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.theme-btn:hover {
    background: var(--surface);
    color: var(--coral);
    border-color: var(--coral);
    box-shadow: 0 0 12px var(--coral-glow);
    transform: rotate(12deg);
}

/* ─── CHAT ─── */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-chip {
    padding: 8px 14px;
    border-radius: 100px;
    border: 1px solid var(--border-hover);
    background: var(--surface);
    color: var(--text-sub);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-chip:hover {
    background: var(--surface-2);
    color: var(--coral);
    border-color: var(--coral);
}

.chat-window {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    overflow-y: auto;
    min-height: 300px;
    max-height: calc(100vh - 380px);
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex: 1;
    text-align: center;
    color: var(--text-sub);
    padding: 32px;
}

.chat-welcome-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--coral-glow), var(--amber-glow));
    border: 1px solid rgba(215, 122, 92, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--amber);
}

.chat-welcome h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.chat-welcome p {
    font-size: 14px;
    line-height: 1.6;
}

.chat-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    max-width: 85%;
}

.chat-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: 1px solid var(--border-hover);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-sub);
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid var(--border);
}

.chat-msg--user .chat-bubble {
    background: linear-gradient(135deg, rgba(215, 122, 92, 0.15), rgba(230, 160, 74, 0.08));
    border-color: rgba(215, 122, 92, 0.2);
    color: var(--text);
    border-radius: 14px 4px 14px 14px;
}

.chat-msg--bot .chat-bubble {
    background: var(--surface-2);
    border-radius: 4px 14px 14px 14px;
}

/* Typing dots */
.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    height: 20px;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-sub);
    animation: blink 1.2s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {

    0%,
    80%,
    100% {
        opacity: 0.3;
        transform: scale(0.85);
    }

    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Input row */
.chat-input-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-input-wrap {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border-hover);
    border-radius: 16px;
    padding: 12px 12px 12px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-wrap:focus-within {
    border-color: var(--coral);
    box-shadow: 0 0 0 3px var(--coral-glow);
}

.chat-input-wrap textarea {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    resize: none;
    outline: none;
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
}

.chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--coral), var(--amber));
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    box-shadow: 0 2px 8px var(--coral-glow);
}

.chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px var(--coral-glow);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-hint {
    font-size: 11px;
    color: var(--text-dim);
    padding-left: 4px;
}

/* Light theme chat adjustments */
[data-theme="light"] .chat-window {
    box-shadow: 0 2px 12px rgba(80, 40, 10, 0.07);
}

/* ─── STORE & PAYMENTS ─── */
.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.plan-card {
    position: relative;
    padding: 32px;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    cursor: default;
    height: 100%; /* Ensure equal card heights */
}

.plan-card:hover {
    transform: translateY(-8px);
    border-color: var(--coral-glow);
}

.plan-card.popular {
    border: 2px solid var(--coral);
    box-shadow: 0 0 20px var(--coral-glow);
}

.plan-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--coral);
    color: #fff;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.plan-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--amber);
}

.plan-card h3 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.plan-price {
    font-size: 32px;
    font-weight: 800;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.plan-price span {
    font-size: 14px;
    color: var(--text-dim);
    font-weight: 400;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    flex-grow: 1; /* Push the button to the bottom */
}

.plan-features li {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-sub);
    text-align: left;
    min-height: 40px; /* Aligns items across cards */
}

.plan-features i {
    color: var(--success);
    font-size: 18px;
}

.buy-btn {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    border: none;
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: auto; /* Aligns all buttons at the bottom */
}

.plan-card.popular .buy-btn {
    background: linear-gradient(135deg, var(--coral), var(--amber));
    color: white;
    box-shadow: 0 4px 12px var(--coral-glow);
}

.buy-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}

/* Modal Payment Flow */
.payment-modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sbp-info {
    padding: 20px;
    background: var(--surface-2);
    border-radius: 18px;
    border: 1px dashed var(--border-hover);
    text-align: center;
}

.sbp-qr {
    width: 180px;
    height: 180px;
    background: white;
    margin: 10px auto;
    padding: 10px;
    border-radius: 12px;
}

.sbp-phone {
    font-size: 22px;
    font-weight: 700;
    margin: 12px 0;
    letter-spacing: 1px;
}

.sbp-bank {
    font-size: 14px;
    color: var(--text-sub);
}

/* Admin Transactions Table */
.admin-table-wrap {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
}

.payment-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 14px;
}

.payment-table th,
.payment-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.status-pending {
    background: rgba(230, 160, 74, 0.15);
    color: #e6a04a;
}

.status-completed {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.status-rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.approve-btn {
    background: var(--success);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

.reject-btn {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 8px;
}
/* =============================================
   ИНТЕРАКТИВНЫЕ БЕЙДЖИ (HEADER)
   ============================================= */
.badge-container {
    position: relative;
    display: inline-block;
}

.interactive-badge {
    padding: 8px 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: 0.3s;
    border: 1px solid var(--border);
}

.interactive-badge:hover {
    background: var(--surface-2);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.badge-popover {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 240px;
    padding: 24px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: left;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-hover);
    background: var(--surface);
    border-radius: 16px;
}

.badge-container:hover .badge-popover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.badge-popover h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text);
}

.badge-popover p {
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 20px;
    line-height: 1.4;
}

.badge-popover .btn.mini {
    padding: 10px 18px;
    font-size: 13px;
    border-radius: 12px;
}

/* =============================================
   ПРОФИЛЬ
   ============================================= */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 30px;
    margin-top: 30px;
}

.profile-card {
    padding: 40px;
    text-align: center;
}

.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

.profile-header img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--surface-2);
}

.profile-meta h3 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.profile-meta p {
    color: var(--text-sub);
    font-size: 14px;
    margin: 5px 0 15px 0;
}

.badge-active {
    background: var(--sage-glow);
    color: var(--sage);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--sage);
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-stats {
    padding: 40px;
}

.profile-stats h3 {
    margin-bottom: 30px;
    font-size: 20px;
    color: var(--text);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span {
    color: var(--text-sub);
    font-size: 15px;
}

.stat-row b {
    color: var(--text);
    font-size: 15px;
}


