:root {
    --accent: #d4a017;
    --accent-hover: #b8860b;
    --accent-light: #e6b830;
    --accent-rgb: 212, 160, 23;
}

html, body {
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

body {
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

.main {
    /* Footer sits just below the content (harmonized to LSR), rather than being
       stretched to the bottom of the viewport via flex-grow + min-height. */
}

footer { margin-top: auto; }
footer a:hover { color: var(--accent) !important; text-decoration: underline !important; }

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(var(--accent-rgb), 0.25);
}

/* Accent color overrides */
.bg-accent { background-color: var(--accent) !important; }
.text-accent { color: var(--accent) !important; }
.border-accent { border-color: var(--accent) !important; }
.btn-accent {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-accent:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}
.btn-outline-accent {
    color: var(--accent);
    border-color: var(--accent);
}
.btn-outline-accent:hover {
    background-color: var(--accent);
    color: #fff;
}

/* Navbar */
.navbar-accent { background-color: var(--accent) !important; }

/* Quintile input styling */
.quintile-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.quintile-input-group label {
    min-width: 140px;
    font-weight: 500;
    font-size: 0.9rem;
}

.quintile-input-group input {
    width: 80px;
    text-align: center;
    font-weight: 600;
}

.quintile-sum {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
}

.quintile-sum.valid { background-color: #d4edda; color: #155724; }
.quintile-sum.invalid { background-color: #f8d7da; color: #721c24; }

/* Quintile stacked bar */
.qbar-q1 { background-color: #4292c6; }
.qbar-q2 { background-color: #41ab5d; }
.qbar-q3 { background-color: #fe9929; }
.qbar-q4 { background-color: #f03b20; }
.qbar-q5 { background-color: #99000d; }

.quintile-bar {
    display: flex;
    height: 44px;
    border-radius: 0.375rem;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}

.qbar-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.2s ease;
    min-width: 0;
    overflow: hidden;
}

.qbar-label {
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    white-space: nowrap;
}

.qbar-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #6c757d;
}

.qbar-legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.qbar-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.qbar-q5-auto-note {
    font-size: 0.75rem;
    color: #6c757d;
    white-space: nowrap;
}

input.qbar-q5-readonly {
    background-color: #f8f9fa;
    color: #6c757d;
}

input.qbar-q5-error {
    background-color: #f8d7da !important;
    color: #721c24 !important;
}

/* Chart container */
.chart-container {
    position: relative;
    max-width: 700px;
    margin: 1.5rem auto;
}

.projector-chart {
    max-width: 900px;
}

.metric-card {
    border-color: rgba(var(--accent-rgb), 0.25);
    box-shadow: 0 8px 24px rgba(33, 37, 41, 0.06);
}

.metric-label {
    color: #6c757d;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 0.35rem;
    color: #212529;
}

.metric-note,
.metric-inline {
    color: #6c757d;
    font-size: 0.9rem;
    margin-top: 0.4rem;
}

/* Progress steps */
.step-indicator {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #dee2e6;
}

.step-dot.active { background-color: var(--accent); }
.step-dot.completed { background-color: #198754; }

/* Backoffice table actions */
.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline-block; margin: 0; }
.actions-cell .btn { min-width: 8rem; text-align: center; margin-right: 0.25rem; margin-bottom: 0.25rem; }

/* Extra-small buttons for dense action cells — override the 8rem min-width explicitly */
.btn-xs { padding: 1px 6px; font-size: .72rem; line-height: 1.4; border-radius: .2rem; }
.actions-cell .btn.btn-xs { min-width: 0; width: auto; }

/* Fixed width badges */
.fixed-width-badge { display: inline-block; min-width: 75px; text-align: center; }

/* Country dropdown with search */
.country-select { max-width: 400px; }

/* Data quality indicators */
.quality-high { color: #198754; }
.quality-medium { color: var(--accent); }
.quality-estimated { color: #6c757d; font-style: italic; }

/* Screen reader only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Password field with show/hide + generate controls ──────── */
.pw-input-wrap { display: flex; gap: .4rem; align-items: stretch; }
.pw-input-wrap input { flex: 1 1 auto; min-width: 0; }
.pw-toggle, .pw-generate {
    flex: 0 0 auto; cursor: pointer; white-space: nowrap;
    border: 1px solid #ccc; background: #f4f5f7;
    border-radius: 6px; padding: 0 .7rem; font-size: .8rem; font-weight: 600;
    color: #555;
}
.pw-toggle:hover, .pw-generate:hover { background: #e9ebef; }
.pw-toggle.is-on { background: #d6eaf8; color: #1e3a5f; }

/* ── Backoffice table controls (search / sort / pagination) ── */
.table-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: .9rem;
    flex-wrap: wrap;
}
.table-search { width: 100%; max-width: 360px; }
.table-search__hint { font-size: .8rem; color: #7f8c8d; }
.table-page-size-label {
    display: flex; align-items: center; gap: .4rem;
    font-size: .85rem; color: #7f8c8d; white-space: nowrap;
}
.table-page-size {
    padding: .2rem .4rem; font-size: .85rem;
    border: 1px solid #dde3ea; border-radius: 4px; background: #fff;
}
.table-pagination {
    display: flex; align-items: center; gap: .75rem;
    margin: .6rem 0 .25rem; font-size: .85rem;
}
.pagination-info { color: #7f8c8d; }

th.sortable-col {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.4rem !important;
}
th.sortable-col:hover { background: #f0f0f0; }
th.sortable-col::after {
    content: "⇅";
    position: absolute;
    right: .55rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: .8rem;
    opacity: .35;
}
th.sortable-col.is-sorted-asc::after  { content: "↑"; opacity: 1; color: var(--accent); }
th.sortable-col.is-sorted-desc::after { content: "↓"; opacity: 1; color: var(--accent); }

.table-empty-msg {
    margin-top: 1rem;
    padding: 1rem;
    color: #7f8c8d;
    background: #f6f6f6;
    border-radius: 6px;
    text-align: center;
    font-size: .9rem;
}

/* ── Bulk select ────────────────────────────────────────────── */
.col-check { width: 2.5rem; padding-left: .75rem !important; padding-right: .5rem !important; }
.col-check input[type="checkbox"] { cursor: pointer; }

.bulk-bar {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.1rem;
    background: #343a40;
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 18px rgba(0,0,0,.22);
    z-index: 200;
    white-space: nowrap;
    flex-wrap: wrap;
}
.bulk-bar[hidden] { display: none; }
.bulk-bar__count { font-size: .875rem; font-weight: 600; }
.bulk-bar__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.bulk-bar .btn-sm { font-size: .8rem; }
.bulk-bar .btn-danger { background: #c0392b; color: #fff; border-color: #c0392b; }
.bulk-bar .btn-danger:hover { background: #a93226; }
.bulk-deselect { background: none; border: none; color: rgba(255,255,255,.6); font-size: .8rem; cursor: pointer; padding: 0 .25rem; }
.bulk-deselect:hover { color: #fff; }

/* ── Role badges ────────────────────────────────────────────── */
.role-badge { display: inline-block; padding: .15rem .5rem; border-radius: 4px; font-size: .75rem; font-weight: 700; }
.role-badge--admin    { background: #fdecea; color: #c0392b; }
.role-badge--educator { background: #d6eaf8; color: #1e3a5f; }

@media print {
    footer,
    .no-print {
        display: none !important;
    }

    .main {
        min-height: auto;
    }

    .card {
        break-inside: avoid;
    }
}
