:root {
    --primary: #2b1a14;
    --primary-hover: #422a21;
    --text: #111827;
    --muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --success: #047857;
    --success-bg: #ecfdf5;
    --success-border: #a7f3d0;
    --warning: #b45309;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --danger: #b42318;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --focus: rgba(43, 26, 20, 0.14);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--surface);
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--surface);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
}

a {
    color: var(--primary);
}

button,
input,
select,
textarea {
    letter-spacing: 0;
}

.site-nav {
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.98);
}

.nav-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    width: min(1120px, 100%);
    min-height: 68px;
    margin: 0 auto;
    padding: 10px 20px;
    gap: 20px;
}

.site-name {
    justify-self: start;
    color: var(--text);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
}

.nav-link {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 6px 13px;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text);
    background: #ffffff;
}

.nav-link.active {
    color: #ffffff;
    background: var(--primary);
}

.nav-utility {
    display: flex;
    justify-self: end;
    align-items: center;
}

.nav-inner.nav-centered {
    display: flex;
    justify-content: center;
}

.shell,
.shell-narrow,
.login-shell {
    width: 100%;
    margin: 0 auto;
    padding: 54px 20px 32px;
}

.shell {
    max-width: 1120px;
}

.shell-match {
    max-width: 820px;
}

.shell-narrow {
    max-width: 680px;
}

.login-shell {
    max-width: 440px;
    padding-top: 10vh;
}

.page-header {
    max-width: 720px;
    margin: 0 auto 34px;
    text-align: center;
}

.page-title {
    margin: 0;
    color: var(--text);
    font-size: 30px;
    font-weight: 750;
    line-height: 1.25;
    letter-spacing: 0;
}

.page-subtitle {
    margin: 9px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.card {
    margin-bottom: 18px;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.login-card {
    padding: 24px;
}

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

.upload-form {
    max-width: 760px;
    margin-right: auto;
    margin-left: auto;
    align-items: end;
}

.shell-narrow .grid {
    grid-template-columns: minmax(0, 1fr);
}

.col-1 { grid-column: span 1; }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-8 { grid-column: span 8; }
.col-10 { grid-column: span 10; }
.col-12 { grid-column: span 12; }

label {
    display: block;
    margin: 0 0 6px;
    color: #475569;
    font-size: 12px;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    outline: none;
    padding: 9px 11px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

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

input:hover,
select:hover,
textarea:hover {
    border-color: #94a3b8;
}

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

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.btn {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 9px 14px;
    background: var(--primary);
    color: #ffffff;
    font: inherit;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.btn:focus-visible,
.nav-link:focus-visible,
.site-name:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.btn.secondary {
    border-color: var(--border-strong);
    background: #ffffff;
    color: #334155;
}

.btn.secondary:hover {
    border-color: #94a3b8;
    background: var(--surface-soft);
}

.btn.danger {
    border-color: var(--danger-border);
    background: #ffffff;
    color: var(--danger);
}

.btn.small {
    min-height: 34px;
    padding: 6px 11px;
    font-size: 13px;
}

.full-button {
    width: 100%;
}

.alert {
    margin-bottom: 16px;
    padding: 11px 13px;
    border: 1px solid;
    border-radius: 6px;
}

.alert.ok {
    border-color: var(--success-border);
    background: var(--success-bg);
    color: var(--success);
}

.alert.err {
    border-color: var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger);
}

.section-title {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.section-title h2 {
    margin: 0;
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
}

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

.hint-spaced {
    margin-top: 8px;
}

.pill {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    max-width: 100%;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-soft);
    color: #475569;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.pill.ok {
    border-color: var(--success-border);
    background: var(--success-bg);
    color: var(--success);
}

.pill.warn {
    border-color: var(--warning-border);
    background: var(--warning-bg);
    color: var(--warning);
}

.pill.err {
    border-color: var(--danger-border);
    background: var(--danger-bg);
    color: var(--danger);
}

.order {
    margin-top: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.order-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-soft);
}

.order-head strong {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 9px;
}

.items {
    display: grid;
}

.item {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.item:first-child {
    border-top: 0;
}

.item-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 20px;
}

.kv {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 7px 12px;
    font-size: 13px;
}

.kv span:nth-child(odd) {
    color: var(--muted);
}

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

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
}

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

.empty-bordered {
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    background: var(--surface-soft);
}

.empty-title {
    display: block;
    margin-bottom: 6px;
    color: #334155;
}

.actions,
.actions-start {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.actions {
    justify-content: flex-end;
}

.actions-start {
    justify-content: flex-start;
    margin-bottom: 12px;
}

.align-end {
    align-self: end;
}

.section-divider {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.stack-gap {
    margin-top: 18px;
}

.filter-actions {
    display: flex;
    align-items: end;
    gap: 8px;
}

.table-wrap,
.preview-panel {
    overflow: auto;
    max-width: 100%;
}

.table-wrap {
    max-height: 560px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.preview-panel {
    margin-top: 14px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table-wrap table {
    min-width: 780px;
}

th {
    background: var(--surface-soft);
    color: #475569;
    font-weight: 650;
}

.table-wrap th {
    position: sticky;
    top: 0;
    z-index: 1;
}

th,
td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

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

.job-status {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 14px;
    padding: 13px;
    border: 1px solid #d6c7bf;
    border-radius: 6px;
    background: #faf7f5;
    color: var(--primary);
}

.spinner {
    width: 18px;
    height: 18px;
    flex: none;
    border: 2px solid #d6c7bf;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.results {
    display: grid;
    gap: 10px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.result {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-soft);
}

.footer {
    margin: 22px 0 4px;
    color: #94a3b8;
    font-size: 12px;
    text-align: center;
}

@media (max-width: 900px) {
    .item-main {
        grid-template-columns: 1fr;
    }

    .col-2,
    .col-3 {
        grid-column: span 4;
    }

    .col-10 {
        grid-column: span 8;
    }
}

@media (max-width: 700px) {
    .nav-inner {
        display: flex;
        min-height: 62px;
        justify-content: center;
        padding: 8px 12px;
        gap: 8px;
    }

    .site-name {
        display: none;
    }

    .nav-links {
        min-width: 0;
    }

    .nav-link {
        min-width: 0;
        padding: 6px 10px;
    }

    .nav-utility {
        flex: none;
    }

    .shell,
    .shell-narrow,
    .login-shell {
        padding: 36px 12px 24px;
    }

    .login-shell {
        padding-top: 9vh;
    }

    .page-header {
        margin-bottom: 26px;
    }

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

    .card {
        padding: 16px;
    }

    .grid {
        display: block;
    }

    .grid > * {
        margin-bottom: 12px;
    }

    .grid > *:last-child {
        margin-bottom: 0;
    }

    .order-head {
        display: block;
    }

    .order-head > .hint {
        margin-top: 10px;
    }

    .section-title {
        flex-direction: column;
        gap: 4px;
    }

    .actions {
        justify-content: stretch;
    }

    .actions > * {
        flex: 1;
    }

    .actions-start .btn,
    .filter-actions .btn,
    .full-mobile {
        width: 100%;
    }

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

    .kv {
        grid-template-columns: 82px minmax(0, 1fr);
    }

    .table-wrap {
        max-height: 480px;
    }
}

@media (max-width: 430px) {
    .nav-inner {
        flex-wrap: wrap;
    }

    .nav-links {
        width: 100%;
    }

    .nav-link {
        flex: 1;
    }

    .nav-utility {
        width: 100%;
        justify-content: center;
    }

    .nav-utility:empty {
        display: none;
    }

    .nav-utility .btn {
        width: 100%;
    }
}
