:root {
    --bg: #F4F8FA;
    --card: #FEFEFE;
    --text: #2B2B2B;
    --text-secondary: #898A8E;
    --primary: #AA060F;
    --primary-hover: #530206;
    --border: #D3DCE0;
    --success: #10b981;
    --error: #AA060F;
    --accent: #0D4BC1;
    --dark: #071B1D;
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header + Nav */
header {
    background: var(--dark);
    color: #FEFEFE;
    padding: 0 2rem;
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
header h1 { font-size: 1.1rem; font-weight: 700; }

nav { display: flex; gap: 0.25rem; align-items: center; }
.nav-btn {
    background: none;
    border: none;
    color: #9ca3af;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}
.nav-btn:hover { color: white; background: rgba(255,255,255,0.1); }
.nav-btn.active { color: white; background: rgba(255,255,255,0.15); }
.nav-logout { color: #DDDDDD; margin-left: 0.5rem; }
.nav-logout:hover { background: rgba(255,255,255,0.1); color: #FEFEFE; }

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text);
}

/* Auth */
.auth-container {
    max-width: 420px;
    margin: 3rem auto;
    background: var(--card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}
.auth-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.auth-form { display: flex; flex-direction: column; gap: 1rem; }

/* Forms */
.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}
.form-group { flex: 1; margin-bottom: 0.5rem; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.hint { color: var(--text-secondary); font-weight: 400; font-size: 0.8rem; }
.hint a { color: var(--primary); }

select, input[type="text"], input[type="email"], input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: white;
    color: var(--text);
    transition: border-color 0.15s;
}
select:focus, input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(170,6,15,0.1);
}
.input-muted { background: #f9fafb; color: var(--text-secondary); }

.input-with-btn {
    display: flex;
    gap: 0.5rem;
}
.input-with-btn input { flex: 1; }

.form-error {
    background: #fef2f2;
    color: var(--error);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}
.form-success {
    background: #ecfdf5;
    color: var(--success);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.65rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; }

.btn-small {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}
.btn-small:hover { background: var(--border); }

.btn-icon {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0.25rem;
}
.btn-icon:hover { color: var(--text); }

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--success);
    color: white;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s;
}
.btn-download:hover { opacity: 0.9; }

/* Model select */

/* Guidelines */
.guideline-section { margin-bottom: 1.25rem; }
.guideline-section h3 {
    font-size: 0.95rem;
    color: var(--dark);
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}
.guideline-text {
    font-size: 0.87rem;
    color: var(--text-secondary);
    line-height: 1.7;
}
.guideline-text strong { color: var(--text); }

/* Drop zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 1rem;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(170,6,15,0.03);
}
.drop-zone-content svg { color: var(--text-secondary); margin-bottom: 0.5rem; }
.drop-zone-content p { margin: 0.25rem 0; color: var(--text-secondary); }
.link { color: var(--primary); cursor: pointer; text-decoration: underline; }

.file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(170,6,15,0.06);
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.file-info span { flex: 1; }

/* Progress */
.progress-container { margin-top: 0.5rem; }
.progress-bar {
    height: 12px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 6px;
    transition: width 0.4s ease;
    width: 0%;
}
.progress-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.error-count { color: var(--error); }

/* Table */
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.table-toolbar input { max-width: 320px; }

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
thead { background: #f9fafb; }
th {
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
th:hover { color: var(--primary); }
th[data-sort]::after { content: " \2195"; color: #ccc; font-size: 0.7rem; }

td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
tr:hover { background: rgba(170,6,15,0.03); }
tr { cursor: pointer; }

.cell-title { max-width: 250px; }
.cell-desc {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-slug {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.attr-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}
.badge {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    background: #e8f0fe;
    color: var(--accent);
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
}
.badge.empty {
    background: #fef2f2;
    color: var(--error);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}
.pagination button {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
}
.pagination button:hover { border-color: var(--primary); }
.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Download */
.download-actions { margin-bottom: 1rem; }
#download-list {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 750px;
    max-height: 85vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: white;
}
.modal-header h3 { font-size: 1rem; }
.modal-body { padding: 1.25rem; }
.modal-body h4 { margin: 1rem 0 0.5rem; font-size: 0.9rem; color: var(--dark); }
.modal-body .desc-preview {
    background: #f9fafb;
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.7;
}
.modal-body .attr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
}
.modal-body .attr-item {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0.5rem;
    background: #f9fafb;
    border-radius: 4px;
    font-size: 0.85rem;
}
.attr-item .attr-key { color: var(--text-secondary); }
.attr-item .attr-val { font-weight: 600; }
.attr-item .attr-val.empty { color: var(--error); }

/* Responsive */
@media (max-width: 640px) {
    .form-row { flex-direction: column; }
    main { padding: 1rem; }
    .card { padding: 1rem; }
    .header-inner { flex-direction: column; height: auto; padding: 0.75rem 0; gap: 0.5rem; }
    .model-cards { grid-template-columns: 1fr; }
}
