* {
    box-sizing: border-box;
}

:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --line: #e5e7eb;
    --field-height: 48px;
    --field-radius: 12px;
    --field-font-size: 16px;
    --field-padding-x: 16px;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

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

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

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px;
}

.page.narrow {
    max-width: 560px;
}

.hero {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.hero h1 {
    margin: 0 0 8px;
    font-size: 26px;
}

.hero p {
    margin: 0;
    line-height: 1.6;
    opacity: .92;
}

.admin-link {
    background: rgba(255, 255, 255, .16);
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.export-link {
    background: #eff6ff;
    color: #1d4ed8;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
}

.panel {
    background: var(--panel);
    border-radius: 18px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 8px 30px rgba(15, 23, 42, .06);
}

.notice-banner {
    margin: 0 0 16px;
    padding: 16px 18px;
    border-radius: 16px;
    background: linear-gradient(135deg, #fef2f2, #fff1f2);
    border: 1px solid #fca5a5;
    color: #b91c1c;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.8;
    box-shadow: 0 10px 24px rgba(220, 38, 38, .12);
}

.notice-banner strong {
    color: #991b1b;
    font-size: 20px;
}

.notice-banner span {
    display: inline-block;
    padding: 1px 10px;
    margin: 0 2px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-weight: 700;
}

.search-form,
.invoice-form,
.admin-login-form,
.import-form {
    display: grid;
    gap: 12px;
}

label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

input[type="text"],
input[type="password"],
input[type="file"],
select,
button {
    width: 100%;
    min-height: var(--field-height);
    height: var(--field-height);
    border-radius: var(--field-radius);
    font-size: var(--field-font-size);
    box-sizing: border-box;
}

input[type="text"],
input[type="password"],
input[type="file"],
select {
    border: 1px solid #d1d5db;
    background: #fff;
    padding: 0 var(--field-padding-x);
    color: var(--text);
}

input[readonly] {
    background: #f8fafc;
    color: #374151;
}

input[type="file"] {
    padding: 7px 16px;
    line-height: 32px;
}

input[type="file"]::file-selector-button {
    height: 32px;
    margin-right: 12px;
    border: none;
    border-radius: 10px;
    padding: 0 14px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    cursor: pointer;
    vertical-align: middle;
}

input[type="file"]::-webkit-file-upload-button {
    height: 32px;
    margin-right: 12px;
    border: none;
    border-radius: 10px;
    padding: 0 14px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    cursor: pointer;
    vertical-align: middle;
}

button {
    border: none;
    background: var(--primary);
    color: #fff;
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
}

input:focus,
select:focus,
button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.hero-search-input {
    font-size: var(--field-font-size) !important;
    border-radius: 16px !important;
}

.search-form select.hero-search-input,
.search-form input.hero-search-input {
    height: var(--field-height) !important;
    min-height: var(--field-height) !important;
}

.search-form select.hero-search-input {
    padding-right: 52px !important;
    padding-left: var(--field-padding-x) !important;
}

.search-form input.hero-search-input {
    padding-left: var(--field-padding-x) !important;
    padding-right: var(--field-padding-x) !important;
}

.custom-select {
    position: relative;
}

.custom-select-native {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.custom-select-trigger {
    border: 1px solid #d1d5db;
    background: #fff;
    color: var(--text);
    padding: 0 52px 0 var(--field-padding-x) !important;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 400;
    box-shadow: none;
}

.custom-select-trigger:hover {
    border-color: #bfdbfe;
}

.custom-select-trigger-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-arrow {
    position: absolute;
    right: 18px;
    top: 50%;
    width: 10px;
    height: 10px;
    border-right: 2px solid #6b7280;
    border-bottom: 2px solid #6b7280;
    transform: translateY(-65%) rotate(45deg);
    transition: transform .2s ease;
    pointer-events: none;
}

.custom-select.is-open .custom-select-arrow {
    transform: translateY(-35%) rotate(-135deg);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #dbe3f0;
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .12);
    z-index: 20;
    overflow: hidden;
}

.custom-select-options {
    max-height: 280px;
    overflow-y: auto;
    padding: 8px;
    display: grid;
    gap: 8px;
}

.custom-select-option {
    width: 100%;
    min-height: 44px;
    height: auto;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    padding: 10px 14px;
    text-align: left;
    font-size: 15px;
    font-weight: 400;
}

.custom-select-option:hover,
.custom-select-option.is-selected {
    background: #eff6ff;
    color: #1d4ed8;
}

.stamp-preview-row {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.stamp-preview-card,
.front-stamp-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.stamp-preview-image {
    max-width: 160px;
    max-height: 160px;
    display: block;
}

.front-stamp-card {
    width: 112px;
    height: 112px;
    padding: 6px;
    border: 1px dashed rgba(220, 38, 38, .18);
    background: radial-gradient(circle at center, rgba(255, 255, 255, .96) 0%, rgba(255, 255, 255, .86) 100%);
}

.front-stamp-image {
    max-width: 100%;
    max-height: 100%;
    display: block;
    opacity: .88;
    filter: saturate(1.08) contrast(1.04);
}

.settlement-table-wrap {
    position: relative;
    overflow: hidden;
}

.settlement-stamp {
    position: absolute;
    right: 12px;
    top: 50%;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 3;
    opacity: .78;
    transform: translateY(-50%) rotate(-10deg);
}

.settlement-stamp .front-stamp-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.settlement-table-wrap .table-scroll.desktop-table {
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .settlement-stamp {
        position: absolute !important;
        right: 8px !important;
        top: 50% !important;
        bottom: auto !important;
        left: auto !important;
        width: 84px !important;
        height: 84px !important;
        opacity: .72;
        transform: translateY(-50%) rotate(-10deg) !important;
    }
}

.danger-button {
    background: #dc2626;
}

.danger-button:hover {
    background: #b91c1c;
}

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

.modal-backdrop[hidden] {
    display: none !important;
}

.modal-card {
    width: min(520px, 100%);
    background: #fff;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .22);
}

.modal-close-btn,
.open-password-modal-btn {
    width: auto;
    min-width: 72px;
    padding: 0 16px;
    border-radius: 12px;
}

.modal-field {
    display: grid;
    gap: 8px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #374151;
    font-weight: 600;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 18px;
    margin: 0;
}

.danger-note {
    margin-top: 5px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    line-height: 1.7;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.summary-card {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 14px;
    padding: 16px;
}

.summary-card span {
    display: block;
    font-size: 13px;
    color: var(--primary-dark);
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .summary-card {
        padding: 14px;
    }

    .summary-card span {
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .summary-card strong {
        font-size: 18px;
    }
}

.summary-card strong {
    font-size: 24px;
    color: #111827;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.section-title-row h2,
.section-title-row h3 {
    margin: 0;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.badge {
    background: #eef2ff;
    color: #4338ca;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.invoice-box {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px dashed #d1d5db;
}

.invoice-list {
    display: grid;
    gap: 10px;
}

.invoice-item {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.invoice-name {
    font-weight: 700;
    margin-bottom: 6px;
    word-break: break-all;
}

.filename-tooltip {
    position: relative;
    display: inline-block;
    cursor: default;
}

.filename-tooltip::after {
    content: attr(data-fullname);
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    transform: translateX(0);
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(37, 99, 235, .12);
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
    max-width: min(80vw, 720px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 30;
}

.filename-tooltip::before {
    content: "";
    position: absolute;
    left: 16px;
    bottom: calc(100% + 3px);
    transform: rotate(45deg);
    width: 10px;
    height: 10px;
    background: #eff6ff;
    border-right: 1px solid #bfdbfe;
    border-bottom: 1px solid #bfdbfe;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 29;
}

.filename-tooltip:hover::after,
.filename-tooltip:hover::before {
    opacity: 1;
    visibility: visible;
}

.right {
    text-align: right;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 14px;
    vertical-align: top;
    white-space: nowrap;
}

.data-table th {
    background: #f8fafc;
    color: #374151;
}

.flash {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-size: 14px;
}

.flash-success {
    background: #ecfdf5;
    color: #047857;
}

.flash-error {
    background: #fef2f2;
    color: #b91c1c;
}

.hint,
.empty-text {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 13px;
}

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

.anchor-section {
    scroll-margin-top: 18px;
}

.admin-login-form input[type="text"],
.admin-login-form input[type="password"],
.admin-login-form button {
    border-radius: 16px !important;
}

.admin-project-table {
    min-width: 1120px;
}

.admin-project-table th:nth-child(1),
.admin-project-table td:nth-child(1) {
    width: 90px;
}

.admin-project-table th:nth-child(2),
.admin-project-table td:nth-child(2) {
    width: 220px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-project-table th:last-child,
.admin-project-table td:last-child {
    width: 90px;
    min-width: 90px;
    text-align: center;
}


.import-form input[type="file"].hero-search-input,
.admin-search input.hero-search-input {
    border-radius: 16px !important;
}

.admin-search input.hero-search-input {
    height: 48px !important;
    min-height: 48px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
}

.import-form input[type="file"].hero-search-input {
    height: 48px !important;
    min-height: 48px !important;
    padding: 0 16px !important;
    line-height: 48px !important;
}

.import-form input[type="file"].hero-search-input::file-selector-button {
    height: 32px;
    margin-right: 12px;
    border: none;
    border-radius: 10px;
    padding: 0 14px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    cursor: pointer;
    vertical-align: middle;
}

.import-form input[type="file"].hero-search-input::-webkit-file-upload-button {
    height: 32px;
    margin-right: 12px;
    border: none;
    border-radius: 10px;
    padding: 0 14px;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 700;
    cursor: pointer;
    vertical-align: middle;
}

.inline-form {
    display: inline;
}

.inline-form button {
    width: auto;
    min-width: 72px;
    padding: 0 12px;
}

.tab-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tab-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    height: 42px;
    padding: 0 18px;
    border-radius: 12px;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 700;
}

.tab-link.active {
    background: #2563eb;
    color: #fff;
}

.admin-account-table th:nth-child(6),
.admin-account-table td:nth-child(6) {
    min-width: 220px;
}

.inline-reset-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.inline-reset-form input[type="password"] {
    width: 120px;
    min-width: 120px;
}
