* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #f3f4f6;
    min-height: 100vh;
    padding: 32px 16px;
    color: #111827;
}

.container { max-width: 1000px; margin: 0 auto; }

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}
.header h1 { font-size: 1.75rem; font-weight: 700; color: #111827; }
.header p  { margin-top: 6px; color: #6b7280; font-size: 0.95rem; }

.admin-entry {
    font-size: 0.875rem;
    color: #6b7280;
    text-decoration: none;
    padding: 6px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    white-space: nowrap;
    transition: all 0.15s;
    background: white;
}
.admin-entry:hover { color: #111827; border-color: #9ca3af; }

.main {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 780px) { .main { grid-template-columns: 1fr; } }

.form-section, .preview-section {
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 1px 8px rgba(0,0,0,0.07);
}

.field { margin-bottom: 20px; }
.label { display: block; font-size: 0.875rem; font-weight: 600; color: #374151; margin-bottom: 7px; }
.optional { font-weight: 400; color: #9ca3af; }

.select, .textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    color: #111827;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.select:focus, .textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.textarea { resize: vertical; min-height: 80px; }

.upload {
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: #fafafa;
    overflow: hidden;
}
.upload:hover { border-color: #6366f1; background: #f5f3ff; }
.upload.drag  { border-color: #4f46e5; background: #ede9fe; }

.upload-empty { padding: 36px 20px; text-align: center; }
.upload-icon  { font-size: 2.2rem; margin-bottom: 10px; }
.upload-text  { font-size: 0.95rem; color: #374151; font-weight: 500; }
.upload-hint  { font-size: 0.8rem; color: #9ca3af; margin-top: 4px; }

.upload-filled { padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.upload-check  { color: #10b981; font-size: 1.1rem; }
.upload-name   { flex: 1; font-size: 0.9rem; color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-clear  { background: none; border: none; font-size: 1.2rem; color: #9ca3af; cursor: pointer; padding: 0 4px; line-height: 1; }
.upload-clear:hover { color: #ef4444; }

/* Urgent toggle */
.urgent-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1.5px solid #e5e7eb;
    cursor: pointer;
    margin-bottom: 20px;
    transition: border-color 0.15s, background 0.15s;
    user-select: none;
}
.urgent-row:hover { border-color: #fca5a5; background: #fff5f5; }
.urgent-row.active { border-color: #ef4444; background: #fff1f2; }

.urgent-icon  { font-size: 1.1rem; }
.urgent-label { font-size: 0.9rem; font-weight: 600; color: #374151; flex: 1; }
.urgent-row.active .urgent-label { color: #dc2626; }

.toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { display: none; }
.toggle-track {
    position: absolute; inset: 0;
    background: #d1d5db;
    border-radius: 20px;
    transition: background 0.2s;
}
.toggle input:checked ~ .toggle-track { background: #ef4444; }
.toggle-thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked ~ .toggle-track .toggle-thumb { transform: translateX(18px); }

.urgent-desc { font-size: 0.8rem; color: #9ca3af; min-width: 28px; }
.urgent-row.active .urgent-desc { color: #ef4444; }

.btn-submit {
    width: 100%;
    padding: 12px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 9px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, opacity 0.15s;
}
.btn-submit:hover:not(:disabled) { background: #4f46e5; transform: translateY(-1px); }
.btn-submit:active:not(:disabled) { transform: translateY(0); }
.btn-submit:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-submit.urgent { background: #dc2626; }
.btn-submit.urgent:hover:not(:disabled) { background: #b91c1c; }

.status {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.875rem;
    display: none;
}
.status.ok   { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; display: block; }
.status.err  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; display: block; }
.status.busy { background: #ede9fe; color: #4338ca; border: 1px solid #c4b5fd; display: block; }

/* Preview */
.preview-empty {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; min-height: 260px; gap: 10px; color: #9ca3af;
}
.preview-icon { font-size: 2.5rem; }
.preview-text { font-size: 0.9rem; }
.preview-content { min-height: 260px; }

.preview-header {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid #e5e7eb;
}
.preview-title { font-weight: 700; font-size: 1rem; }
.preview-badge { background: #ede9fe; color: #4f46e5; font-size: 0.78rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; }

.preview-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 6px 12px; font-size: 0.82rem; }
.chip-key { color: #6b7280; margin-right: 4px; }
.chip-val { color: #111827; font-weight: 600; }

.preview-images h4 { font-size: 0.875rem; color: #374151; margin-bottom: 10px; }

.img-row { border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; font-size: 0.85rem; }
.img-row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.img-num { background: #ede9fe; color: #4f46e5; font-size: 0.75rem; font-weight: 700; padding: 2px 9px; border-radius: 20px; }
.img-section { font-size: 0.75rem; color: #f59e0b; background: #fef3c7; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.img-size { color: #9ca3af; font-size: 0.78rem; }

.img-line { display: flex; gap: 8px; padding: 3px 0; color: #374151; line-height: 1.5; }
.img-label { min-width: 36px; color: #9ca3af; font-weight: 600; flex-shrink: 0; }

/* ── Admin page ─────────────────────────────────────── */
.admin-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px;
}
.admin-header h1 { font-size: 1.6rem; font-weight: 700; }
.admin-header p  { color: #6b7280; font-size: 0.9rem; margin-top: 4px; }
.back-link { font-size: 0.875rem; color: #6b7280; text-decoration: none; padding: 6px 14px; border: 1px solid #d1d5db; border-radius: 8px; background: white; }
.back-link:hover { color: #111827; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-select { padding: 8px 12px; border: 1.5px solid #d1d5db; border-radius: 8px; font-size: 0.875rem; background: white; outline: none; color: #374151; }
.filter-select:focus { border-color: #6366f1; }

.submissions-list {}

.sub-card {
    background: white;
    border-radius: 12px;
    padding: 20px 22px;
    margin-bottom: 14px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    border-left: 4px solid #e5e7eb;
    transition: box-shadow 0.15s;
}
.sub-card:hover { box-shadow: 0 3px 14px rgba(0,0,0,0.09); }
.sub-card.urgent { border-left-color: #ef4444; }

.sub-card-head {
    display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px;
}
.sub-card-title { display: flex; align-items: center; gap: 8px; }
.sub-product { font-size: 1.05rem; font-weight: 700; color: #111827; }
.tag { font-size: 0.75rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.tag-type { background: #ede9fe; color: #4f46e5; }
.tag-urgent { background: #fee2e2; color: #dc2626; }
.sub-meta { font-size: 0.8rem; color: #9ca3af; text-align: right; line-height: 1.6; }

.sub-body { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sub-chip { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 4px 10px; font-size: 0.8rem; color: #374151; }

.sub-remarks { font-size: 0.85rem; color: #6b7280; background: #f9fafb; border-radius: 8px; padding: 8px 12px; margin-top: 8px; }

.sub-toggle { font-size: 0.82rem; color: #6366f1; cursor: pointer; margin-top: 10px; display: inline-block; }
.sub-toggle:hover { text-decoration: underline; }

.sub-images { margin-top: 12px; border-top: 1px solid #f3f4f6; padding-top: 12px; }
.sub-img-row { display: flex; gap: 8px; padding: 4px 0; font-size: 0.83rem; color: #374151; align-items: baseline; }
.sub-img-num { background: #ede9fe; color: #4f46e5; font-size: 0.72rem; font-weight: 700; padding: 1px 8px; border-radius: 20px; flex-shrink: 0; }

.empty-state { text-align: center; padding: 60px 20px; color: #9ca3af; }
.empty-state p { margin-top: 10px; font-size: 0.9rem; }

.stats-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.stat-card { background: white; border-radius: 10px; padding: 16px 20px; box-shadow: 0 1px 6px rgba(0,0,0,0.06); flex: 1; min-width: 130px; }
.stat-val { font-size: 1.8rem; font-weight: 800; color: #111827; }
.stat-label { font-size: 0.8rem; color: #6b7280; margin-top: 2px; }
.stat-card.red .stat-val { color: #dc2626; }

.admin-loading { text-align: center; padding: 50px 20px; color: #9ca3af; }
