﻿:root {
    --bg: #0a0f14;
    --surface: #141c24;
    --surface-2: #1a2530;
    --text: #ecf2f8;
    --muted: #8ea1b6;
    --primary: #3ecf8e;
    --danger: #ff5d73;
    --border: #233241;
}
body.theme-light {
    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface-2: #f8fbff;
    --text: #0f1b2a;
    --muted: #5f7388;
    --primary: #0ea66a;
    --danger: #e5484d;
    --border: #d8e2ec;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: radial-gradient(circle at top right, #1a2f3f 0%, var(--bg) 45%);
    color: var(--text);
}
body.theme-light {
    background: radial-gradient(circle at top right, #dceaf8 0%, var(--bg) 45%);
}

a { color: #89d8ff; text-decoration: none; }
.app-shell { max-width: 980px; margin: 0 auto; padding: 16px 16px 90px; }
.card {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.card-emphasis {
    background: linear-gradient(135deg, rgba(62, 207, 142, .14) 0%, var(--surface) 45%, var(--surface-2) 100%);
}
.card-soft {
    background: linear-gradient(180deg, rgba(255, 255, 255, .03) 0%, var(--surface) 100%);
}

.topbar {
    margin-bottom: 15px;
}

.topbar, .row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.brand-head { display: flex; align-items: center; min-width: 0; }
.logo-top {
    width: 132px;
    max-height: 38px;
    height: auto;
    object-fit: contain;
    display: block;
}
.user-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-meta h1 { margin-bottom: 4px; }
.user-meta { min-width: 0; }
.avatar-mini {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px;
    max-width: 28px;
    max-height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
    flex-shrink: 0;
    display: block;
}
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px;
    border: 1px solid var(--border);
    background: rgba(32, 49, 64, .45);
    border-radius: 999px;
    color: var(--text);
    font-weight: 600;
    max-width: 52vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
}
.filter { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.filter-form { display: flex; gap: 8px; align-items: center; }
.period-label {
    font-size: .92rem;
    font-weight: 700;
    color: var(--text);
    margin-right: 2px;
}

.filter-form {margin-bottom: 0;}

h1, h2 { margin: 0 0 8px; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1rem; }
h3 { margin: 0 0 8px; font-size: .95rem; color: var(--muted); }
.muted { color: var(--muted); margin: 0; }
.money { font-weight: 700; }
.positive { color: var(--primary); }
.negative { color: var(--danger); }
.status { margin: 10px 0; font-size: .9rem; }
.status.ok { color: var(--primary); }
.status.danger { color: var(--danger); }

.progress {
    background: #0e151c;
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin: 8px 0 12px;
}
.progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #2ad57f 0%, #54f2a8 100%);
    transition: width .35s ease;
}
.progress span.income-bar, .income-bar {
    background: linear-gradient(90deg, #2ea8ff 0%, #6be4ff 100%);
}

.form-grid { display: grid; gap: 10px; }
label { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); }
input, select {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #0d141b;
    color: var(--text);
    padding: 10px;
}
body.theme-light input,
body.theme-light select {
    background: #ffffff;
}

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-primary { background: var(--primary); color: #062312; }
.btn-danger { background: var(--danger); color: white; }
.btn-ghost { background: #203140; color: #d8e8f7; }
body.theme-light .btn-ghost { background: #d9e6f3; color: #1c3348; }
.btn-small { padding: 7px 10px; font-size: .78rem; }

.grid-cards { display: grid; grid-template-columns: 1fr; gap: 12px; }
.dashboard-stack {
    display: grid;
    gap: 16px;
}
.dashboard-budget-card {
    margin-bottom: 0;
}
.dashboard-flow-grid {
    display: grid;
    gap: 16px;
}
.compact-form {
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(3, 9, 15, .22);
}
.dashboard-hidden-form {
    display: none !important;
}
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}
.summary-strip {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 8px 0 12px;
}
.summary-item {
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.summary-label {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: .9rem;
}
.summary-value {
    margin: 0;
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
}
.summary-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--border);
}
.summary-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}
.category-list { display: grid; gap: 12px; margin: 8px 0 0; }
.category-list-grid {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.category-item { background: rgba(255,255,255,.02); border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.category-card {
    background: linear-gradient(180deg, rgba(255,255,255,.04) 0%, rgba(255,255,255,.015) 100%);
    padding: 14px;
}
.category-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}
.category-card-head small {
    display: block;
    margin-top: 4px;
}
.category-stats {
    display: grid;
    gap: 8px;
    margin-bottom: 10px;
}
.category-stats span {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: .88rem;
}
.category-stats strong {
    color: var(--text);
}
.category-progress {
    margin-bottom: 8px;
}
.category-progress span {
    min-width: 8px;
}
.danger-bar {
    background: linear-gradient(90deg, #ff7b87 0%, #ff5d73 100%) !important;
}
.category-footer {
    display: flex;
    justify-content: flex-end;
}
.category-top {
    align-items: flex-start;
}
.category-top strong,
.record-item strong {
    display: block;
    margin-bottom: 4px;
}
.category-meta {
    display: grid;
    justify-items: end;
    gap: 8px;
    flex-shrink: 0;
}
.record-list { display: grid; gap: 8px; margin: 12px 0; }
.scroll-records {
    max-height: 372px;
    overflow-y: auto;
    padding-right: 4px;
}
.scroll-records::-webkit-scrollbar {
    width: 8px;
}
.scroll-records::-webkit-scrollbar-thumb {
    background: rgba(142, 161, 182, .28);
    border-radius: 999px;
}
.record-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .02);
}
.record-item small { display: block; color: var(--muted); margin-top: 4px; }
.record-actions { display: grid; gap: 8px; justify-items: end; }
.chart-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
canvas { width: 100% !important; max-height: 280px; }
.avatar-preview {
    width: 56px !important;
    height: 56px !important;
    min-width: 56px;
    max-width: 56px;
    max-height: 56px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--border);
    margin-bottom: 0;
    display: block;
}
.settings-grid {
    margin: 0 auto 90px;
    max-width: 640px;
    grid-template-columns: 1fr;
}
.settings-grid .card { padding: 12px; }
.profile-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
@media (max-width: 640px) {
    .app-shell { padding: 10px 10px 86px; }
    .topbar { gap: 8px; }
    .topbar .btn { padding: 8px 10px; font-size: .82rem; }
    .user-meta h1 { font-size: 1.05rem; line-height: 1.2; }
    .user-meta .muted { font-size: .82rem; line-height: 1.2; }
    .settings-grid { gap: 8px; margin-bottom: 84px; }
    .settings-grid .card { padding: 10px; border-radius: 12px; }
    .settings-grid h2 { font-size: .95rem; margin-bottom: 6px; }
    .settings-grid label { font-size: .8rem; gap: 4px; }
    .settings-grid input,
    .settings-grid select { padding: 8px; font-size: .9rem; }
    .settings-grid input[type="file"] { font-size: .76rem; max-width: 100%; }
    .settings-grid .btn { padding: 8px 10px; font-size: .86rem; }
    .compact-form { padding: 12px; }
    .section-head {
        flex-direction: column;
        align-items: stretch;
    }
    .section-head .btn {
        width: 100%;
    }
    .category-top,
    .category-card-head,
    .record-item {
        flex-direction: column;
        align-items: stretch;
    }
    .category-meta,
    .record-actions {
        justify-items: stretch;
    }
    .record-actions .btn,
    .record-actions form,
    .category-meta .btn {
        width: 100%;
    }
    .category-stats span,
    .category-footer {
        justify-content: space-between;
    }
    .filter {
        flex-wrap: wrap;
    }
    .filter-form {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    .filter-form select {
        flex: 1;
        min-width: 110px;
    }
}

.auth-wrap { min-height: 100vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 420px; }
.login-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 6px;
}
.logo-login {
    width: min(220px, 72vw);
    max-height: 92px;
    height: auto;
    object-fit: contain;
}
.alert {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 10px;
}
.alert-error { background: rgba(255, 93, 115, .15); color: #ff9bab; border: 1px solid rgba(255, 93, 115, .3); }

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: #0d141b;
    border-top: 1px solid var(--border);
}
body.theme-light .bottom-nav { background: #ffffff; }
.bottom-nav a {
    color: var(--muted);
    text-align: center;
    padding: 14px 6px;
    font-size: .8rem;
}
.bottom-nav a.active { color: var(--text); background: #162230; }
body.theme-light .bottom-nav a.active { background: #e8f1fb; }

.app-nav {
    grid-template-columns: repeat(5, 1fr);
    align-items: end;
    padding-top: 8px;
}
.app-nav a {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 8px 4px 10px;
}
.nav-ico {
    width: 20px;
    height: 20px;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.nav-ico svg {
    width: 20px;
    height: 20px;
    display: block;
}
.app-nav a.active .nav-ico { color: var(--text); }
.nav-label {
    font-size: .68rem;
    line-height: 1;
}
.nav-plus {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 0;
    margin: -18px auto 6px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #072014;
    background: linear-gradient(145deg, #4ee9a3, #2dd989);
    box-shadow: 0 10px 24px rgba(46, 217, 137, .4);
    cursor: pointer;
}

.quick-modal[hidden] { display: none; }
.quick-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
}
.quick-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 7, 12, .66);
}
.quick-card {
    position: absolute;
    left: 50%;
    bottom: 76px;
    transform: translateX(-50%);
    width: min(520px, calc(100vw - 20px));
    border-radius: 16px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    padding: 12px;
    box-shadow: 0 22px 48px rgba(0, 0, 0, .45);
}
.quick-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.quick-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}
.quick-tab {
    border: 1px solid var(--border);
    background: #0d141b;
    color: var(--muted);
    border-radius: 10px;
    padding: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: .88rem;
}
.quick-tab.active {
    background: #203140;
    color: var(--text);
}
.quick-panel-shell[hidden] { display: none !important; }
.quick-panel-shell { display: none; }
.quick-panel-shell.active { display: block; }
.quick-panel[hidden] { display: none !important; }
.quick-panel { display: none; }
.quick-panel.active { display: grid; }

@media (min-width: 900px) {
    .grid-cards { grid-template-columns: repeat(3, 1fr); }
    .dashboard-flow-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .summary-strip { grid-template-columns: repeat(3, 1fr); }
    .settings-grid { grid-template-columns: 1fr 1fr; }
    .chart-grid { grid-template-columns: 1fr 1fr; }
    .bottom-nav { max-width: 980px; margin: 0 auto; left: 50%; transform: translateX(-50%); border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

@media (max-width: 640px) {
    .logo-top { width: 108px; max-height: 32px; }
    .user-chip { max-width: 46vw; font-size: .82rem; padding: 6px 9px; }
    .quick-card { bottom: 82px; padding: 10px; }
    .nav-plus { width: 46px; height: 46px; margin-top: -14px; }
    .quick-tabs {
        grid-template-columns: repeat(3, 1fr);
    }
}
