/* ===================================================================
   MoneyTracker — стили приложения
   =================================================================== */
:root {
    --c-bg: #f4f6fb;
    --c-surface: #ffffff;
    --c-border: #e3e8f0;
    --c-text: #1f2733;
    --c-muted: #6b7280;
    --c-primary: #3b5bdb;
    --c-primary-dark: #2f49b0;
    --c-success: #2e7d32;
    --c-success-bg: #e6f4ea;
    --c-error: #c62828;
    --c-error-bg: #fdecea;
    --c-info: #1565c0;
    --c-info-bg: #e8f1fb;
    --c-income: #2e7d32;
    --c-expense: #d32f2f;
    --c-transfer: #6b7280;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.5;
}

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

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.main { padding-top: 28px; padding-bottom: 48px; }
.inline { display: inline; }

/* --- Топбар --- */
.topbar {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 50;
}
.topbar__inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { font-weight: 700; font-size: 18px; color: var(--c-text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.navlink {
    padding: 8px 12px; border-radius: 8px; color: var(--c-muted);
    font-weight: 500; font-size: 15px;
}
.navlink:hover { background: var(--c-bg); color: var(--c-text); text-decoration: none; }
.navlink.active { background: #eaf0ff; color: var(--c-primary); }
.navlink--admin { color: #b45309; }
.topbar--admin { border-bottom-color: #f59f00; box-shadow: 0 2px 0 #f59f00, var(--shadow); }
.usermenu { display: flex; align-items: center; gap: 12px; }
.usermenu__name { color: var(--c-muted); font-size: 14px; white-space: nowrap; }

/* --- Footer --- */
.footer { padding: 24px 0; color: var(--c-muted); text-align: center; }

/* --- Кнопки --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s;
    background: var(--c-surface); color: var(--c-text); line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--c-primary); color: #fff; }
.btn--primary:hover { background: var(--c-primary-dark); }
.btn--ghost { background: transparent; border-color: var(--c-border); color: var(--c-muted); }
.btn--ghost:hover { background: var(--c-bg); }
.btn--danger { background: var(--c-error); color: #fff; }
.btn--danger:hover { background: #a31515; }
.btn--sm { padding: 6px 10px; font-size: 13px; }
.btn--block { width: 100%; }

/* --- Формы --- */
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 160px; }
label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.input, select.input, textarea.input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--c-border);
    border-radius: 8px; font-size: 15px; background: #fff; color: var(--c-text);
}
.input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(59,91,219,.12); }
.input--error { border-color: var(--c-error); }
.field-error { color: var(--c-error); font-size: 13px; margin-top: 4px; }
.form-hint { color: var(--c-muted); font-size: 13px; margin-top: 4px; }

/* --- Алерты --- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert--success { background: var(--c-success-bg); color: var(--c-success); }
.alert--error { background: var(--c-error-bg); color: var(--c-error); }
.alert--info { background: var(--c-info-bg); color: var(--c-info); }

/* --- Карточки --- */
.card {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card__title { font-size: 16px; font-weight: 700; margin: 0 0 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 700; margin: 0; }

/* --- Таблицы --- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--c-border); font-size: 14px; }
.table th { color: var(--c-muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; }
.table tbody tr:hover { background: #fafbfe; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* --- Бейджи / суммы --- */
.amount-income { color: var(--c-income); font-weight: 600; }
.amount-expense { color: var(--c-expense); font-weight: 600; }
.amount-transfer { color: var(--c-transfer); font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge--income { background: var(--c-success-bg); color: var(--c-success); }
.badge--expense { background: var(--c-error-bg); color: var(--c-error); }
.badge--transfer { background: #eef0f4; color: var(--c-transfer); }
.badge--muted { background: #eef0f4; color: var(--c-muted); }
.cat-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* --- Сетки виджетов --- */
.grid { display: grid; gap: 20px; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .grid--3, .grid--2, .grid--4 { grid-template-columns: 1fr; } }

.stat { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat__label { color: var(--c-muted); font-size: 13px; margin-bottom: 6px; }
.stat__value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat__value--income { color: var(--c-income); }
.stat__value--expense { color: var(--c-expense); }

/* --- Auth --- */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { background: var(--c-surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 32px; width: 100%; max-width: 420px; }
.auth-card--center { text-align: center; }
.auth-card__brand { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 20px; }
.auth-card h1 { font-size: 20px; margin: 0 0 20px; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--c-muted); font-size: 14px; }

/* --- Баннеры --- */
.banner-slot { margin-bottom: 20px; }
.banner-slot img, .banner-slot svg { width: 100%; border-radius: var(--radius); display: block; box-shadow: var(--shadow); }
.banner-thumb { max-width: 160px; border-radius: 6px; border: 1px solid var(--c-border); }

/* --- Прочее --- */
.muted { color: var(--c-muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.empty { text-align: center; color: var(--c-muted); padding: 40px 20px; }

/* --- Error page --- */
.error-page { text-align: center; padding: 20px; }
.error-page__code { font-size: 64px; font-weight: 800; color: var(--c-primary); }
.error-page__title { margin: 8px 0; }
.error-page__msg { color: var(--c-muted); margin-bottom: 20px; }

/* --- Segmented control --- */
.seg { display: inline-flex; border: 1px solid var(--c-border); border-radius: 8px; overflow: hidden; background: #fff; }
.seg__item { position: relative; margin: 0; }
.seg__item input { position: absolute; opacity: 0; pointer-events: none; }
.seg__item span { display: block; padding: 8px 18px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--c-muted); }
.seg__item input:checked + span { background: var(--c-primary); color: #fff; }

/* --- Фильтры --- */
.filters { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.filters .form-group { margin-bottom: 0; }
.filters .input { min-width: 140px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; max-height: 120px; overflow-y: auto; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; font-size: 14px; margin: 0; }

/* --- Pagination --- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--c-border); font-size: 14px; background: #fff; }
.pagination .current { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.pagination a:hover { background: var(--c-bg); text-decoration: none; }
