:root {
    --ink: #17202a;
    --muted: #6b7280;
    --line: #e5e7eb;
    --surface: #ffffff;
    --page: #f5f7fb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --warning: #b45309;
    --success: #15803d;
}

* {
    box-sizing: border-box;
}

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

a {
    color: var(--primary);
    text-decoration: none;
}

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

button {
    cursor: pointer;
}

.page-shell {
    min-height: 100vh;
}

.topbar {
    height: 64px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-size: 18px;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
}

.user-name {
    color: var(--ink);
    font-weight: 600;
}

.main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px;
}

.page-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.page-heading h1 {
    margin: 0 0 6px;
    font-size: 24px;
}

.page-heading p {
    margin: 0;
    color: var(--muted);
}

.panel {
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.filter-panel {
    margin-bottom: 18px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr)) auto auto;
    gap: 12px;
    align-items: end;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 18px 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

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

.form-field label {
    color: #374151;
    font-weight: 600;
}

.form-field label span {
    color: var(--danger);
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
}

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

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

.button-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.button {
    min-height: 40px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-weight: 600;
}

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

.button.primary:hover {
    background: var(--primary-dark);
}

.button.secondary {
    color: #374151;
    background: #fff;
    border-color: #d1d5db;
}

.button.danger {
    color: #fff;
    background: var(--danger);
}

.button.warning {
    color: #fff;
    background: var(--warning);
}

.button.success {
    color: #fff;
    background: var(--success);
}

.button.small {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
}

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

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

th,
td {
    padding: 13px 12px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    color: #4b5563;
    background: #f9fafb;
    font-size: 13px;
    font-weight: 700;
}

td.material-cell {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status {
    display: inline-flex;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status.pending_settlement {
    color: #92400e;
    background: #fef3c7;
}

.status.pending_review {
    color: #1d4ed8;
    background: #dbeafe;
}

.status.approved {
    color: #166534;
    background: #dcfce7;
}

.status.rejected {
    color: #991b1b;
    background: #fee2e2;
}

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

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    color: var(--muted);
}

.notice {
    margin-bottom: 16px;
    padding: 11px 13px;
    border-radius: 6px;
    color: #1e40af;
    background: #eff6ff;
}

.notice.error {
    color: #991b1b;
    background: #fef2f2;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 18px 28px;
}

.detail-item {
    min-width: 0;
}

.detail-item.full {
    grid-column: 1 / -1;
}

.detail-label {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
}

.detail-value {
    overflow-wrap: anywhere;
    line-height: 1.6;
}

.proof-list {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.proof-item {
    width: 180px;
}

.proof-item img {
    display: block;
    width: 180px;
    height: 120px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f9fafb;
}

.proof-item p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.file-help {
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
}

.upload-preview,
.existing-proof {
    margin-top: 10px;
}

.upload-preview img,
.existing-proof img {
    display: block;
    width: 180px;
    height: 120px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f9fafb;
}

.existing-proof a {
    display: inline-block;
}

.login-page {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #eef3fb;
}

.login-card {
    width: min(420px, 100%);
    padding: 32px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

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

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

.login-card .form-field {
    margin-bottom: 16px;
}

.login-card .button {
    width: 100%;
    margin-top: 6px;
}

.loading {
    color: var(--muted);
}

@media (max-width: 900px) {
    .filter-grid,
    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }

    .filter-grid .button-row {
        grid-column: 1 / -1;
    }
}

@media (max-width: 620px) {
    .topbar {
        height: auto;
        min-height: 64px;
        padding: 14px 18px;
        align-items: flex-start;
        gap: 12px;
        flex-direction: column;
    }

    .topbar-right {
        width: 100%;
        justify-content: space-between;
    }

    .main {
        padding: 18px;
    }

    .page-heading {
        display: block;
    }

    .page-heading .button {
        margin-top: 14px;
    }

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

    .form-field.full,
    .detail-item.full {
        grid-column: auto;
    }

    .panel {
        padding: 16px;
    }
}
