:root {
    --primary: #16a34a;
    --primary-dark: #166534;
    --secondary: #2563eb;
    --warning: #f59e0b;
    --danger: #dc2626;
    --danger-soft: #be5f6d;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: linear-gradient(180deg, #f8fafc 0%, #eef4ff 100%);
    color: var(--text);
    font-family: Tahoma, Arial, sans-serif;
}

body { min-height: 100vh; }

a { color: inherit; }

.container {
    width: min(100%, 980px);
    margin: 0 auto;
    padding: 14px 12px 28px;
}

.card, .glass {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
}

.page-title {
    margin: 0 0 6px;
    font-size: 1.18rem;
}

.page-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.flash {
    padding: 12px 14px;
    border-radius: 14px;
    margin-bottom: 12px;
    font-size: 0.94rem;
    border: 1px solid transparent;
}

.flash-success {
    background: #ecfdf5;
    color: #166534;
    border-color: #bbf7d0;
}

.flash-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.btn, button, .btn-link {
    border: none;
    border-radius: 14px;
    padding: 11px 14px;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease, background .18s ease;
}

.btn:hover, button:hover, .btn-link:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #22c55e);
    color: white;
    box-shadow: 0 10px 24px rgba(34, 197, 94, 0.22);
}

.btn-secondary {
    background: #eff6ff;
    color: #1d4ed8;
}

.btn-neutral {
    background: #f1f5f9;
    color: #334155;
}

.btn-danger {
    background: #fef2f2;
    color: var(--danger);
}

.btn-warning {
    background: #fff7ed;
    color: #c2410c;
}

.btn-success-soft {
    background: #ecfdf5;
    color: #166534;
}

.btn-block { width: 100%; display: block; text-align: center; }

.icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(255,255,255,0.9);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
}

.icon-btn-danger {
    color: var(--danger);
}

.icon-btn-secondary {
    color: #1d4ed8;
}

.dashboard-container {
    display: grid;
    gap: 12px;
}

.sticky-shell {
    position: sticky;
    top: 8px;
    z-index: 20;
    display: grid;
    gap: 8px;
}

.top-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 55%, #16a34a 100%);
    color: #fff;
}

.top-card::after {
    content: "";
    position: absolute;
    width: 145px;
    height: 145px;
    border-radius: 50%;
    background: rgba(255,255,255,0.09);
    top: -58px;
    left: -28px;
}

.top-card-compact {
    padding: 14px 14px 12px 56px;
    min-height: 128px;
}

.top-actions {
    position: absolute;
    top: 12px;
    left: 10px;
    display: flex;
    z-index: 2;
}

.top-actions-vertical {
    flex-direction: column;
    gap: 8px;
}

.welcome-meta {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 14px;
    align-items: stretch;
    justify-content: space-between;
}

.compact-welcome-meta {
    min-height: 102px;
}

.welcome-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.welcome-label {
    opacity: .86;
    margin-bottom: 4px;
    font-size: .86rem;
}

.welcome-title {
    color: #fff;
    margin-bottom: 5px;
    font-size: 1.12rem;
}

.welcome-subline {
    opacity: .85;
    font-size: .88rem;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.total-balance {
    min-width: 218px;
    text-align: left;
}

.compact-balance-box {
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(255,255,255,0.13);
    border: 1px solid rgba(255,255,255,0.15);
}

.total-balance small {
    display: block;
    opacity: .92;
}

.total-balance strong {
    display: block;
    font-size: 1.38rem;
    margin-top: 4px;
}

.summary-line {
    opacity: .92;
    margin-top: 5px;
    font-size: .84rem;
}

.balance-positive { color: #16a34a; }
.balance-negative-soft { color: var(--danger-soft); }
.top-card .balance-positive,
.top-card .balance-negative-soft { color: #fff; }
.top-card .compact-balance-box.balance-positive strong { color: #d7ffe6; }
.top-card .compact-balance-box.balance-negative-soft strong { color: #ffd6d8; }

.btn-sticky-add {
    width: 100%;
    border-radius: 16px;
    padding: 11px 16px;
    font-weight: 700;
}

.accounts-shell {
    padding: 14px;
}

.accounts-shell-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.accounts-shell-title {
    margin: 0 0 4px;
    font-size: 1rem;
}

.accounts-shell-badge {
    min-width: 76px;
    text-align: center;
    padding: 9px 12px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    font-size: .88rem;
}

.account-grid {
    display: grid;
    gap: 10px;
}

.compact-account-grid {
    max-height: calc(100vh - 240px);
    overflow: auto;
    padding-inline-end: 2px;
}

.account-card {
    padding: 12px;
}

.compact-account-card {
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.account-head {
    display: flex;
    gap: 14px;
    justify-content: space-between;
    align-items: flex-start;
}

.compact-account-head {
    align-items: stretch;
}

.account-main-col {
    flex: 1;
    min-width: 0;
}

.account-title-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 5px;
}

.account-title {
    margin: 0;
    font-size: 1rem;
}

.account-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.78rem;
}

.inline-holder {
    margin-top: 2px;
}

.account-balance {
    text-align: left;
    min-width: 170px;
    padding: 8px 10px;
    border-radius: 14px;
    background: #f8fafc;
}

.compact-balance .value {
    font-weight: 700;
    font-size: 1.08rem;
}

.muted {
    color: var(--muted);
    font-size: 0.88rem;
}

.account-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.compact-meta {
    margin-top: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid var(--border);
    color: #334155;
    font-size: 0.78rem;
}

.slide-toggle {
    width: 100%;
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.fancy-slide-toggle {
    background: linear-gradient(180deg, #fbfdff 0%, #f1f5f9 100%);
    color: #0f172a;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.slide-toggle-main {
    font-weight: 700;
    font-size: .88rem;
}

.slide-arrow {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--border);
}

.fancy-slide-toggle.open .slide-arrow {
    background: #ecfdf5;
    color: #166534;
}

.slide-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height .32s ease;
}

.slide-panel.open {
    max-height: 360px;
}

.ops-row {
    display: grid;
    gap: 8px;
    padding-top: 12px;
}

.compact-ops-row {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

.ops-row .btn {
    text-align: center;
    padding: 10px 12px;
    font-size: .88rem;
}

.section-card {
    padding: 18px;
    margin-bottom: 12px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
}

.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { color: #334155; font-size: 0.9rem; }

input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 11px 13px;
    font: inherit;
    background: #fff;
    color: var(--text);
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea { min-height: 100px; resize: vertical; }

.field-hint {
    color: var(--muted);
    font-size: 0.8rem;
}

.op-hint-box {
    margin-top: 14px;
    border: 1px dashed #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    border-radius: 14px;
    padding: 10px 12px;
    font-size: .86rem;
    display: none;
}

.op-hint-box:not(:empty) {
    display: block;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 1000;
}

.modal.show { display: flex; }

.modal-card {
    width: min(100%, 560px);
    max-height: calc(100vh - 36px);
    overflow: auto;
    padding: 20px;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-title {
    margin: 0;
    font-size: 1.05rem;
}

.modal-copy {
    margin-top: 10px;
}

.confirm-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 14px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fef2f2;
    color: var(--danger);
    font-size: 1.65rem;
}

.confirm-icon-soft {
    background: #eff6ff;
    color: #2563eb;
}

.archive-account-name {
    margin: 14px auto 0;
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: #f8fafc;
    border: 1px solid var(--border);
    font-weight: 700;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.end-toolbar { justify-content: flex-end; }
.center-toolbar { justify-content: center; }

.text-center { text-align: center; }
.text-left { text-align: left; }

.table-like {
    display: grid;
    gap: 10px;
}

.log-item {
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    gap: 14px;
}

.log-item.positive { border-inline-start: 5px solid #16a34a; }
.log-item.negative { border-inline-start: 5px solid #dc2626; }
.log-item.neutral { border-inline-start: 5px solid #2563eb; }
.log-title { font-weight: 700; margin-bottom: 6px; }
.log-amount { white-space: nowrap; font-weight: 700; }

.profit-strip {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profit-chip {
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    background: #f8fafc;
    border: 1px solid var(--border);
}

.empty-state {
    padding: 26px 18px;
    text-align: center;
    color: var(--muted);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    margin-bottom: 12px;
    color: #1d4ed8;
}

.danger-box {
    margin-top: 18px;
    padding: 16px;
    border-radius: 16px;
    background: #fff7f7;
    border: 1px solid #fecaca;
}

.danger-box h3 {
    margin: 0 0 8px;
    font-size: 1rem;
    color: #991b1b;
}

@media (max-width: 760px) {
    .accounts-shell-head,
    .welcome-meta,
    .account-head {
        flex-direction: column;
    }

    .top-card-compact {
        padding: 14px 14px 12px 56px;
    }

    .total-balance,
    .account-balance {
        text-align: right;
        min-width: 100%;
    }

    .compact-account-grid {
        max-height: none;
        overflow: visible;
    }

    .modal-card { padding: 18px 16px; }
}
