/* === Apple-style Reset & Base === */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --border: #e5e5e7;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #aeaeb2;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-light: #e8f2fd;
    --red: #ff3b30;
    --green: #34c759;
    --orange: #ff9500;
    --purple: #af52de;
    --teal: #5ac8fa;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
        "SF Pro Text", "Helvetica Neue", "PingFang SC", "Microsoft YaHei",
        sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Nav === */
.nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(245, 245, 247, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
    height: 48px;
    display: flex;
    align-items: center;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    opacity: 0.9;
}

/* === Page layout === */
.page {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

/* === Hero === */
.hero {
    text-align: center;
    padding: 60px 0 48px;
}

.hero-title {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 10px;
}

.hero-desc {
    font-size: 19px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* === Section === */
.section {
    margin-bottom: 28px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

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

.section-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

.section-title strong {
    font-weight: 700;
}

/* === Upload Zone === */
.upload-zone {
    border: 2px dashed #d2d2d7;
    border-radius: var(--radius-lg);
    padding: 56px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.upload-zone:hover {
    border-color: var(--accent);
    background: #fafbff;
    box-shadow: var(--shadow);
}

.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: var(--shadow-lg);
}

.upload-icon {
    color: var(--accent);
    margin-bottom: 16px;
    opacity: 0.8;
}

.upload-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.upload-hint {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* === Toast === */
.toast {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: var(--red);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* === Status Bar === */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.spinner-sm {
    width: 18px;
    height: 18px;
    border: 2px solid #e5e5e7;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* === Category Strip === */
.category-strip {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: #f5f5f7;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    font-family: inherit;
}

.cat-badge:hover {
    background: #e8e8ed;
}

.cat-badge.active {
    background: var(--text);
    color: #fff;
}

.cat-badge .cat-count {
    font-weight: 600;
}

.cat-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.cat-dot.dining {
    background: var(--orange);
}
.cat-dot.travel {
    background: var(--accent);
}
.cat-dot.transport {
    background: var(--teal);
}
.cat-dot.venue {
    background: var(--purple);
}
.cat-dot.office {
    background: var(--green);
}
.cat-dot.telecom {
    background: var(--red);
}
.cat-dot.print {
    background: #ff6b35;
}
.cat-dot.software {
    background: #0071e3;
}
.cat-dot.hotel {
    background: #ff9500;
}
.cat-dot.fuel {
    background: #ff3b30;
}
.cat-dot.prop {
    background: #af52de;
}
.cat-dot.purchase {
    background: #34c759;
}
.cat-dot.image {
    background: #5ac8fa;
}
.cat-dot.other {
    background: var(--text-tertiary);
}

/* === Category Merge Panel === */
.category-merge-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.cat-merge-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.cat-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.cat-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid var(--border);
    background: #fafafa;
    color: var(--text-secondary);
    user-select: none;
}

.cat-checkbox:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.cat-checkbox input[type="checkbox"] {
    display: none;
}

.cat-checkbox.checked {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.cat-check-name {
    white-space: nowrap;
}

.cat-check-count {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 400;
}

.cat-toggle-all {
    margin-left: 4px;
    font-size: 12px;
}

.cat-merge-summary {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.cat-merge-summary .em {
    font-weight: 600;
    color: var(--accent);
}

.cat-merge-summary .merge-hint {
    color: var(--text-tertiary);
}

.cat-merge-summary .merge-hint .em {
    color: var(--text);
    font-weight: 600;
}

/* === File Grid === */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}

.file-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: grab;
    transition: all var(--transition);
    position: relative;
}

.file-card:hover {
    box-shadow: var(--shadow);
    border-color: #d2d2d7;
}

.file-card:active {
    cursor: grabbing;
}

.file-card.dragging {
    opacity: 0.4;
    box-shadow: var(--shadow-lg);
}

.file-card .card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #f2f2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.file-card .card-body {
    flex: 1;
    min-width: 0;
}

.file-card .card-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.file-card .card-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    display: flex;
    gap: 8px;
}

.file-card .card-category {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 10px;
    background: #f5f5f7;
    color: var(--text-secondary);
}

.file-card .card-remove {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: #f5f5f7;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition);
}

.file-card:hover .card-remove {
    opacity: 1;
}

.file-card .card-remove:hover {
    background: var(--red);
    color: #fff;
}

/* === Operations === */
.ops {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.op-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.op-card:hover {
    border-color: #b0b0b8;
    box-shadow: var(--shadow);
}

.op-card:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.08);
}

.op-card input {
    display: none;
}

.op-icon {
    color: var(--accent);
    margin-bottom: 4px;
}

.op-card strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.op-card span {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* === Range Row === */
.range-row {
    margin-bottom: 16px;
}

.range-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-tertiary);
}

/* === Buttons === */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    font-family: inherit;
    letter-spacing: -0.01em;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 22px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 10px;
    border: 1px solid #d2d2d7;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
}

.btn-outline:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-ghost {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--accent);
    cursor: pointer;
    font-family: inherit;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition);
}

.btn-ghost:hover {
    background: var(--accent-light);
}

.btn-block {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
    border-radius: 12px;
}

/* === Input === */
.input {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid #d2d2d7;
    border-radius: 10px;
    font-family: inherit;
    background: var(--surface);
    transition: all var(--transition);
    color: var(--text);
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
}

.input::placeholder {
    color: var(--text-tertiary);
}

/* === Result === */
.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.result-file {
    font-size: 15px;
    color: var(--text);
    margin-bottom: 16px;
    word-break: break-all;
}

.result-file .output-name {
    font-weight: 600;
    color: var(--accent);
}

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

/* === Preview Panel === */
.preview-panel {
    margin-top: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 500;
}

.preview-frame {
    width: 100%;
    height: 620px;
    border: none;
    display: block;
}

/* === Footer === */
.foot {
    text-align: center;
    padding: 24px;
    color: var(--text-tertiary);
    font-size: 12px;
}

/* === Responsive === */
@media (max-width: 700px) {
    .hero {
        padding: 40px 0 32px;
    }

    .hero-title {
        font-size: 32px;
    }

    .hero-desc {
        font-size: 16px;
        padding: 0 8px;
    }

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

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

    .upload-zone {
        padding: 36px 16px;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn-primary,
    .result-actions .btn-outline {
        width: 100%;
    }

    .preview-frame {
        height: 380px;
    }
}

@media (max-width: 400px) {
    .hero-title {
        font-size: 26px;
    }

    .page {
        padding: 0 12px 60px;
    }
}
