:root {
    --bg: #f4f5f7;
    --panel: #ffffff;
    --border: #e2e5eb;
    --text: #1f2430;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --gray-bg: #eef0f4;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 220px;
    background: #171b26;
    color: #cbd2e0;
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar .brand {
    font-weight: 700;
    font-size: 16px;
    color: #fff;
    padding: 0 20px 20px;
    border-bottom: 1px solid #2a3040;
    margin-bottom: 10px;
}

.sidebar nav a {
    display: block;
    padding: 10px 20px;
    color: #cbd2e0;
    font-size: 14px;
}

.sidebar nav a:hover { background: #232a3a; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }

.sidebar .user-box {
    margin-top: 20px;
    padding: 12px 20px;
    border-top: 1px solid #2a3040;
    font-size: 12px;
    color: #8a93a8;
}

.main { flex: 1; padding: 28px 32px; max-width: 1200px; }

h1 { font-size: 22px; margin: 0 0 20px; }
h2 { font-size: 16px; margin: 0 0 14px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.actions-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.stat-card .value { font-size: 24px; font-weight: 700; }
.stat-card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .03em; }
tr:hover td { background: #fafbfc; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.badge-new { background: var(--gray-bg); color: #374151; }
.badge-pending_ai, .badge-pending_price { background: var(--warning-bg); color: var(--warning); }
.badge-ready, .badge-synced { background: var(--success-bg); color: var(--success); }
.badge-missing_from_csv { background: var(--gray-bg); color: #6b7280; }
.badge-error { background: var(--danger-bg); color: var(--danger); }

.btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--gray-bg); color: var(--text); }
.btn-secondary:hover { background: #dde1e8; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; }
.form-group .hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
}
textarea { min-height: 80px; resize: vertical; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; align-items: end; }
.filters .form-group { margin-bottom: 0; flex: 1; max-width: 240px; }

.pagination { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: center; }

.alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-success { background: var(--success-bg); color: #15803d; }
.alert-error { background: var(--danger-bg); color: #b91c1c; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.login-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 320px;
}
.login-box h1 { text-align: center; font-size: 18px; }

.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }

/* --- Menu a comparsa (mobile) --- */
.menu-toggle { display: none; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1040;
}

.sidebar-backdrop.visible { display: block; }

/* --- Responsive --- */
@media (max-width: 768px) {
    .layout { flex-direction: column; min-height: auto; }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 14px;
        left: 14px;
        z-index: 1100;
        width: 42px;
        height: 42px;
        background: #171b26;
        color: #fff;
        border: none;
        border-radius: 8px;
        font-size: 20px;
        line-height: 1;
        cursor: pointer;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 240px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 1050;
        overflow-y: auto;
    }

    .sidebar.open { transform: translateX(0); }

    .main { padding: 72px 16px 16px; max-width: none; }

    h1 { font-size: 19px; }

    .filters { flex-direction: column; align-items: stretch; }
    .filters .form-group { max-width: none; }

    .login-box { width: 90%; max-width: 320px; padding: 24px; }
}

@media (max-width: 480px) {
    .grid-stats { grid-template-columns: repeat(2, 1fr); }
    .stat-card .value { font-size: 20px; }
}

.progress-wrap { margin-top: 12px; }
.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--gray-bg);
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: 999px;
    transition: width 0.3s ease;
}
.progress-label {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-muted);
}
