:root {
    --ink: #172126;
    --muted: #63727a;
    --line: #dbe3e6;
    --paper: #ffffff;
    --wash: #f4f7f8;
    --mist: #eaf2f2;
    --teal: #0f766e;
    --teal-strong: #0b5f59;
    --blue: #2563eb;
    --amber: #b7791f;
    --red: #d64545;
    --green: #27834f;
    --shadow: 0 18px 44px rgba(23, 33, 38, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--wash);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a {
    color: inherit;
}

.shell {
    min-height: 100vh;
}

.topbar {
    background: #17313b;
    color: #fff;
    padding: 18px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #d6f4ef;
    color: #17313b;
    font-weight: 800;
}

.brand-title {
    margin: 0;
    font-size: 19px;
    letter-spacing: 0;
}

.brand-subtitle {
    margin: 3px 0 0;
    color: #b8c8cd;
    font-size: 13px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav a,
.nav span {
    color: #e7f0f2;
    text-decoration: none;
    font-size: 14px;
    padding: 8px 10px;
    border-radius: 8px;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.12);
}

.page {
    width: min(1320px, calc(100% - 40px));
    margin: 26px auto 44px;
}

.grid {
    display: grid;
    grid-template-columns: minmax(360px, 0.85fr) minmax(520px, 1.4fr);
    gap: 22px;
    align-items: start;
}

.submit-only-grid {
    grid-template-columns: minmax(360px, 760px);
    justify-content: center;
}

.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel-header {
    padding: 20px 22px 14px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.panel-title {
    margin: 0;
    font-size: 18px;
}

.panel-kicker {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.panel-body {
    padding: 22px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.metric {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 23px;
}

.positive {
    color: var(--green);
}

.negative {
    color: var(--red);
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 20px;
    padding: 4px;
    background: var(--mist);
    border-radius: 8px;
}

.tab {
    border: 0;
    border-radius: 7px;
    padding: 11px 10px;
    background: transparent;
    color: var(--muted);
    font-weight: 700;
    cursor: pointer;
}

.tab.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 2px 10px rgba(23, 33, 38, 0.08);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.field {
    margin-bottom: 16px;
}

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

label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    background: #fbfcfc;
    color: var(--ink);
    border-radius: 8px;
    padding: 12px 13px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

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

input:focus,
textarea:focus,
select:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.13);
    background: #fff;
}

.drop-zone {
    border: 1px dashed #9db2b8;
    background: #f8fbfb;
    min-height: 126px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    text-align: center;
    cursor: pointer;
    padding: 20px;
}

.drop-zone:hover,
.drop-zone.dragging {
    border-color: var(--teal);
    background: #eef8f6;
}

.drop-title {
    margin: 0;
    font-weight: 800;
}

.drop-help {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.file-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.file-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    min-width: 0;
}

.file-item span:first-child {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.btn {
    border: 0;
    border-radius: 8px;
    padding: 11px 14px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--teal);
    color: #fff;
}

.btn-primary:hover {
    background: var(--teal-strong);
}

.btn-secondary {
    background: #e9eff1;
    color: var(--ink);
}

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

.btn-danger:hover {
    background: #fbd3d3;
}

.btn-ghost {
    background: transparent;
    color: var(--teal);
    border: 1px solid var(--line);
}

.flash {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
    background: #edf7ee;
    color: var(--green);
    border: 1px solid #cae9d0;
}

.flash.error {
    background: #fff0f0;
    color: var(--red);
    border-color: #f4cccc;
}

.flash.info {
    background: #edf4ff;
    color: var(--blue);
    border-color: #d6e5ff;
}

.month-strip {
    display: flex;
    gap: 12px;
    margin-bottom: 22px;
    overflow-x: auto;
    padding: 4px 2px 12px;
    scrollbar-color: #9db2b8 transparent;
}

.month-card {
    flex: 0 0 190px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 13px;
    text-decoration: none;
    display: block;
}

.month-card.active {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.month-card strong {
    display: block;
    margin-bottom: 8px;
}

.month-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.panel-filters {
    border-bottom: 1px solid var(--line);
}

.filter-form {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.filter-form .field {
    margin-bottom: 0;
    min-width: 160px;
}

.filter-form .keyword-field {
    flex: 1 1 220px;
}

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

.category-chip,
.tag-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.category-chip {
    padding: 7px 10px;
    color: var(--muted);
    border: 1px solid var(--line);
    background: #fbfcfc;
}

.category-chip.active {
    color: var(--teal);
    border-color: var(--teal);
    background: #edf8f6;
}

.tag-pill {
    padding: 5px 9px;
    color: #31535b;
    background: #eaf2f2;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1080px;
}

th {
    color: var(--muted);
    text-align: left;
    font-size: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

td {
    padding: 14px;
    border-bottom: 1px solid #edf1f2;
    vertical-align: top;
    font-size: 14px;
}

.cell-main {
    font-weight: 800;
}

.cell-sub {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 9px;
    font-weight: 800;
    font-size: 12px;
}

.pill-income {
    background: #e8f6ee;
    color: var(--green);
}

.pill-expense {
    background: #fff3dc;
    color: var(--amber);
}

.pill-pending {
    background: #edf4ff;
    color: var(--blue);
}

.pill-rejected {
    background: #fff0f0;
    color: var(--red);
}

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

.attachment {
    display: inline-flex;
    max-width: 190px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--teal);
    text-decoration: none;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.toolbar .field {
    margin-bottom: 0;
    min-width: 170px;
}

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

.empty {
    padding: 42px 20px;
    text-align: center;
    color: var(--muted);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #17313b;
}

.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.22);
    position: relative;
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 24px;
}

.login-card p {
    margin: 0 0 22px;
    color: var(--muted);
}

.close-card {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    text-decoration: none;
    color: var(--muted);
    background: #eef3f4;
    font-size: 24px;
    line-height: 1;
}

.close-card:hover {
    color: var(--ink);
    background: #dde8ea;
}

.danger-panel {
    border-color: #f0caca;
}

@media (max-width: 980px) {
    .grid,
    .metrics {
        grid-template-columns: 1fr;
    }

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

    .nav {
        justify-content: flex-start;
    }
}

@media (max-width: 620px) {
    .page {
        width: min(100% - 24px, 1320px);
        margin-top: 16px;
    }

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

    .panel-header {
        flex-direction: column;
    }
}
