/* =========================================
   Budget Calculator — Design System
   Светлая минималистичная тема, Inter font
   ========================================= */

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

/* ===== CSS Variables ===== */
:root {
    /* Primary */
    --primary:        #4F46E5;
    --primary-hover:  #4338CA;
    --primary-light:  #EEF2FF;
    --primary-dim:    rgba(79, 70, 229, 0.12);
    --primary-shadow: rgba(79, 70, 229, 0.25);

    /* Backgrounds */
    --bg:             #F5F7FA;
    --bg-alt:         #ECEEF3;
    --surface:        #FFFFFF;
    --surface-hover:  #FAFBFF;

    /* Borders */
    --border:         #E5E8EF;
    --border-focus:   #4F46E5;
    --border-hover:   #C8CBD6;

    /* Text */
    --text-primary:   #111827;
    --text-secondary: #6B7280;
    --text-tertiary:  #9CA3AF;

    /* Status */
    --success:        #10B981;
    --success-light:  #ECFDF5;
    --success-border: rgba(16, 185, 129, 0.25);
    --warning:        #F59E0B;
    --warning-light:  #FFFBEB;
    --warning-border: rgba(245, 158, 11, 0.3);
    --danger:         #EF4444;
    --danger-light:   #FEF2F2;
    --danger-border:  rgba(239, 68, 68, 0.25);

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.09), 0 4px 10px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.12), 0 8px 20px rgba(0,0,0,0.07);

    /* Radius */
    --r-xs:   4px;
    --r-sm:   8px;
    --r-md:   12px;
    --r-lg:   16px;
    --r-xl:   20px;
    --r-2xl:  28px;
    --r-full: 9999px;

    /* Transitions */
    --t-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ===== Screen States ===== */
#login-screen, #main-screen { display: none; }

/* ===== LOGIN SCREEN ===== */
#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at 75% 20%, rgba(79,70,229,0.08) 0%, transparent 55%),
        radial-gradient(ellipse at 20% 80%, rgba(16,185,129,0.06) 0%, transparent 50%),
        linear-gradient(160deg, #F8F9FF 0%, #F0F4FE 50%, #F5FBF8 100%);
    position: relative;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--r-2xl);
    padding: 44px 40px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    animation: slideUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 28px;
}

.brand-logo-img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: var(--r-md);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.brand-logo-img.sm {
    width: 48px;
    height: 48px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.login-brand-name {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.04em;
}

.login-brand-sub {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.login-heading {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: -0.04em;
    margin-bottom: 6px;
}

.login-desc {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
}

/* ===== FORM ===== */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 7px;
    letter-spacing: -0.01em;
}

.input-icon-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-secondary);
    pointer-events: none;
    transition: color var(--t-fast);
}

.btn-icon-left {
    margin-right: 6px;
    flex-shrink: 0;
    vertical-align: middle;
}

.form-input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--r-md);
    font-family: inherit;
    font-size: 15px;
    color: var(--text-primary);
    transition: all var(--t-base);
    outline: none;
    appearance: none;
}

.form-input.has-icon {
    padding-left: 44px;
}

.form-input.has-icon:focus ~ .input-icon {
    color: var(--primary);
}

.form-input:hover { border-color: var(--border-hover); }

.form-input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--primary-dim);
}

.form-input::placeholder { color: var(--text-tertiary); }

.form-error {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--danger);
    background: var(--danger-light);
    border: 1px solid var(--danger-border);
    border-radius: var(--r-sm);
    padding: 10px 14px;
    margin-top: 14px;
    font-weight: 500;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 46px;
    padding: 0 22px;
    border: none;
    border-radius: var(--r-md);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--t-base);
    white-space: nowrap;
    text-decoration: none;
    letter-spacing: -0.01em;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px var(--primary-shadow);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(79,70,229,0.35);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 8px var(--primary-shadow);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg);
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:active:not(:disabled) { transform: translateY(0); }

.btn-danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1.5px solid var(--danger-border);
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0 12px;
    height: 36px;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg);
    color: var(--text-primary);
}

.btn-full  { width: 100%; }
.btn-sm    { height: 36px; padding: 0 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn-icon  { width: 36px; height: 36px; padding: 0; border-radius: var(--r-sm); }

/* ===== MAIN SCREEN ===== */
#main-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: var(--shadow-sm);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    text-decoration: none;
}

.header-brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #6366F1);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    box-shadow: 0 4px 10px var(--primary-shadow);
}

.header-brand-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.header-clock {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.header-time {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.header-tz {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-username {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0 4px;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    padding: 36px 28px;
    max-width: 1120px;
    margin: 0 auto;
    width: 100%;
}

/* Amount Section */
.amount-section {
    background: var(--surface);
    border-radius: var(--r-xl);
    padding: 48px 40px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.amount-section::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(79,70,229,0.05) 0%, transparent 70%);
    pointer-events: none;
}

.amount-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 20px;
}

.amount-input-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    max-width: 420px;
    width: 100%;
    margin-bottom: 24px;
}

#amount-input {
    width: 100%;
    height: 68px;
    padding: 0 80px 0 20px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--r-lg);
    font-family: inherit;
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    transition: all var(--t-base);
    outline: none;
    text-align: right;
}

#amount-input:hover { border-color: var(--border-hover); }

#amount-input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px var(--primary-dim);
}

.amount-currency-badge {
    position: absolute;
    right: 16px;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-secondary);
    pointer-events: none;
    background: var(--bg-alt);
    padding: 4px 10px;
    border-radius: var(--r-sm);
    letter-spacing: 0.02em;
}

.amount-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Categories */
.section-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    margin-bottom: 18px;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

/* Category Card */
.cat-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 20px;
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: all var(--t-base);
    position: relative;
    overflow: hidden;
}

.cat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--c-accent, var(--primary));
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    transition: height var(--t-base);
}

.cat-card:hover {
    border-color: var(--c-accent, var(--primary));
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.cat-card:hover::after { height: 4px; }

.cat-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.cat-card-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.cat-badge {
    font-size: 12px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: var(--r-full);
    background: var(--c-bg, var(--primary-light));
    color: var(--c-text, var(--primary));
    letter-spacing: -0.01em;
}

.cat-amount {
    font-size: 28px;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -0.04em;
    line-height: 1;
    transition: color var(--t-base);
}

.cat-amount.has-value { color: var(--c-accent, var(--primary)); }

.cat-currency {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-tertiary);
    margin-top: 3px;
}

.cat-progress {
    margin-top: 16px;
    height: 4px;
    background: var(--c-bg, var(--primary-light));
    border-radius: var(--r-full);
    overflow: hidden;
}

.cat-progress-fill {
    height: 100%;
    background: var(--c-accent, var(--primary));
    border-radius: var(--r-full);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--surface);
    border-radius: var(--r-2xl);
    padding: 36px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border);
}

.modal-lg { max-width: 700px; }

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

.modal-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.04em;
}

.modal-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg);
    border-radius: var(--r-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 18px;
    transition: all var(--t-fast);
    flex-shrink: 0;
    margin-left: 16px;
    margin-top: -4px;
}

.modal-close:hover {
    background: var(--danger-light);
    color: var(--danger);
    transform: scale(1.1);
}

.modal-footer {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* ===== RESULTS MODAL ===== */
.results-banner {
    background: linear-gradient(135deg, var(--primary) 0%, #6366F1 60%, #8B5CF6 100%);
    border-radius: var(--r-lg);
    padding: 20px 24px;
    color: white;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-banner-label {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.75;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.results-banner-amount {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: -0.05em;
    line-height: 1;
}

.results-banner-curr {
    font-size: 16px;
    font-weight: 700;
    opacity: 0.8;
    align-self: flex-end;
    padding-bottom: 4px;
}

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

.result-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    animation: slideRight 0.35s ease both;
    transition: background var(--t-fast);
}

.result-row:hover { background: var(--surface); }

.result-dot {
    width: 10px;
    height: 38px;
    border-radius: var(--r-full);
    flex-shrink: 0;
}

.result-info { flex: 1; min-width: 0; }

.result-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-pct {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.result-right { text-align: right; }

.result-amount {
    font-size: 20px;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.result-curr {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===== HISTORY MODAL ===== */
.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
    border: 1.5px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.history-item:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.history-row {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 16px;
    cursor: pointer;
    background: var(--surface);
    transition: background var(--t-fast);
    user-select: none;
}

.history-row:hover { background: var(--surface-hover); }

.history-meta { flex: 1; min-width: 0; }

.history-date {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.history-note {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-total {
    font-size: 18px;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    white-space: nowrap;
}

.history-total-curr {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-tertiary);
}

.history-chevron {
    font-size: 14px;
    color: var(--text-tertiary);
    transition: transform var(--t-fast);
    margin-left: 4px;
}

.history-chevron.open { transform: rotate(180deg); }

.history-details {
    display: none;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.history-details.open { display: block; }

.history-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

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

.history-detail-name { color: var(--text-secondary); font-weight: 500; }

.history-detail-pct {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-left: 6px;
}

.history-detail-amount {
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.history-pagination {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.pag-info { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

/* ===== SETTINGS MODAL ===== */
.settings-tabs {
    display: flex;
    border-bottom: 1.5px solid var(--border);
    margin-bottom: 28px;
    gap: 2px;
}

.settings-tab {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2.5px solid transparent;
    margin-bottom: -1.5px;
    transition: all var(--t-fast);
    border-radius: var(--r-sm) var(--r-sm) 0 0;
    letter-spacing: -0.01em;
}

.settings-tab:hover {
    color: var(--text-primary);
    background: var(--bg);
}

.settings-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--primary-light);
}

.settings-panel { display: none; }
.settings-panel.active { display: block; }

/* Percentage indicator */
.pct-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg);
    border-radius: var(--r-md);
    border: 1.5px solid var(--border);
    margin-bottom: 16px;
}

.pct-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); flex-shrink: 0; }

.pct-bar-bg {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: var(--r-full);
    overflow: hidden;
}

.pct-bar-fill {
    height: 100%;
    border-radius: var(--r-full);
    background: var(--success);
    transition: all var(--t-base);
}

.pct-bar-fill.warn  { background: var(--warning); }
.pct-bar-fill.error { background: var(--danger); }

.pct-value { font-size: 14px; font-weight: 800; min-width: 52px; text-align: right; }
.pct-value.ok    { color: var(--success); }
.pct-value.warn  { color: var(--warning); }
.pct-value.error { color: var(--danger); }

.pct-warning {
    display: none;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 14px;
    border-radius: var(--r-md);
    margin-bottom: 16px;
}

.pct-warning.show { display: block; }
.pct-warning.warn  { background: var(--warning-light); color: #92400E; border: 1px solid var(--warning-border); }
.pct-warning.error { background: var(--danger-light);  color: #991B1B; border: 1px solid var(--danger-border); }

/* Category settings list */
.cat-settings-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 16px;
    padding-right: 4px;
}

.cat-settings-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: var(--r-md);
    border: 1.5px solid var(--border);
    transition: border-color var(--t-fast);
}

.cat-settings-row:hover { border-color: var(--border-hover); }

.cat-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cat-name-inp {
    flex: 1;
    height: 34px;
    padding: 0 10px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--t-fast);
}

.cat-name-inp:focus { border-color: var(--primary); }

.cat-pct-inp {
    width: 66px;
    height: 34px;
    padding: 0 8px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
    outline: none;
    text-align: right;
    transition: border-color var(--t-fast);
    -moz-appearance: textfield;
}

.cat-pct-inp:focus { border-color: var(--primary); }
.cat-pct-lbl { font-size: 13px; font-weight: 700; color: var(--text-secondary); }

/* Add category form */
.add-cat-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.add-cat-form .form-input {
    height: 38px;
    font-size: 13px;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 16px;
    line-height: 1.5;
}

.alert-success {
    background: var(--success-light);
    color: #065F46;
    border: 1px solid var(--success-border);
}

.alert-error {
    background: var(--danger-light);
    color: #991B1B;
    border: 1px solid var(--danger-border);
}

/* ===== SPINNER ===== */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

.spinner-dark {
    border-color: rgba(79,70,229,0.2);
    border-top-color: var(--primary);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 24px;
}

.empty-icon { font-size: 48px; margin-bottom: 14px; opacity: 0.4; }

.empty-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-tertiary);
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    padding: 12px 24px;
    border-radius: var(--r-full);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    letter-spacing: -0.01em;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-success { background: #111827; color: #D1FAE5; }
.toast-error   { background: #7F1D1D; color: #FEE2E2; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes slideRight { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity: 0.6; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-header { padding: 0 14px; height: 64px; }
    .header-brand-name { display: none; }
    .header-time { font-size: 13px; }
    .header-username { display: none; }
    .header-actions { gap: 6px; }

    .main-content { padding: 16px 12px; }

    .amount-section { padding: 24px 18px; margin-bottom: 20px; }
    #amount-input { font-size: 24px; height: 56px; }

    .categories-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .cat-card { padding: 14px; }
    .cat-amount { font-size: 20px; }

    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal {
        border-radius: var(--r-xl) var(--r-xl) 0 0;
        max-height: 92vh;
        width: 100%;
        max-width: 100%;
        padding: 24px 16px;
    }

    .modal-footer { flex-direction: column; gap: 8px; }
    .modal-footer .btn { width: 100%; }
    .amount-actions { flex-direction: column; align-items: stretch; gap: 8px; }
    .amount-actions .btn { width: 100%; }

    .results-banner-amount { font-size: 24px; }

    .add-cat-form { gap: 6px; }
    .add-cat-form input { flex: 1 1 100% !important; margin-bottom: 4px; }
    .add-cat-form button { width: 100%; }
}

@media (max-width: 580px) {
    .header-actions .btn-text { display: none; }
    .header-actions .btn-sm {
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
        border-radius: var(--r-sm);
    }
    .header-actions .btn-sm svg {
        margin-right: 0;
        width: 16px;
        height: 16px;
    }
}

@media (max-width: 480px) {
    .header-clock { display: none; }
    
    /* Горизонтальные карточки категорий для компактности */
    .categories-grid { grid-template-columns: 1fr; gap: 8px; }
    .cat-card {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        gap: 12px;
    }
    .cat-card::after {
        width: 3px;
        height: 100%;
        border-radius: var(--r-lg) 0 0 var(--r-lg);
    }
    .cat-card-top { margin-bottom: 0; flex-shrink: 0; }
    .cat-card-name { font-size: 13px; font-weight: 700; }
    .cat-badge { font-size: 11px; padding: 2px 8px; }
    .cat-amount { font-size: 17px; text-align: right; }
    .cat-currency { display: none; }
    .cat-progress { display: none; }

    .settings-tab { padding: 8px 12px; font-size: 13px; }
    .settings-tab svg { width: 13px; height: 13px; }

    /* Исправление наложения шрифтов в истории на мобильных */
    .history-row {
        flex-wrap: wrap;
        gap: 8px;
        position: relative;
        padding-right: 54px; /* Оставляем место для кнопки удаления */
    }
    .history-meta {
        flex: 1 1 100%;
        margin-bottom: 2px;
    }
    .history-total-wrap {
        flex: 1;
        display: flex;
        align-items: baseline;
        gap: 4px;
    }
    .history-chevron {
        align-self: center;
        margin-left: auto;
    }
    .history-row .btn-danger {
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
    }

    /* Перенос элементов в строках настроек категорий на мобильных */
    .cat-settings-row {
        flex-wrap: wrap;
        padding: 10px;
        position: relative;
    }
    .cat-settings-row .cat-dot {
        position: absolute;
        left: 12px;
        top: 19px;
    }
    .cat-settings-row .cat-name-inp {
        flex: 1 1 calc(100% - 30px);
        margin-bottom: 8px;
        padding-left: 20px;
    }
    .cat-settings-row .cat-pct-inp {
        flex: 1;
        max-width: 100px;
    }
    .cat-settings-row .btn-danger {
        position: absolute;
        right: 10px;
        bottom: 8px;
        height: 34px;
        width: 34px;
    }
}

