:root {
    --bg: #f4f1ea;
    --surface: #fffdf8;
    --surface-alt: #f1ebdf;
    --line: #ded2be;
    --text: #2f2419;
    --muted: #7c6a59;
    --brand: #1f8f6a;
    --brand-soft: #d9f4ea;
    --danger: #cb5b3e;
    --danger-soft: #f9e1da;
    --success: #177245;
    --success-soft: #dbf2e1;
    --shadow: 0 18px 40px rgba(72, 49, 24, 0.08);
    --radius: 24px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(244, 202, 141, 0.28), transparent 28%),
        linear-gradient(180deg, #f7f2ea 0%, #f0ece3 100%);
    color: var(--text);
}

.auth-body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    padding: 28px;
    border-right: 1px solid rgba(122, 98, 71, 0.14);
    background: rgba(255, 253, 248, 0.7);
    backdrop-filter: blur(14px);
}

.brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 28px;
}

.brand strong {
    display: block;
    font-size: 1.1rem;
}

.brand small {
    color: var(--muted);
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #1f8f6a, #76b89b);
    color: white;
    font-weight: 700;
}

.menu {
    display: grid;
    gap: 8px;
}

.menu a {
    padding: 14px 16px;
    border-radius: 16px;
    color: var(--muted);
}

.menu a.is-active,
.menu a:hover {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.client-box,
.panel,
.metric-card {
    background: var(--surface);
    border: 1px solid rgba(136, 113, 83, 0.12);
    box-shadow: var(--shadow);
}

.client-box {
    margin-top: 28px;
    padding: 18px;
    border-radius: 20px;
}

.client-box span,
.client-box small,
.panel p,
.topbar p,
.metric-card span,
small {
    color: var(--muted);
}

.main {
    padding: 26px;
}

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

.topbar__actions {
    display: grid;
    gap: 10px;
    justify-items: end;
    flex-shrink: 0;
}

.topbar__buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.user-chip {
    padding: 12px 16px;
    background: rgba(255, 253, 248, 0.8);
    border: 1px solid rgba(136, 113, 83, 0.12);
    border-radius: 18px;
    text-align: right;
}

.user-chip strong,
.user-chip small {
    display: block;
}

.topbar h1,
.panel h2 {
    margin: 0;
}

.panel,
.metric-card {
    border-radius: var(--radius);
}

.panel {
    padding: 22px;
}

.panel__header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
    margin-bottom: 18px;
}

.card-grid,
.chart-grid,
.split-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

.card-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.chart-grid,
.split-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
    padding: 22px;
}

.metric-card strong {
    font-size: 1.55rem;
    display: block;
    margin-top: 12px;
}

.metric-card--danger {
    background: linear-gradient(180deg, var(--surface) 0%, var(--danger-soft) 100%);
}

.metric-card--success {
    background: linear-gradient(180deg, var(--surface) 0%, var(--success-soft) 100%);
}

.primary-button,
.ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 12px 18px;
    border: 0;
    cursor: pointer;
}

.primary-button {
    background: var(--brand);
    color: white;
}

.ghost-button {
    background: var(--surface-alt);
    color: var(--text);
}

.danger-text {
    color: var(--danger);
}

.filter-grid,
.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 8px;
    font-size: 0.95rem;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px 14px;
    background: #fffefb;
}

.table-wrapper {
    overflow: auto;
}

.table-wrapper--transactions {
    border: 1px solid rgba(136, 113, 83, 0.12);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 254, 251, 0.96) 0%, rgba(250, 245, 236, 0.92) 100%);
}

.transactions-page {
    display: grid;
    gap: 16px;
}

.transactions-page .panel {
    padding: 16px 18px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(255, 253, 248, 0.96) 0%, rgba(252, 247, 239, 0.92) 100%);
    border: 1px solid rgba(136, 113, 83, 0.12);
    box-shadow: 0 14px 34px rgba(136, 113, 83, 0.08);
}

.transactions-page .panel__header {
    margin-bottom: 12px;
    align-items: flex-start;
    gap: 12px;
}

.transactions-page h2 {
    margin: 0;
    font-size: 1.28rem;
}

.transactions-page p {
    margin: 6px 0 0;
    font-size: 0.92rem;
    color: var(--muted);
}

.transactions-page label {
    gap: 6px;
    font-size: 0.86rem;
    color: var(--text);
}

.transactions-page input,
.transactions-page select,
.transactions-page textarea {
    padding: 10px 12px;
    font-size: 0.9rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.95);
}

.transactions-page input[type="file"] {
    padding: 8px 10px;
}

.table-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(239, 232, 217, 0.95);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 14px 10px;
    border-bottom: 1px solid rgba(136, 113, 83, 0.12);
    vertical-align: top;
}

.transactions-table {
    min-width: 1020px;
}

.transactions-table thead th {
    padding: 16px 16px;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: rgba(255, 250, 241, 0.9);
}

.transactions-table tbody td {
    padding: 16px;
}

.transactions-page .filter-grid,
.transactions-page .form-grid {
    gap: 12px 14px;
}

.transactions-page .filter-grid--transactions,
.transactions-page .form-grid--import {
    align-items: end;
}

.transactions-page .filter-grid--transactions .primary-button {
    width: fit-content;
    min-width: 180px;
}

.transactions-page .form-grid--import .primary-button {
    width: fit-content;
    min-width: 168px;
}

.transactions-page .panel--import .panel__header,
.transactions-page .panel--listing .panel__header {
    justify-content: space-between;
}

.transactions-page .panel--listing .panel__header > div,
.transactions-page .panel--editor .panel__header > div,
.transactions-page .panel--filters .panel__header > div {
    max-width: 720px;
}

.transactions-page .panel--import .ghost-button {
    white-space: nowrap;
}

.transactions-row:hover {
    background: rgba(255, 248, 235, 0.75);
}

.transaction-main {
    min-width: 280px;
    max-width: 360px;
}

.transaction-title {
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.25;
}

.transaction-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.84rem;
}

.transaction-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.transaction-meta span:not(:last-child)::after {
    content: "";
    width: 4px;
    height: 4px;
    border-radius: 999px;
    background: rgba(124, 106, 89, 0.55);
}

.type-badge,
.table-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.type-badge--income {
    background: var(--success-soft);
    color: var(--success);
}

.type-badge--expense {
    background: var(--danger-soft);
    color: var(--danger);
}

.table-chip {
    background: rgba(239, 232, 217, 0.9);
    color: var(--text);
}

.transaction-date {
    white-space: nowrap;
    font-weight: 600;
}

.transaction-value {
    white-space: nowrap;
    font-size: 1rem;
    font-weight: 800;
}

.transaction-value--income {
    color: var(--success);
}

.transaction-value--expense {
    color: var(--danger);
}

.transaction-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    min-width: 250px;
}

.transaction-actions form,
.transaction-actions button {
    width: auto;
}

.transaction-actions .ghost-button {
    width: auto;
    min-height: 32px;
    padding: 6px 10px;
    justify-content: center;
    font-size: 0.76rem;
    border-radius: 14px;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
}

.pagination__status {
    color: var(--muted);
    font-weight: 700;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--surface-alt);
    font-size: 0.86rem;
}

.pill--paid,
.pill--success {
    background: var(--success-soft);
    color: var(--success);
}

.pill--pending {
    background: #efe8d9;
}

.pill--overdue,
.pill--danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.list {
    display: grid;
    gap: 12px;
}

.list--spaced {
    gap: 14px;
}

.list__item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    background: #fffaf1;
    border: 1px solid rgba(136, 113, 83, 0.12);
    border-radius: 18px;
}

.empty-state {
    padding: 16px;
    border-radius: 18px;
    background: #fffaf1;
}

.quick-launch[hidden] {
    display: none;
}

.quick-launch {
    position: fixed;
    inset: 0;
    z-index: 20;
}

.quick-launch__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(42, 29, 18, 0.45);
}

.quick-launch__panel {
    position: relative;
    width: min(920px, calc(100% - 24px));
    margin: 28px auto;
    padding: 22px;
    background: var(--surface);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.quick-launch__header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
    margin-bottom: 18px;
}

.alert {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.alert--danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.alert--success {
    background: var(--success-soft);
    color: var(--success);
}

.import-panel {
    margin-top: 18px;
}

.import-steps {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    padding: 11px 13px;
    background: #fffaf1;
    border: 1px solid rgba(136, 113, 83, 0.12);
    border-radius: 18px;
}

.import-steps p {
    margin: 0;
    font-size: 0.84rem;
}

.transactions-page .primary-button,
.transactions-page .ghost-button {
    padding: 8px 12px;
    font-size: 0.84rem;
    min-height: 40px;
}

.transactions-page form[action="/transactions/import/upload"] .primary-button,
.transactions-page form[action="/transactions/import/preview"] .primary-button,
.transactions-page form[action="/transactions/import/commit"] .primary-button {
    padding: 7px 11px;
    font-size: 0.8rem;
    min-height: 38px;
}

.pill--warning {
    background: #fff0c9;
    color: #9a6a00;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(480px, 100%);
    background: rgba(255, 253, 248, 0.94);
    border: 1px solid rgba(136, 113, 83, 0.12);
    box-shadow: var(--shadow);
    border-radius: 30px;
    padding: 28px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.auth-brand strong,
.auth-brand small {
    display: block;
}

.auth-copy h1 {
    margin: 0 0 8px;
}

.auth-copy {
    margin-bottom: 20px;
}

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

.auth-form .primary-button {
    width: 100%;
}

canvas {
    width: 100%;
    background: linear-gradient(180deg, #fffefb 0%, #f7f1e7 100%);
    border-radius: 18px;
}

@media (max-width: 1080px) {
    .shell,
    .card-grid,
    .chart-grid,
    .split-grid,
    .filter-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .topbar {
        align-items: start;
    }

    .topbar__actions,
    .topbar__buttons {
        width: 100%;
        justify-items: stretch;
    }

    .topbar__buttons {
        flex-direction: column;
    }

    .topbar__buttons .primary-button,
    .topbar__buttons .ghost-button {
        width: 100%;
    }

    .user-chip {
        width: 100%;
        text-align: left;
    }

    .transactions-table {
        min-width: 920px;
    }
}

@media (max-width: 1440px) {
    .transactions-page .panel {
        padding: 14px;
    }

    .transactions-table {
        min-width: 940px;
    }

    .transaction-main {
        min-width: 240px;
        max-width: 300px;
    }

    .transaction-title {
        font-size: 0.94rem;
    }

    .transaction-meta {
        font-size: 0.8rem;
    }

    .transaction-actions {
        min-width: 156px;
    }

    .transaction-actions .ghost-button {
        padding: 5px 9px;
        font-size: 0.72rem;
    }

    .transactions-page .filter-grid--transactions .primary-button,
    .transactions-page .form-grid--import .primary-button {
        min-width: 154px;
    }
}
