:root {
    --brand-green: #1f9d55;
    --brand-green-dark: #146338;
    --brand-green-tint: #eaf6ee;
    --brand-gray: #f2f4f3;
    --brand-gray-dark: #e8ebea;
    --brand-border: #dfe3e1;
    --brand-text: #24282b;
    --brand-text-muted: #626b68;
    --brand-header-bg: #eef1ef;
    --brand-radius: 0.25rem;

    --status-success-bg: #e3f6e9;
    --status-success-fg: #146338;
    --status-warning-bg: #fef3e0;
    --status-warning-fg: #93590a;
    --status-danger-bg: #fdecec;
    --status-danger-fg: #a3241c;
    --status-neutral-bg: #edeeee;
    --status-neutral-fg: #565c5a;

    --brand-sidebar-bg: #131a4d;
    --brand-sidebar-bg-active: #1d2566;
    --brand-sidebar-border: rgba(255, 255, 255, 0.12);
    --brand-sidebar-text: #ffffff;
    --brand-sidebar-text-muted: #aab0e0;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--brand-gray);
    color: var(--brand-text);
    font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
    font-size: 0.875rem;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
}

h4 { font-size: 1.05rem; }
h5 { font-size: 0.95rem; }

a {
    text-decoration: none;
}

/* ---------------------------------------------------------------- Shell */

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

.app-sidebar {
    width: 226px;
    flex-shrink: 0;
    background: var(--brand-sidebar-bg);
    border-right: 1px solid var(--brand-sidebar-border);
    padding: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 0.92rem;
    padding: 0.9rem 1.1rem;
    color: var(--brand-sidebar-text);
    border-bottom: 1px solid var(--brand-sidebar-border);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.sidebar-brand-logo {
    height: 30px;
    width: 30px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0 1rem;
}

.nav-section {
    font-size: 0.63rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-sidebar-text-muted);
    padding: 0.75rem 1.1rem 0.25rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--brand-sidebar-border);
}

.nav-section:first-child {
    border-top: none;
    margin-top: 0;
}

.sidebar-nav .nav-link {
    padding: 0.38rem 1.1rem;
    color: rgba(255, 255, 255, 0.78);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-left: 2px solid transparent;
    font-size: 0.8rem;
    font-weight: 500;
}

.sidebar-nav .nav-link i {
    font-size: 0.92rem;
    width: 1.05rem;
    text-align: center;
    color: var(--brand-sidebar-text-muted);
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.sidebar-nav .nav-link.active {
    border-left-color: var(--brand-green);
    background: var(--brand-sidebar-bg-active);
    color: #ffffff;
    font-weight: 600;
}

.sidebar-nav .nav-link.active i {
    color: var(--brand-green);
}

.app-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-navbar {
    background: #ffffff;
    border-bottom: 1px solid var(--brand-border);
    padding: 0.4rem 1.25rem;
    display: flex;
    align-items: center;
    min-height: 44px;
}

.navbar-spacer {
    flex-grow: 1;
}

.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--brand-radius);
    background: transparent;
    color: var(--brand-text);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    background: var(--brand-gray-dark);
    outline: none;
}

.sidebar-toggle:active {
    background: var(--brand-border);
}

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

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

.navbar-user .btn-link {
    color: var(--brand-text);
    font-size: 0.82rem;
    font-weight: 600;
}

.app-content {
    padding: 1.15rem 1.5rem 2rem;
    flex-grow: 1;
}

/* ---------------------------------------------------------------- Page header */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--brand-border);
}

.page-header h4 {
    margin-bottom: 0.15rem;
    font-size: 1.05rem;
}

.page-header p {
    margin-bottom: 0;
    color: var(--brand-text-muted);
    font-size: 0.8rem;
}

.app-content > h4:first-child {
    font-size: 1.05rem;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--brand-border);
}

/* ---------------------------------------------------------------- Cards */

.card {
    border: 1px solid var(--brand-border);
    border-radius: var(--brand-radius);
    box-shadow: none;
}

.card-body {
    padding: 1rem 1.1rem;
}

.card-header {
    background: var(--brand-header-bg);
    font-weight: 700;
    font-size: 0.8rem;
    padding: 0.55rem 1.1rem;
    border-bottom: 1px solid var(--brand-border);
}

/* ---------------------------------------------------------------- Toolbar / filters */

.toolbar-card .card-body {
    padding: 0.9rem 1.1rem;
}

.toolbar-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.85rem;
}

.toolbar-form .field-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.toolbar-form label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--brand-text-muted);
    margin-bottom: 0;
}

.toolbar-form .form-control,
.toolbar-form select.form-control {
    min-width: 190px;
}

/* ---------------------------------------------------------------- Forms */

.form-control,
.form-select,
select.form-control {
    border-color: var(--brand-border);
    font-size: 0.875rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-green);
    box-shadow: 0 0 0 0.2rem rgba(31, 157, 85, 0.14);
}

.form-check-input:checked {
    background-color: var(--brand-green);
    border-color: var(--brand-green);
}

.form-check-input:focus {
    border-color: var(--brand-green);
    box-shadow: 0 0 0 0.2rem rgba(31, 157, 85, 0.14);
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #40453f;
}

/* ---------------------------------------------------------------- Buttons */

.btn {
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--brand-radius);
    padding: 0.38rem 0.8rem;
}

.btn-sm {
    font-size: 0.76rem;
    padding: 0.26rem 0.55rem;
}

.btn-lg {
    font-size: 0.88rem;
    padding: 0.5rem 1rem;
}

.btn-brand,
.btn-primary {
    background-color: var(--brand-green);
    border-color: var(--brand-green);
}

.btn-brand:hover,
.btn-primary:hover,
.btn-brand:focus,
.btn-primary:focus {
    background-color: var(--brand-green-dark);
    border-color: var(--brand-green-dark);
}

.btn-outline-primary {
    color: var(--brand-green-dark);
    border-color: var(--brand-green);
}

.btn-outline-primary:hover {
    background-color: var(--brand-green);
    border-color: var(--brand-green);
}

.btn-outline-secondary {
    color: #454b48;
    border-color: #c9cfcc;
}

.btn-outline-secondary:hover {
    background-color: #454b48;
    border-color: #454b48;
}

/* ---------------------------------------------------------------- Tables (ERP density) */

.app-content .table {
    margin-bottom: 0;
}

.app-content .table thead th {
    background: var(--brand-header-bg);
    text-transform: uppercase;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #5b6360;
    border-bottom: 1px solid var(--brand-border);
    padding: 0.5rem 0.85rem;
    white-space: nowrap;
}

.app-content .table td {
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--brand-border);
    vertical-align: middle;
    color: var(--brand-text);
}

.app-content .table tbody tr:hover {
    background: #fafbfa;
}

.app-content .table tbody tr:last-child td {
    border-bottom: none;
}

/* ---------------------------------------------------------------- Status badges */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.4;
    white-space: nowrap;
}

.status-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge--success {
    background: var(--status-success-bg);
    color: var(--status-success-fg);
}

.status-badge--warning {
    background: var(--status-warning-bg);
    color: var(--status-warning-fg);
}

.status-badge--danger {
    background: var(--status-danger-bg);
    color: var(--status-danger-fg);
}

.status-badge--neutral {
    background: var(--status-neutral-bg);
    color: var(--status-neutral-fg);
}

.toggle-active-btn {
    cursor: pointer;
}

.toggle-active-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.badge-conforme {
    background-color: var(--status-success-bg);
    color: var(--status-success-fg);
}

.badge-nao-conforme {
    background-color: var(--status-danger-bg);
    color: var(--status-danger-fg);
}

/* ---------------------------------------------------------------- Stat cards */

.stat-card {
    background: #ffffff;
    border: 1px solid var(--brand-border);
    border-radius: var(--brand-radius);
    padding: 0.85rem 1rem;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--brand-green);
}

.stat-card .stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.stat-card .stat-label {
    color: var(--brand-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 0.15rem;
}

/* ---------------------------------------------------------------- Nav tabs */

.nav-tabs {
    border-bottom-color: var(--brand-border);
}

.nav-tabs .nav-link {
    color: var(--brand-text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.5rem 0.15rem;
    margin-right: 1.25rem;
    border-radius: 0;
}

.nav-tabs .nav-link:hover {
    border-color: transparent;
    color: var(--brand-text);
}

.nav-tabs .nav-link.active {
    color: var(--brand-green-dark);
    background: transparent;
    border-bottom-color: var(--brand-green);
}

.nav-tabs .nav-link.disabled {
    color: #b7bcb9;
}

/* ---------------------------------------------------------------- Checklist structure */

.area-card .card-header {
    background: var(--brand-header-bg);
    font-weight: 700;
}

.answer-item {
    border-bottom: 1px solid var(--brand-border);
    padding: 1rem 0;
}

.answer-item:last-child {
    border-bottom: none;
}

.answer-choice-btn {
    min-width: 140px;
}

/* ---------------------------------------------------------------- Aplicação (wizard) */

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

.wizard-progress-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--brand-text-muted);
}

.question-card .card-body {
    padding: 1.25rem;
}

.question-area-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--brand-green-dark);
}

.question-text {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
}

.answer-choices .answer-choice-btn {
    min-height: 42px;
    font-size: 0.85rem;
    min-width: 0;
}

.anexo-required-hint {
    font-weight: 700;
}

.review-row {
    border-bottom: 1px solid var(--brand-border);
}

.review-row:last-child {
    border-bottom: none;
}

.review-area-header {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--brand-text-muted);
    margin: 1rem 0 0.35rem;
}

.review-area-header:first-child {
    margin-top: 0;
}

.wizard-nav .btn {
    min-height: 38px;
}

/* ---------------------------------------------------------------- Misc */

.card .table-responsive {
    border-radius: 0 0 var(--brand-radius) var(--brand-radius);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.pagination .page-link {
    font-size: 0.82rem;
    color: var(--brand-text);
}

.pagination .page-item.disabled .page-link {
    color: #9aa19e;
}

@media (min-width: 992px) {
    .sidebar-backdrop {
        display: none !important;
    }
}

@media (max-width: 992px) {
    .app-sidebar {
        position: fixed;
        left: -260px;
        z-index: 1050;
        transition: left 0.2s ease;
    }

    .app-sidebar.show {
        left: 0;
        box-shadow: 2px 0 16px rgba(0, 0, 0, 0.25);
    }
}

@media (max-width: 576px) {
    .question-card .card-body {
        padding: 1.1rem;
    }

    .question-text {
        font-size: 1.05rem;
    }

    .wizard-nav {
        position: sticky;
        bottom: 0;
        background: var(--brand-gray);
        padding: 0.6rem 0;
    }
}
