:root {
    --bg: #f3f6f8;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #687385;
    --line: #dfe6ee;
    --primary: #1f6feb;
    --primary-dark: #1557bb;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --orange: #E19A75;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
    --shadow: 0 18px 45px rgba(31, 41, 55, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    background:
        radial-gradient(circle at 18% 12%, rgba(31, 111, 235, 0.10), transparent 28%),
        linear-gradient(135deg, #f8fafc 0%, var(--bg) 54%, #eef7f3 100%);
    color: var(--ink);
}

a {
    color: inherit;
    text-decoration: none;
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    width: 252px;
    height: 100vh;
    flex: 0 0 252px;
    padding: 24px 18px;
    color: #e5e7eb;
    background: linear-gradient(180deg, var(--sidebar), #0b1220);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.logo {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 40px;
    margin-bottom: 34px;
    font-size: 20px;
    font-weight: 700;
}

.logo-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #f8fafc;
    color: var(--sidebar);
    font-size: 18px;
}

.menu-section {
    margin: 24px 0 10px;
    color: #95a3b8;
    font-size: 12px;
    letter-spacing: 0;
}

.menu {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 44px;
    margin-bottom: 6px;
    padding: 11px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 14px;
}

.menu:hover,
.menu.active {
    background: var(--sidebar-soft);
    color: #ffffff;
}

.menu.active {
    box-shadow: inset 3px 0 0 #38bdf8;
}

.menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    color: #93c5fd;
    font-weight: 700;
}

.main {
    flex: 1;
    min-width: 0;
    padding: 28px;
    overflow-x: hidden;
}

.upload-main {
    max-width: 1440px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    margin-bottom: 24px;
    padding: 22px 26px;
    border: 1px solid rgba(223, 230, 238, 0.85);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow);
}

.topbar h1 {
    margin: 4px 0 0;
    font-size: 28px;
    line-height: 1.25;
}

.topbar p {
    max-width: 820px;
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.upload-hero {
    min-height: 170px;
    align-items: stretch;
    overflow: hidden;
    background:
        linear-gradient(115deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.78)),
        linear-gradient(135deg, rgba(31, 111, 235, 0.16), rgba(22, 163, 74, 0.12));
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
}

.hero-status {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 230px;
    padding: 22px;
    border: 1px solid rgba(31, 111, 235, 0.14);
    border-radius: 12px;
    background: #f8fbff;
}

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

.hero-status strong {
    margin-top: 8px;
    color: var(--ink);
    font-size: 20px;
}

.user-badge {
    padding: 10px 16px;
    border-radius: 999px;
    background: #eef6ff;
    color: var(--primary);
    white-space: nowrap;
}

.overview-grid,
.stat-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 24px;
}

.overview-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.overview-card,
.stat-card,
.upload-panel,
.table-panel {
    border: 1px solid rgba(223, 230, 238, 0.9);
    border-radius: 14px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.overview-card,
.stat-card {
    padding: 22px;
}

.overview-card span,
.stat-card span {
    color: var(--muted);
    font-size: 14px;
}

.overview-card strong,
.stat-card strong {
    display: block;
    margin: 10px 0 6px;
    font-size: 26px;
}

.overview-card p {
    margin: 0;
    color: #8a97a8;
}

.stat-card.danger strong {
    color: var(--red);
}

.stat-card.orange strong {
    color: var(--orange);
}

.stat-card.warning strong {
    color: var(--amber);
}

.stat-card.success strong {
    color: var(--green);
}

.stat-card.primary strong {
    color: var(--primary);
}

.warning-banner {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 16px;
}

.upload-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 22px;
    align-items: start;
}

.upload-panel,
.table-panel {
    padding: 28px;
    margin-bottom: 24px;
}

.upload-card {
    min-height: 560px;
}

.panel-title h2 {
    margin: 4px 0 0;
    font-size: 23px;
    line-height: 1.35;
}

.panel-title p {
    margin: 9px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.upload-form {
    margin-top: 24px;
}

.upload-box {
    position: relative;
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 18px;
    align-items: center;
    min-height: 128px;
    margin: 16px 0;
    padding: 22px 24px 22px 78px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdff;
    cursor: pointer;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.upload-box:hover {
    transform: translateY(-1px);
    border-color: rgba(31, 111, 235, 0.45);
    box-shadow: 0 12px 28px rgba(31, 111, 235, 0.10);
}

.upload-box.has-file {
    border-color: rgba(22, 163, 74, 0.45);
    background: #f7fcf9;
}

.upload-box.small {
    min-height: 80px;
    margin: 0;
    padding: 16px 18px 16px 18px;
    grid-template-columns: 1fr;
    gap: 0;
}

.upload-box.small .upload-content strong {
    font-size: 14px;
}

.upload-box.small .upload-content small {
    font-size: 12px;
}

.upload-box.small .upload-content em {
    font-size: 12px;
}

.upload-box input {
    display: none;
}

.upload-step {
    position: absolute;
    top: 22px;
    left: 22px;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 700;
}

.upload-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 12px;
    background: #eef6ff;
    font-size: 26px;
}

.upload-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.upload-content strong {
    color: var(--ink);
    font-size: 18px;
}

.upload-content small {
    margin-top: 6px;
    color: var(--muted);
    line-height: 1.5;
}

.upload-content em {
    display: block;
    max-width: 100%;
    margin-top: 12px;
    overflow: hidden;
    color: #8a97a8;
    font-size: 13px;
    font-style: normal;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-box.has-file .upload-content em {
    color: var(--green);
    font-weight: 700;
}

.upload-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-top: 24px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.upload-note {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: var(--muted);
    font-size: 14px;
}

.upload-note strong {
    color: var(--ink);
    font-size: 15px;
}

.primary-btn,
.secondary-btn,
.download-btn,
.summary-btn,
.filter-bar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.primary-btn {
    min-width: 164px;
    background: var(--primary);
    box-shadow: 0 12px 24px rgba(31, 111, 235, 0.20);
}

.primary-btn:hover {
    transform: translateY(-1px);
    background: var(--primary-dark);
}

.primary-btn:disabled {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

.secondary-btn {
    min-width: 152px;
    background: #0f766e;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.18);
}

.secondary-btn:hover {
    transform: translateY(-1px);
    background: #115e59;
}

.secondary-btn:disabled {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

.download-btn {
    background: var(--green);
}

.database-form {
    margin-top: 22px;
}

.database-source {
    padding: 22px;
    border: 1px solid rgba(15, 118, 110, 0.18);
    border-radius: 12px;
    background: #f6fbfa;
}

.database-source-header {
    margin-bottom: 18px;
}

.database-source-header h3 {
    margin: 4px 0 0;
    font-size: 18px;
}

.database-source-header p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.database-upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 18px;
}

.database-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.summary-btn {
    background: var(--amber);
}

.upload-guide {
    display: grid;
    gap: 14px;
}

.guide-card {
    padding: 20px;
    border: 1px solid rgba(223, 230, 238, 0.9);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 12px 30px rgba(31, 41, 55, 0.08);
}

.guide-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-bottom: 14px;
    border-radius: 8px;
    background: #e7f7ef;
    color: var(--green);
    font-weight: 800;
}

.guide-card strong {
    display: block;
    font-size: 16px;
}

.guide-card p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.7;
}

.action-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 18px;
}

.filter-bar input,
.filter-bar select {
    min-height: 44px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 12px 14px;
    background: white;
}

.filter-bar input {
    width: min(360px, 100%);
}

.filter-bar button {
    background: var(--primary);
}

.table-wrap {
    overflow-x: auto;
    margin-top: 18px;
}

.empty-state {
    padding: 22px;
    border: 1px dashed var(--line);
    border-radius: 10px;
    background: #f8fafc;
    color: var(--muted);
    text-align: center;
}

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

th {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
}

td {
    padding: 11px;
    border-bottom: 1px solid #e5e7eb;
    text-align: center;
}

/* 在用学校固定为结果表最后一列，长文本左对齐更便于阅读。 */
.table-panel table tbody td:last-child {
    text-align: left;
}

.row-red {
    background: #fee2e2;
}

.row-orange {
    background: #fbe8db;
}

.row-yellow {
    background: #fef3c7;
}

.row-green {
    background: #dcfce7;
}

.row-high-stock {
    background: #E9D5FF;
}

.high-stock-section {
    margin-top: 36px;
    border-top: 1px solid #E9D5FF;
    padding-top: 24px;
}

.high-stock-section .eyebrow {
    color: #7C3AED;
}

.high-stock-btn {
    background: #7C3AED !important;
}

.high-stock-btn:hover {
    background: #6D28D9 !important;
}

.filter-checkboxes {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.filter-check {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    border: 1px solid #e5e7eb;
    background: #fff;
    transition: all 0.15s;
}

.filter-check input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.filter-check.red {
    border-color: #fca5a5;
    color: #dc2626;
}
.filter-check.red:has(input:checked) {
    background: #fee2e2;
}

.filter-check.orange {
    border-color: #fdba74;
    color: #ea580c;
}
.filter-check.orange:has(input:checked) {
    background: #fbe8db;
}

.filter-check.yellow {
    border-color: #fde68a;
    color: #d97706;
}
.filter-check.yellow:has(input:checked) {
    background: #fef3c7;
}

.filter-check.green {
    border-color: #86efac;
    color: #16a34a;
}
.filter-check.green:has(input:checked) {
    background: #dcfce7;
}

@media (max-width: 1120px) {
    .upload-shell {
        grid-template-columns: 1fr;
    }

    .upload-guide {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stat-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .layout {
        display: block;
    }

    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        padding: 18px;
    }

    .menu-section {
        margin-top: 18px;
    }

    .main {
        padding: 18px;
    }

    .topbar,
    .upload-actions,
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .database-upload-grid {
        grid-template-columns: 1fr;
    }

    .database-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-status {
        min-width: 0;
    }

    .upload-guide,
    .stat-grid,
    .overview-grid {
        grid-template-columns: 1fr;
    }

    .upload-panel,
    .table-panel {
        padding: 20px;
    }

    .upload-box {
        grid-template-columns: 48px 1fr;
        gap: 14px;
        min-height: 118px;
        padding: 20px 18px 20px 58px;
    }

    .upload-step {
        left: 18px;
    }

    .upload-icon {
        width: 48px;
        height: 48px;
        font-size: 22px;
    }

    .primary-btn {
        width: 100%;
    }

    .secondary-btn {
        width: 100%;
    }
}

/* 导出按钮样式 */
.export-actions {
    display: flex;
    gap: 12px;
    margin: 16px 0;
}

.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #f0f7ff;
    color: #1f6feb;
    border: 1px solid #d0e3ff;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}

.export-btn:hover {
    background: #1f6feb;
    color: #fff;
    border-color: #1f6feb;
}

/* ---------- 侧边栏用户信息 ---------- */
.sidebar-user {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary, #2563eb);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.user-info div {
    display: flex;
    flex-direction: column;
}

.user-info strong {
    font-size: 14px;
    color: #f1f5f9;
}

.user-info small {
    font-size: 12px;
    color: #94a3b8;
}

.logout-link {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s;
}

.logout-link:hover {
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
}
