:root {
    color-scheme: light;
    --bg: #f6f8fc;
    --bg-soft: #fbfcff;
    --panel: rgba(255, 255, 255, .94);
    --panel-solid: #ffffff;
    --panel-alt: #f7f9fe;
    --text: #172033;
    --text-soft: #59657a;
    --muted: #8791a5;
    --border: #dbe2ef;
    --border-soft: #e9eef6;
    --primary: #3867f4;
    --primary-2: #7357ef;
    --primary-strong: #2455e6;
    --primary-soft: #eef3ff;
    --success: #16845b;
    --success-bg: #eaf8f2;
    --warning: #a56508;
    --warning-bg: #fff7df;
    --danger: #d33f5a;
    --danger-bg: #fff0f3;
    --shadow: 0 12px 36px rgba(47, 67, 112, .08);
    --shadow-soft: 0 6px 20px rgba(47, 67, 112, .06);
    --radius: 18px;
    --radius-sm: 11px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 15% 0%, rgba(82, 125, 255, .10), transparent 30%),
        radial-gradient(circle at 90% 8%, rgba(121, 88, 239, .09), transparent 28%),
        var(--bg);
    color: var(--text);
}

body {
    min-height: 100vh;
    margin: 0;
    background: transparent;
}

button,
input,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(56, 103, 244, .18);
    outline-offset: 2px;
}

.shell {
    width: min(1840px, calc(100% - 32px));
    margin: 0 auto;
}

.app-header {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(213, 222, 238, .9);
    background:
        linear-gradient(120deg, rgba(255,255,255,.97), rgba(244,248,255,.95) 54%, rgba(249,245,255,.96));
    box-shadow: 0 4px 18px rgba(44, 63, 104, .04);
}

.app-header::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 12% 20%, rgba(61, 111, 249, .13), transparent 22%),
        radial-gradient(circle at 88% 0%, rgba(119, 80, 232, .12), transparent 24%);
}

.header-inner {
    position: relative;
    z-index: 1;
    min-height: 112px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.finance-header {
    padding: 18px 0;
}

.eyebrow,
.section-kicker {
    color: var(--primary);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.brand-title {
    margin-top: 7px;
    font-size: 30px;
    font-weight: 850;
    letter-spacing: -.035em;
}

.brand-subtitle {
    margin-top: 4px;
    color: var(--text-soft);
    font-size: 13px;
}

.finance-main {
    padding: 22px 0 46px;
}

.flash {
    margin-bottom: 16px;
    padding: 13px 15px;
    border: 1px solid;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    font-size: 13px;
    font-weight: 700;
}

.flash-success {
    border-color: #bde5d5;
    background: var(--success-bg);
    color: var(--success);
}

.flash-error {
    border-color: #f3c5ce;
    background: var(--danger-bg);
    color: var(--danger);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.stat-card {
    position: relative;
    min-height: 118px;
    overflow: hidden;
    padding: 17px 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background:
        linear-gradient(145deg, rgba(255,255,255,.98), rgba(248,250,255,.98));
    box-shadow: var(--shadow-soft);
}

.stat-card::after {
    content: "";
    position: absolute;
    width: 92px;
    height: 92px;
    right: -36px;
    top: -38px;
    border-radius: 999px;
    background: rgba(68, 111, 247, .07);
}

.stat-card.stat-salary::after {
    background: rgba(20, 151, 112, .08);
}

.stat-card.stat-primary {
    border-color: #cbd7ff;
    background:
        linear-gradient(145deg, #f8faff, #eef3ff 64%, #f5f0ff);
}

.stat-card.stat-primary::after {
    background: rgba(113, 84, 239, .10);
}

.stat-label {
    position: relative;
    z-index: 1;
    color: var(--text-soft);
    font-size: 11px;
    font-weight: 700;
}

.stat-value {
    position: relative;
    z-index: 1;
    margin-top: 8px;
    color: var(--text);
    font-size: clamp(22px, 1.65vw, 28px);
    font-weight: 880;
    letter-spacing: -.035em;
}

.stat-note {
    position: relative;
    z-index: 1;
    margin-top: 8px;
    color: var(--muted);
    font-size: 10px;
}

.text-action {
    position: absolute;
    z-index: 2;
    right: 14px;
    bottom: 13px;
    border: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
}

.finance-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.panel {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.panel-heading {
    min-height: 86px;
    padding: 17px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--border-soft);
    background:
        linear-gradient(120deg, rgba(255,255,255,.98), rgba(249,251,255,.98));
}

.panel-heading h2 {
    margin: 4px 0 0;
    color: var(--text);
    font-size: 18px;
    font-weight: 850;
    letter-spacing: -.025em;
}

.section-description {
    max-width: 580px;
    margin: 5px 0 0;
    color: var(--text-soft);
    font-size: 11px;
    line-height: 1.4;
}

.panel-heading-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.total-pill {
    min-height: 38px;
    padding: 0 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d5def0;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    box-shadow: 0 3px 12px rgba(47, 67, 112, .04);
    font-size: 12px;
    font-weight: 850;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.mini-action,
.close-button {
    cursor: pointer;
}

.primary-button,
.secondary-button,
.ghost-button {
    min-height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
}

.primary-button {
    border: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
    box-shadow: 0 7px 18px rgba(61, 91, 230, .18);
}

.primary-button:hover {
    filter: brightness(1.035);
}

.secondary-button {
    border: 1px solid #cdd8ec;
    background: #f2f6ff;
    color: #365287;
}

.ghost-button {
    border: 1px solid #d4ddeb;
    background: rgba(255,255,255,.88);
    color: var(--text-soft);
}

.ghost-button.compact {
    min-height: 36px;
}

.table-toolbar {
    padding: 11px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-soft);
    background: #fbfcff;
}

.search-box {
    width: min(100%, 510px);
    min-height: 36px;
    padding: 0 11px;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid #d6dfed;
    border-radius: 9px;
    background: #fff;
    color: var(--muted);
}

.search-box:focus-within {
    border-color: #9ab4ff;
    box-shadow: 0 0 0 3px rgba(56, 103, 244, .08);
}

.search-box input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 11px;
}

.search-box input::placeholder {
    color: #9aa4b6;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text);
    font-size: 11px;
}

.fixed-table {
    min-width: 830px;
}

.data-table th,
.data-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    background: #f7f9fd;
    color: #69758a;
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .055em;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table th a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.data-table tbody tr {
    background: rgba(255,255,255,.72);
    transition: background .14s ease;
}

.data-table tbody tr:hover {
    background: #f8faff;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.strong-cell {
    font-weight: 720;
}

.amount-cell {
    text-align: right !important;
    white-space: nowrap;
    font-weight: 720;
}

.date-cell {
    white-space: nowrap;
    color: var(--text-soft);
}

.actions-cell {
    text-align: right !important;
    white-space: nowrap;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    border: 1px solid;
    font-size: 9px;
    font-weight: 850;
    white-space: nowrap;
}

.status-paid {
    border-color: #b8e7d4;
    background: var(--success-bg);
    color: var(--success);
}

.status-pending {
    border-color: #f0dca2;
    background: var(--warning-bg);
    color: var(--warning);
}

.icon-button {
    padding: 5px 6px;
    border: 0;
    background: transparent;
    color: var(--primary);
    font-size: 10px;
    font-weight: 800;
}

.icon-button:hover {
    text-decoration: underline;
}

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

.inline-form {
    display: inline;
    margin: 0;
}

.empty-table {
    padding: 30px !important;
    text-align: center !important;
    color: var(--muted);
}

.pagination-row {
    min-height: 58px;
    padding: 11px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--border-soft);
    background: #fbfcff;
}

.pagination-info,
.pagination {
    color: var(--muted);
    font-size: 10px;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 7px;
}

.pagination a,
.pagination .disabled,
.page-current {
    padding: 7px 8px;
    border: 1px solid #dbe3ef;
    border-radius: 8px;
    background: #fff;
}

.pagination a {
    color: var(--text-soft);
}

.pagination .disabled {
    opacity: .48;
}

.board-panel {
    overflow: hidden;
}

.board-help {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    background: #fbfcff;
    color: var(--muted);
    font-size: 10px;
}

.kanban-board {
    min-width: 720px;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    overflow-x: auto;
    background:
        linear-gradient(180deg, #fafbff, #f6f8fc);
}

.kanban-column {
    min-width: 0;
    min-height: 430px;
    overflow: hidden;
    border: 1px solid #d9e1ee;
    border-radius: 13px;
    background: rgba(255,255,255,.9);
    box-shadow: 0 4px 16px rgba(49, 69, 111, .04);
    transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.kanban-column.drag-over {
    border-color: #7ea0ff;
    background: #f4f7ff;
    transform: translateY(-1px);
}

.kanban-column-header {
    min-height: 65px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
    border-bottom: 1px solid var(--border-soft);
    background: linear-gradient(180deg, #fff, #fbfcff);
}

.kanban-column-header h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 830;
}

.kanban-column-header strong {
    font-size: 12px;
    white-space: nowrap;
}

.column-count {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 9px;
}

.kanban-list {
    min-height: 360px;
    padding: 8px;
}

.kanban-empty {
    margin: 3px;
    padding: 22px 10px;
    border: 1px dashed #ccd6e6;
    border-radius: 10px;
    background: #fbfcff;
    color: #9aa5b7;
    text-align: center;
    font-size: 9px;
    line-height: 1.45;
}

.transaction-card {
    margin-bottom: 8px;
    padding: 10px;
    border: 1px solid #dbe3ef;
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(47, 67, 112, .05);
    cursor: grab;
    user-select: none;
    transition: transform .15s ease, opacity .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.transaction-card:hover {
    border-color: #b8c9ee;
    box-shadow: 0 7px 18px rgba(47, 67, 112, .08);
}

.transaction-card.dragging {
    opacity: .5;
    transform: rotate(1deg) scale(.985);
}

.transaction-card-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: flex-start;
}

.transaction-title {
    min-width: 0;
    color: var(--text);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.transaction-amount {
    white-space: nowrap;
    color: #263653;
    font-size: 11px;
    font-weight: 880;
}

.transaction-meta {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 9px;
}

.source-badge {
    max-width: 95px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 3px 5px;
    border: 1px solid #d8e2f4;
    border-radius: 999px;
    background: var(--primary-soft);
    color: #5170ac;
    font-size: 7px;
    font-weight: 850;
    letter-spacing: .04em;
}

.transaction-controls {
    margin-top: 9px;
    padding-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    border-top: 1px solid var(--border-soft);
}

.assignment-select-wrap {
    min-width: 0;
    flex: 1;
}

.assignment-select {
    width: 100%;
    min-height: 30px;
    padding: 0 7px;
    border: 1px solid #d5deec;
    border-radius: 8px;
    background: #fbfcff;
    color: var(--text);
    font-size: 9px;
    outline: none;
}

.mini-action {
    padding: 4px 3px;
    border: 0;
    background: transparent;
    color: var(--primary);
    font-size: 8px;
    font-weight: 820;
}

.modal {
    width: min(610px, calc(100% - 24px));
    max-height: calc(100vh - 30px);
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 18px;
    background: transparent;
}

.modal::backdrop {
    background: rgba(29, 40, 64, .40);
    backdrop-filter: blur(4px);
}

.modal-card {
    overflow: hidden;
    border: 1px solid #d9e1ee;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 28px 70px rgba(27, 42, 73, .22);
}

.modal-header {
    min-height: 82px;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-soft);
    background: linear-gradient(120deg, #fff, #f6f9ff 60%, #faf7ff);
}

.modal-header h2 {
    margin: 4px 0 0;
    font-size: 18px;
    font-weight: 850;
}

.close-button {
    width: 34px;
    height: 34px;
    border: 1px solid #dbe3ef;
    border-radius: 9px;
    background: #fff;
    color: #6e798c;
    font-size: 19px;
}

.form-grid {
    padding: 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-grid.one-column {
    grid-template-columns: 1fr;
}

.form-grid label {
    min-width: 0;
    display: grid;
    gap: 7px;
}

.form-grid label > span {
    color: #5d687b;
    font-size: 10px;
    font-weight: 780;
}

.form-grid input,
.form-grid select {
    width: 100%;
    min-height: 42px;
    padding: 0 11px;
    border: 1px solid #d5deec;
    border-radius: 10px;
    outline: 0;
    background: #fbfcff;
    color: var(--text);
    font-size: 12px;
}

.form-grid input:focus,
.form-grid select:focus {
    border-color: #91adff;
    box-shadow: 0 0 0 3px rgba(56,103,244,.08);
}

.form-grid input:disabled {
    background: #f0f2f6;
    color: #9aa3b2;
    cursor: not-allowed;
}

.span-2 {
    grid-column: span 2;
}

.form-hint {
    margin: -4px 18px 0;
    padding: 10px 12px;
    border-radius: 10px;
    background: #f6f8fc;
    color: var(--muted);
    font-size: 9px;
    line-height: 1.45;
}

.modal-actions {
    padding: 14px 18px 18px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.home-main {
    padding: 34px 0 48px;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 420px));
    gap: 16px;
}

.module-tile {
    min-height: 112px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: linear-gradient(145deg, #fff, #f8faff);
    box-shadow: var(--shadow);
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.module-tile:hover {
    transform: translateY(-2px);
    border-color: #b9c8eb;
    box-shadow: 0 14px 34px rgba(47, 67, 112, .11);
}

.module-icon {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: #fff;
    box-shadow: 0 8px 18px rgba(68, 91, 224, .22);
    font-size: 22px;
    font-weight: 900;
}

.module-copy {
    min-width: 0;
    flex: 1;
}

.module-copy h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 850;
}

.module-copy p {
    margin: 5px 0 0;
    color: var(--text-soft);
    font-size: 11px;
    line-height: 1.45;
}

.module-arrow {
    color: var(--primary);
    font-size: 22px;
    font-weight: 800;
}

@media (max-width: 1360px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .finance-columns {
        grid-template-columns: 1fr;
    }

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

    .kanban-board {
        min-width: 0;
    }
}

@media (max-width: 920px) {
    .shell {
        width: min(100% - 20px, 1840px);
    }

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

    .kanban-board {
        min-width: 690px;
    }

    .panel-heading {
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .header-inner {
        min-height: 96px;
    }

    .brand-title {
        font-size: 25px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        min-height: 104px;
    }

    .panel-heading {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-heading-actions {
        justify-content: space-between;
    }

    .table-toolbar {
        flex-wrap: wrap;
    }

    .search-box {
        width: 100%;
    }

    .pagination-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }
}
