html, body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f4f6f8;
    color: #1e293b;
}

a { color: #0f5cc0; text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header, .site-footer {
    background: #ffffff;
    border-bottom: 1px solid #d8dee7;
}

.site-footer {
    border-top: 1px solid #d8dee7;
    border-bottom: 0;
    margin-top: 32px;
}

.header-inner, .footer-inner, .hero-strip, .filter-bar, .dashboard-grid, .stats-grid {
    display: flex;
    gap: 16px;
    align-items: center;
}

.header-inner, .footer-inner { min-height: 64px; justify-content: space-between; }
.brand { font-weight: 700; color: #111827; }
.nav { display: flex; gap: 14px; flex-wrap: wrap; }
.page { min-height: calc(100vh - 128px); }

.panel, .model-card, .flash, .empty-state {
    background: #fff;
    border: 1px solid #d8dee7;
    border-radius: 8px;
    box-sizing: border-box;
}

.panel { padding: 20px; }
.flash, .empty-state { padding: 14px 16px; margin-top: 16px; }
.flash-success { border-color: #82c791; background: #edf9ef; }
.flash-error { border-color: #ee9c9c; background: #fff1f1; }

.hero-strip {
    justify-content: space-between;
    padding: 28px 0 20px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid #1d4ed8;
    background: #1d4ed8;
    color: #fff;
    cursor: pointer;
}
.button:hover { text-decoration: none; background: #1845c4; }
.button.ghost { background: #fff; color: #1d4ed8; }
.button.danger { background: #b91c1c; border-color: #b91c1c; }
.button.small { min-height: 34px; padding: 0 12px; font-size: 14px; }

.filter-bar { flex-wrap: wrap; padding-bottom: 20px; }
.chip {
    padding: 8px 12px;
    border-radius: 999px;
    background: #e8edf3;
    color: #1f2937;
}
.chip.active { background: #1d4ed8; color: #fff; }

.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.model-card { overflow: hidden; }
.model-card-body { padding: 14px; display: grid; gap: 10px; }
.thumb-link { display: block; padding: 10px; background: #eef2f7; }
.model-thumb { width: 100%; height: 220px; display: block; border-radius: 6px; background: #f8fafc; object-fit: contain; }
#thumbnail-generator-canvas {
    position: fixed;
    left: -10000px;
    top: 0;
    width: 320px;
    height: 220px;
    pointer-events: none;
}
.meta-row, .meta-actions { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; color: #475569; }
.pagination { display: flex; gap: 8px; padding: 24px 0; flex-wrap: wrap; }
.pagination a { padding: 8px 12px; border-radius: 8px; background: #fff; border: 1px solid #d8dee7; }
.pagination a.active { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-panel, .single-column .panel { width: min(460px, 100%); }

.form-grid, .mini-form {
    display: grid;
    gap: 12px;
}

label { display: grid; gap: 6px; font-size: 14px; color: #334155; }
input, select {
    box-sizing: border-box;
    width: 100%;
    min-height: 40px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    padding: 0 12px;
    background: #fff;
}
input[type="file"] { padding: 8px 12px; }

.dashboard-grid {
    align-items: start;
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 16px;
    padding-top: 20px;
}

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}
.inline-form { display: inline-flex; gap: 8px; align-items: center; margin: 2px 8px 2px 0; }
details summary { cursor: pointer; color: #0f5cc0; }
.admin-thumbnail-cell {
    display: grid;
    gap: 8px;
    width: 132px;
}
.admin-thumbnail {
    width: 132px;
    height: 92px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid #d8dee7;
    background: #f8fafc;
}
.thumbnail-missing {
    display: grid;
    place-items: center;
    width: 132px;
    height: 92px;
    border-radius: 6px;
    border: 1px dashed #cbd5e1;
    color: #64748b;
    background: #f8fafc;
    font-size: 13px;
}
.thumbnail-progress {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid #93c5fd;
    background: #eff6ff;
    box-sizing: border-box;
}
.thumbnail-progress-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.thumbnail-progress-track {
    height: 8px;
    margin-top: 12px;
    border-radius: 999px;
    background: #dbeafe;
    overflow: hidden;
}
.thumbnail-progress-bar {
    height: 100%;
    border-radius: inherit;
    background: #1d4ed8;
    transition: width 0.2s ease;
}

.admin-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.stat-card { display: grid; gap: 8px; justify-items: center; padding: 24px; }
.stat-card strong { font-size: 32px; }

.viewer-page {
    min-height: 100vh;
    background: #ffffff;
}
.viewer-canvas-holder { height: 100vh; }

.parts-wrap #big_parts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.parts-card {
    display: grid;
    gap: 10px;
    justify-items: center;
    padding: 12px;
    border: 1px solid #d8dee7;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}
.parts-amount { font-weight: 700; }
.parts-name { font-size: 14px; color: #475569; text-align: center; }
.parts-card canvas {
    display: block;
    justify-self: center;
}
#list_table canvas {
    display: block;
    margin: 0 auto;
}

@media (max-width: 900px) {
    .dashboard-grid, .stats-grid {
        grid-template-columns: 1fr;
    }
    .hero-strip {
        flex-direction: column;
        align-items: flex-start;
    }
}
