/* ═══════════════════════════════════════════
   Design System — Corporate Sobre
   ═══════════════════════════════════════════ */

:root {
    --bg: #f8f9fb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --ink: #111827;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* ── Base ── */

html { font-size: 16px; }

body {
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ── Navbar ── */

.site-header .navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 0.6rem 0;
}

.site-header .navbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ink);
    text-decoration: none;
}

.site-header .navbar-brand:hover { color: var(--primary); }

.site-header .brand-icon {
    width: 22px;
    height: 22px;
    color: var(--primary);
}

.site-header .nav-link {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s;
}

.site-header .nav-link:hover { color: var(--primary); }

.site-header .navbar-toggler {
    border: 1px solid var(--border);
}

/* ── Page shell ── */

.page-shell { padding-bottom: 3rem; }

/* ── Footer ── */

.site-footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.85rem;
    padding: 1.25rem 0;
}

/* ── Cards ── */

.card-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

/* Legacy class support */
.hero-card,
.feature-card,
.dashboard-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.hero-card,
.dashboard-card { padding: 2rem; }
.feature-card { padding: 1.5rem; }

/* ── Stat cards (dashboard) ── */

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--border);
    min-height: 100%;
}

.stat-card--blue   { border-left-color: #3b82f6; }
.stat-card--green  { border-left-color: var(--success); }
.stat-card--yellow { border-left-color: var(--warning); }
.stat-card--red    { border-left-color: var(--danger); }

.stat-card .stat-info { flex: 1; }

.stat-card .stat-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-card .stat-total {
    font-size: 1rem;
    font-weight: 400;
    color: var(--muted);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 1rem;
}

.stat-icon--blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon--green  { background: var(--success-light); color: var(--success); }
.stat-icon--yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon--red    { background: var(--danger-light); color: var(--danger); }

/* ── Dashboard header ── */

.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.dash-header .dash-icon {
    color: var(--primary);
    margin-right: 0.5rem;
}

.dash-header .dash-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
}

.dash-header .dash-subtitle {
    font-size: 0.88rem;
    color: var(--muted);
    margin: 0.15rem 0 0;
}

/* ── Toolbar ── */

.toolbar-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.toolbar-card .search-wrap {
    position: relative;
    flex: 1;
}

.toolbar-card .search-wrap .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    width: 16px;
    height: 16px;
}

.toolbar-card .search-input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem 0.55rem 2.25rem;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.15s;
}

.toolbar-card .search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ── Buttons ── */

.btn-primary {
    --bs-btn-bg: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary-hover);
    --bs-btn-hover-border-color: var(--primary-hover);
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.btn-outline-primary {
    --bs-btn-color: var(--primary);
    --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary);
    --bs-btn-hover-border-color: var(--primary);
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s;
}

.btn-export:hover {
    border-color: var(--border-strong);
    color: var(--ink);
    background: var(--bg);
}

.btn-export.btn-export--active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-export.btn-export--active:hover {
    background: var(--primary-hover);
    color: #fff;
}

/* ── Validation items ── */

.validation-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--ink);
    transition: all 0.15s;
}

.validation-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    color: var(--ink);
}

.validation-item .vi-code {
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 2.5rem;
    color: var(--muted);
}

.validation-item .vi-name {
    flex: 1;
    margin-left: 1rem;
}

.validation-item .vi-name strong { display: block; font-weight: 600; }
.validation-item .vi-name .vi-sub { font-size: 0.8rem; color: var(--muted); }

.validation-item .vi-entities {
    font-size: 0.82rem;
    color: var(--muted);
    margin-left: 1rem;
}

.validation-item .vi-badge { margin-left: 1rem; }
.validation-item .vi-actions { margin-left: 0.75rem; }

/* ── Empty state ── */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.empty-state .empty-icon { color: var(--border-strong); margin-bottom: 0.75rem; }
.empty-state .empty-title { font-weight: 600; margin-bottom: 0.25rem; }
.empty-state .empty-text { color: var(--muted); font-size: 0.88rem; }

/* ── Metric cards (legacy) ── */

.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    min-height: 100%;
}

.metric-label, .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
}

.metric-value {
    display: block;
    margin-top: 0.4rem;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

/* ── Tables ── */

.table > :not(caption) > * > * {
    background: transparent;
}

.table > thead > tr > th {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
    padding: 0.75rem;
}

.table > tbody > tr > td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table > tbody > tr:hover > td {
    background: var(--bg);
}

/* ── Forms ── */

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    padding: 0.6rem 0.85rem;
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 0.3rem;
}

/* ── Badges ── */

.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.3em 0.65em;
    border-radius: var(--radius-xs);
}

.badge.text-bg-success {
    background: var(--success-light) !important;
    color: var(--success) !important;
}

.badge.text-bg-warning {
    background: var(--warning-light) !important;
    color: var(--warning) !important;
}

.badge.text-bg-danger {
    background: var(--danger-light) !important;
    color: var(--danger) !important;
}

.badge.text-bg-secondary {
    background: var(--bg) !important;
    color: var(--muted) !important;
}

.badge.text-bg-info {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

/* ── Alerts ── */

.alert-info {
    background: var(--primary-light);
    border-color: #bfdbfe;
    color: #1e40af;
    border-radius: var(--radius-sm);
}

.alert-success {
    background: var(--success-light);
    border-color: #a7f3d0;
    color: #065f46;
    border-radius: var(--radius-sm);
}

.alert-warning {
    background: var(--warning-light);
    border-color: #fde68a;
    color: #92400e;
    border-radius: var(--radius-sm);
}

/* ── Questionnaire: Entity list ── */

.entity-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-height: 480px;
    overflow-y: auto;
}

.entity-table-header {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    background: #4b5563;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    position: sticky;
    top: 0;
    z-index: 1;
}

.entity-table-header .eth-name { flex: 1; }
.entity-table-header .eth-mode { flex: 1; }
.entity-table-header .eth-active { width: 120px; text-align: center; flex-shrink: 0; }

.entity-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.entity-row:last-child { border-bottom: none; }

.entity-row:nth-child(even) { background: var(--bg); }

.entity-info { flex: 1; display: flex; align-items: center; gap: 1.5rem; }

.entity-name { flex: 1; font-weight: 500; }

.entity-mode { flex: 1; font-size: 0.85rem; color: var(--muted); }

.entity-check {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
}

/* ── Merge source checkboxes ── */

.merge-source-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.merge-source-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.merge-source-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.merge-source-item:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.merge-source-item input { width: 16px; height: 16px; }

/* ── Entity active badge ── */

.entity-active-badge {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.2em 0.6em;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
}

.entity-active-badge.active-yes {
    background: var(--success-light);
    color: var(--success);
}

.entity-active-badge.active-no {
    background: var(--danger-light);
    color: var(--danger);
}

/* ── Scrollable containers ── */

.scroll-list {
    max-height: 500px;
    overflow-y: auto;
}

.scroll-table {
    max-height: 480px;
    overflow-y: auto;
}

/* ── Questionnaire: Choice buttons ── */

.choice-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1rem 1.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.15s;
    text-align: center;
    color: var(--muted);
    background: var(--surface);
}

.choice-btn:hover { border-color: var(--border-strong); }

.choice-btn--yes.active {
    border-color: var(--success);
    background: var(--success-light);
    color: var(--success);
}

.choice-btn--no.active {
    border-color: var(--warning);
    background: var(--warning-light);
    color: var(--warning);
}

/* ── Submit button (bordeaux) ── */

.btn-submit {
    background: #7c2d3e;
    border-color: #7c2d3e;
    color: #fff;
    font-weight: 600;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    transition: background 0.15s;
}

.btn-submit:hover {
    background: #5f1f2e;
    border-color: #5f1f2e;
    color: #fff;
}

/* ── Auth pages ── */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2.5rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.auth-subtitle {
    font-size: 0.88rem;
    color: var(--muted);
    margin: 0;
}

.auth-form { display: flex; flex-direction: column; }

.auth-field { margin-bottom: 1.25rem; }

.auth-field .form-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 0.4rem;
}

.auth-field .form-control {
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
}

.auth-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-size: 1rem;
}

/* ── Responsive ── */

@media (max-width: 767.98px) {
    .dash-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1.25rem;
    }

    .toolbar-card {
        flex-direction: column;
    }

    .validation-item {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .hero-card,
    .dashboard-card,
    .feature-card {
        padding: 1.25rem;
    }
}
