/* ============================================================
   assets/style.css — современный адаптивный интерфейс
   ============================================================ */

:root {
    --bg:        #f4f6fb;
    --card:      #ffffff;
    --text:      #1d2433;
    --muted:     #6b7590;
    --border:    #e5e9f2;
    --primary:   #4f6ef7;
    --primary-d: #3a56d6;
    --green:     #16a34a;
    --red:       #e11d48;
    --amber:     #f59e0b;
    --radius:    16px;
    --radius-sm: 10px;
    --shadow:    0 6px 24px rgba(29, 36, 51, .07);
    --shadow-lg: 0 14px 40px rgba(29, 36, 51, .12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; }

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 18px;
}

.main { flex: 1; padding-bottom: 48px; }

.muted { color: var(--muted); }
.pos   { color: var(--green); }
.neg   { color: var(--red); }

/* ---------------- Топбар ---------------- */

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 12px rgba(29, 36, 51, .04);
}

.topbar__inner {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 64px;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.topnav {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
}

.topnav a {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-weight: 500;
    font-size: .92rem;
}
.topnav a:hover {
    background: #eef1fb;
    color: var(--primary);
    text-decoration: none;
}

.topbar__user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.user-name {
    font-weight: 600;
    font-size: .92rem;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------- Кнопки ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: .93rem;
    font-weight: 600;
    cursor: pointer;
    transition: .18s;
    white-space: nowrap;
    font-family: inherit;
    text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

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

.btn--ghost {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
}
.btn--ghost:hover { border-color: var(--primary); color: var(--primary); }

.btn--sm { padding: 7px 12px; font-size: .85rem; }
.btn--block { width: 100%; }

.icon-btn {
    background: #f6f8fd;
    border: 1px solid var(--border);
    border-radius: 9px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .95rem;
    transition: .18s;
    padding: 0;
}
.icon-btn:hover { background: #eef1fb; border-color: var(--primary); }
.icon-btn--danger:hover { background: #ffeef2; border-color: var(--red); }

/* ---------------- Flash ---------------- */

.flashes { margin-top: 16px; }

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    font-weight: 500;
    border: 1px solid transparent;
}
.flash--ok  { background: #e9f9ef; color: #10693a; border-color: #bfe9cd; }
.flash--err { background: #ffeef2; color: #9f1239; border-color: #fbcfe0; }

/* ---------------- Страницы ---------------- */

.page-head, .profile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 26px 0 18px;
}

.page-title { font-size: 1.6rem; }

.breadcrumbs {
    margin-top: 20px;
    color: var(--muted);
    font-size: .9rem;
    display: flex;
    gap: 8px;
}

/* ---------------- Статистика ---------------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat__label { color: var(--muted); font-size: .84rem; font-weight: 500; }
.stat__value { font-size: 1.35rem; font-weight: 700; }

/* ---------------- Плитки ---------------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow);
    transition: .2s;
    color: var(--text);
}
.tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
    text-decoration: none;
}
.tile__icon { font-size: 1.7rem; }
.tile__title { font-weight: 700; font-size: 1rem; }
.tile__desc { color: var(--muted); font-size: .86rem; }

/* ---------------- Панели ---------------- */

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.panel--flush { padding: 0; overflow: hidden; }
.panel--accent { border-left: 4px solid var(--primary); }

.panel__title { font-size: 1.08rem; margin-bottom: 14px; }
.panel__title--pad { padding: 20px 22px 0; }

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ---------------- Формы ---------------- */

.form, .form-grid { display: grid; gap: 14px; }

.form-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-grid--filters { align-items: end; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field--wide { grid-column: 1 / -1; }
.field--check {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-size: .92rem;
}

.field > span {
    font-size: .84rem;
    font-weight: 600;
    color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .94rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: .18s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, .14);
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.search-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.search-form input { flex: 1; min-width: 200px; }

.inline-form { display: inline; }

.inline-edit {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}
.inline-input { max-width: 260px; padding: 7px 10px; font-size: .9rem; }
.inline-input--num { max-width: 80px; }

/* ---------------- Таблицы ---------------- */

.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

.table th {
    text-align: left;
    padding: 13px 16px;
    background: #f8fafd;
    color: var(--muted);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f3f9;
    vertical-align: middle;
}

.table tbody tr:hover { background: #fafbff; }

.table .num { text-align: right; white-space: nowrap; }
.actions-col { width: 1%; white-space: nowrap; text-align: right; }

.row-control { background: #fffdf3; }
.row-control:hover { background: #fffbe8; }

.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: #eef1fb;
    color: var(--primary-d);
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}

.bar {
    display: block;
    height: 6px;
    border-radius: 999px;
    background: #eef1f7;
    margin-top: 6px;
    overflow: hidden;
}
.bar__fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

/* ---------------- Итоги ---------------- */

.totals {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 18px 22px;
    border-top: 1px solid var(--border);
    background: #fbfcff;
}

.totals--grand {
    justify-content: space-between;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow);
    font-size: 1.05rem;
    margin-top: 20px;
}

.totals__item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: .85rem;
    color: var(--muted);
}
.totals__item strong { font-size: 1.08rem; }
.totals__item--main { margin-left: auto; }

/* ---------------- Счета ---------------- */

.account-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.account-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow);
    transition: .2s;
    color: var(--text);
}
.account-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
    text-decoration: none;
}
.account-card__bank { font-weight: 700; font-size: 1.05rem; }
.account-card__balance { font-size: 1.5rem; font-weight: 700; }
.account-card__meta {
    display: flex;
    gap: 14px;
    font-size: .85rem;
    font-weight: 600;
}
.account-card__more { color: var(--muted); font-size: .82rem; margin-top: 4px; }

.account-hero {
    text-align: center;
    padding: 26px 18px;
    background: linear-gradient(135deg, #eef2ff 0%, #f7f9ff 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}
.account-hero__title { font-size: 1.7rem; }
.account-hero__balance { font-size: 2rem; font-weight: 800; margin: 6px 0 2px; }

.month-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.month-form { flex: 1; min-width: 160px; max-width: 260px; }
.month-form select { width: 100%; }
.month-bar #toggleForm { margin-left: auto; }

/* ---------------- Графики ---------------- */

.charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 18px;
    margin-bottom: 20px;
}

.chart-card { margin-bottom: 0; }
.chart-box { position: relative; height: 320px; }

/* ---------------- Пустое состояние ---------------- */

.empty {
    text-align: center;
    padding: 46px 20px;
    color: var(--muted);
}
.empty p { margin: 0 0 14px; }

/* ---------------- Авторизация ---------------- */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #4f6ef7 0%, #7c3aed 100%);
    padding: 20px;
}

.auth-card {
    background: #fff;
    border-radius: 20px;
    padding: 38px 34px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
    text-align: center;
}

.auth-logo { font-size: 2.6rem; margin-bottom: 6px; }
.auth-card h1 { font-size: 1.4rem; }
.auth-card .muted { margin-bottom: 22px; font-size: .9rem; }
.auth-card form { text-align: left; }

/* ---------------- Футер ---------------- */

.footer {
    border-top: 1px solid var(--border);
    background: #fff;
    padding: 18px 0;
    color: var(--muted);
    font-size: .85rem;
    text-align: center;
}

/* ---------------- Адаптивность ---------------- */

@media (max-width: 900px) {
    .topnav { order: 3; width: 100%; flex: none; }
    .topbar__inner { min-height: auto; padding: 10px 18px; }
}

@media (max-width: 720px) {
    .page-title { font-size: 1.3rem; }
    .panel { padding: 16px; }
    .panel__title--pad { padding: 16px 16px 0; }
    .totals { gap: 14px; padding: 14px 16px; }
    .totals__item--main { margin-left: 0; width: 100%; }

    /* Таблицы превращаются в карточки */
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin: 0 12px 12px;
        padding: 8px 4px;
        background: #fff;
    }
    .table td {
        display: flex;
        justify-content: space-between;
        gap: 14px;
        border: none;
        padding: 7px 12px;
        text-align: right;
    }
    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--muted);
        font-size: .8rem;
        text-align: left;
        text-transform: uppercase;
        letter-spacing: .02em;
    }
    .table .actions-col { text-align: right; }
    .table .actions-col::before { content: ''; }
    .table tbody tr:hover { background: #fff; }

    .account-hero__balance { font-size: 1.6rem; }
    .chart-box { height: 260px; }
}

@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .stat { padding: 14px 16px; }
    .stat__value { font-size: 1.15rem; }
    .tile { padding: 16px; }
    .auth-card { padding: 28px 20px; }
    .user-name { max-width: 120px; }
}