:root {
    /* Paleta Primordial — cores da logo de login */
    --brand-light: #63B3D6;
    --brand-medium: #46A1C9;
    --brand-primary: #126381;
    --brand-dark: #0E5268;
    --brand-deep: #0A3D4F;

    --sidebar-width: 268px;
    --navbar-height: 64px;
    --primary: var(--brand-primary);
    --primary-hover: var(--brand-dark);
    --primary-light: var(--brand-medium);
    --primary-accent: var(--brand-light);
    --primary-soft: rgba(18, 99, 129, 0.1);
    --primary-soft-strong: rgba(18, 99, 129, 0.18);
    --primary-border: rgba(18, 99, 129, 0.22);
    --primary-focus: rgba(70, 161, 201, 0.55);
    --primary-shadow: rgba(18, 99, 129, 0.22);
    --success: #1F9D6A;
    --danger: #D64545;
    --warning: #E6A023;
    --bg-body: #EBF5F9;
    --bg-card: #ffffff;
    --bg-muted: #F2F9FC;
    --text-primary: #124656;
    --text-secondary: #3D7285;
    --text-muted: #6A96A8;
    --border-color: rgba(18, 99, 129, 0.12);
    --sidebar-bg: var(--brand-deep);
    --sidebar-bg-end: var(--brand-primary);
    --sidebar-bg-hover: rgba(99, 179, 214, 0.1);
    --sidebar-text: #B8D9E8;
    --sidebar-active: var(--brand-medium);
    --shadow-sm: 0 1px 2px rgba(14, 82, 104, 0.07);
    --shadow-md: 0 8px 24px rgba(14, 82, 104, 0.12);
    --radius-md: 0.875rem;
    --radius-lg: 1rem;
    --status-active: var(--success);
    --status-pending: #6A96A8;
    --status-deferred: var(--brand-medium);
    --status-rejected: var(--danger);
    --status-requirement: var(--warning);
    --status-archived: #3D7285;

    /* Bootstrap */
    --bs-primary: var(--brand-primary);
    --bs-primary-rgb: 18, 99, 129;
    --bs-link-color: var(--brand-primary);
    --bs-link-hover-color: var(--brand-dark);
    --bs-body-bg: var(--bg-body);
    --bs-body-color: var(--text-primary);
    --bs-border-color: var(--border-color);
    --bs-secondary-color: var(--text-secondary);
    --bs-tertiary-color: var(--text-muted);
}

[data-bs-theme="dark"] {
    --bg-body: #0A3D4F;
    --bg-card: #0E5268;
    --bg-muted: #0C465A;
    --text-primary: #EBF5F9;
    --text-secondary: #B8D9E8;
    --text-muted: #6A96A8;
    --border-color: rgba(99, 179, 214, 0.14);
    --sidebar-bg: #082F3D;
    --sidebar-bg-end: #0A3D4F;
    --primary-soft: rgba(99, 179, 214, 0.12);
    --primary-soft-strong: rgba(99, 179, 214, 0.2);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --bs-body-bg: var(--bg-body);
    --bs-body-color: var(--text-primary);
    --bs-border-color: var(--border-color);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 0.9375rem;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-end) 100%);
    z-index: 1040;
    transition: transform 0.3s ease;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.sidebar-brand {
    padding: 1.15rem 1.25rem;
    display: block;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-decoration: none;
}

.sidebar-brand-logo {
    max-width: 100%;
}

.brand-logo {
    display: flex;
    align-items: center;
}

.brand-logo img {
    display: block;
    max-width: 100%;
    height: auto;
}

.brand-logo--internal {
    width: 100%;
}

.brand-logo--internal img {
    width: 100%;
    max-height: 54px;
    object-fit: contain;
    object-position: left center;
    mix-blend-mode: screen;
}

.brand-logo--horizontal,
.brand-logo--stacked {
    justify-content: center;
}

.brand-logo--horizontal img {
    max-height: 56px;
}

.brand-logo--stacked img {
    max-height: 130px;
}

.auth-shell {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    overflow: hidden;
    border-radius: 1.25rem;
    box-shadow: var(--shadow-md);
}

.auth-brand {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 1.5rem 1.25rem 1.25rem;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
}

.auth-login-logo {
    display: block;
    width: 100%;
    max-width: 220px;
    height: auto;
}

.auth-card {
    background: var(--bg-card);
    padding: 2rem 2.5rem 2.5rem;
    width: 100%;
    box-shadow: none;
    border-radius: 0;
    margin-top: 0;
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-medium));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.25rem;
    box-shadow: 0 8px 20px var(--primary-shadow);
}

.sidebar-nav { padding: 1rem 0.85rem 1.5rem; }

.sidebar-section {
    padding: 0.35rem 0.85rem;
    margin-top: 0.75rem;
    margin-bottom: 0.35rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.8rem 0.95rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0.75rem;
    margin-bottom: 0.2rem;
    transition: all 0.2s ease;
    font-weight: 500;
}

.sidebar-nav .nav-link i { width: 1.25rem; font-size: 1.05rem; }

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-bg-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: linear-gradient(90deg, var(--primary-soft-strong), var(--primary-soft));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--sidebar-active);
}

.sidebar-divider {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin: 1rem 0.85rem;
}

.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 61, 79, 0.45);
    z-index: 1035;
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
}

body.sidebar-collapsed .main-content {
    margin-left: 0;
}

body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.app-main { padding: 1.5rem; }

.app-container { max-width: 1440px; margin: 0 auto; }

.top-navbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    min-height: var(--navbar-height);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1030;
}

[data-bs-theme="dark"] .top-navbar { background: rgba(31, 41, 55, 0.92); }

.sidebar-toggle,
.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.sidebar-toggle:hover,
.theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary-border);
    background: var(--primary-soft);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.75rem 0.35rem 0.35rem;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-card);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.navbar-user.dropdown-toggle::after {
    margin-left: 0.35rem;
}

.top-navbar .dropdown-menu {
    min-width: 220px;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    padding: 0.5rem;
}

.navbar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-medium));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.navbar-user-name { font-size: 0.875rem; font-weight: 600; }
.navbar-user-role { font-size: 0.75rem; color: var(--text-muted); }

.page-header-pro { margin-bottom: 1.5rem; }

.page-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.page-breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.page-breadcrumb a:hover { color: var(--primary); }
.page-breadcrumb-sep { font-size: 0.7rem; }

.page-title {
    font-size: 1.625rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.page-subtitle { margin-top: 0.35rem; color: var(--text-muted); }
.page-actions .btn { border-radius: 0.75rem; }

.card,
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.form-card { overflow: hidden; }

.form-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-muted);
}

.form-card-header h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.form-card-header p { margin: 0.25rem 0 0; color: var(--text-muted); font-size: 0.875rem; }
.form-card-body { padding: 1.5rem; }

.form-section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0.5rem 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.card-header h5 { font-size: 1rem; font-weight: 700; }
.card-body { padding: 1.25rem; }

.form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
}

.form-control,
.form-select {
    border-radius: 0.75rem;
    border-color: var(--border-color);
    padding: 0.7rem 0.95rem;
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: none;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-focus);
    box-shadow: 0 0 0 0.2rem var(--primary-soft);
}

.input-group-pro { position: relative; }

.input-group-pro .input-icon {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    z-index: 4;
}

.input-group-pro .form-control { padding-left: 2.6rem; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-muted);
}

.switch-field {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-muted);
    cursor: pointer;
    user-select: none;
    margin: 0;
    height: 100%;
}

.switch-field:hover { border-color: var(--primary-border); }
.switch-field-input { position: absolute; opacity: 0; pointer-events: none; }

.switch-field-track {
    position: relative;
    width: 46px;
    min-width: 46px;
    height: 26px;
    border-radius: 999px;
    background: rgba(18, 99, 129, 0.18);
    transition: background 0.2s ease;
}

.switch-field-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    transition: transform 0.2s ease;
}

.switch-field-input:checked + .switch-field-track {
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-medium));
}

.switch-field-input:checked + .switch-field-track .switch-field-thumb {
    transform: translateX(20px);
}

.switch-field-copy { display: flex; flex-direction: column; gap: 0.15rem; }
.switch-field-title { font-size: 0.9375rem; color: var(--text-primary); }
.switch-field-hint,
.switch-field-status { font-size: 0.8125rem; color: var(--text-muted); }

.switch-field-input:not(:checked) ~ .switch-field-copy .switch-field-status {
    color: var(--danger);
}

.btn {
    border-radius: 0.75rem;
    font-weight: 600;
    padding: 0.625rem 1.1rem;
}

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8125rem;
    border-radius: 0.5rem;
}

.table > :not(caption) > * > * {
    padding: 0.75rem 1rem;
    border-bottom-color: var(--border-color);
    vertical-align: middle;
}

.table .btn-sm {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.table .btn-sm i {
    font-size: 0.875rem;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-medium));
    border: none;
    box-shadow: 0 8px 18px var(--primary-shadow);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--brand-dark), var(--brand-primary));
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-bg: var(--brand-primary);
    --bs-btn-hover-border-color: var(--brand-primary);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-color: var(--brand-primary);
    --bs-btn-disabled-border-color: var(--brand-primary);
}

.btn-light {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn[disabled] { cursor: wait; opacity: 0.88; }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    height: 100%;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card-link:hover {
    border-color: color-mix(in srgb, var(--brand-medium) 45%, var(--border-color));
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    color: inherit;
}

.stat-card-link .stat-card-arrow {
    color: var(--text-muted);
    font-size: 1rem;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.stat-card-link:hover .stat-card-arrow {
    opacity: 1;
    transform: translateX(0);
    color: var(--brand-medium);
}

.stat-info-btn {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    padding: 0;
    line-height: 1;
    font-size: 0.8125rem;
    opacity: 0.65;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.stat-info-btn:hover,
.stat-info-btn:focus {
    opacity: 1;
    color: var(--brand-medium);
}

.stat-tooltip .tooltip-inner {
    max-width: 260px;
    text-align: left;
    font-size: 0.8125rem;
    line-height: 1.45;
    padding: 0.5rem 0.65rem;
}

.dashboard-legend {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    overflow: hidden;
}

.dashboard-legend-toggle {
    width: 100%;
    border: 0;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.dashboard-legend-toggle:hover {
    color: var(--brand-medium);
    background: color-mix(in srgb, var(--brand-medium) 6%, transparent);
}

.dashboard-legend-chevron {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.dashboard-legend-toggle[aria-expanded="true"] .dashboard-legend-chevron {
    transform: rotate(180deg);
}

.dashboard-legend-body {
    padding: 1rem 1rem 1rem;
    border-top: 1px solid var(--border-color);
}

.dashboard-legend-item {
    height: 100%;
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--brand-medium) 4%, var(--bg-card));
    border: 1px solid var(--border-color);
}

.dashboard-legend-term {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.dashboard-legend-desc {
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.35rem;
}

.stat-icon-archived {
    background: var(--status-archived);
}

.stat-icon-active { background: var(--status-active); }
.stat-icon-pending { background: var(--status-pending); }
.stat-icon-deferred { background: var(--status-deferred); }
.stat-icon-rejected { background: var(--status-rejected); }
.stat-icon-requirement { background: var(--status-requirement); color: #212529; }

.stat-value {
    display: block;
    font-size: 1.625rem;
    font-weight: 700;
    line-height: 1;
    margin-top: 0.25rem;
}

.stat-label {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.dashboard-chart-wrap {
    position: relative;
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
    aspect-ratio: 1;
}

.dashboard-chart-empty {
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    font-size: 0.9375rem;
}

.table thead th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    background: var(--bg-muted);
}

.table-hover > tbody > tr:hover > * {
    background: var(--primary-soft);
}

.table-card .card-body { padding: 0; }

.attachment-upload-form {
    padding: 1.25rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-muted);
}

.attachment-upload-hint {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.attachment-upload-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.attachment-preview-body {
    min-height: 60vh;
    background: var(--bg-muted);
    border-radius: 0.75rem;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-preview-loading,
.attachment-preview-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 50vh;
    color: var(--text-muted);
    text-align: center;
}

.attachment-preview-error { color: var(--danger); }

.attachment-preview-frame {
    width: 100%;
    height: 70vh;
    border: 0;
    border-radius: 0.5rem;
    background: #fff;
    align-self: stretch;
}

.attachment-preview-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 0.5rem;
    object-fit: contain;
    background: #fff;
    display: block;
    margin: 0 auto;
    box-shadow: var(--shadow-sm);
}

.badge { border-radius: 999px; padding: 0.4em 0.75em; font-weight: 600; }

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at top right, rgba(110, 200, 240, 0.28), transparent 32%),
        linear-gradient(135deg, var(--brand-deep) 0%, var(--brand-primary) 55%, var(--brand-medium) 100%);
    padding: 1.5rem;
}

.bg-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-medium)) !important;
}

.text-primary {
    color: var(--brand-primary) !important;
}

.stat-icon.bg-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-medium)) !important;
}

.auth-logo-wrap {
    width: 100%;
    max-width: 280px;
    margin: 0 auto 1rem;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.timeline-date {
    min-width: 80px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Process status badges */
.badge.status-active { background-color: var(--status-active); color: #fff; }
.badge.status-deferred { background-color: var(--status-deferred); color: #fff; }
.badge.status-rejected { background-color: var(--status-rejected); color: #fff; }
.badge.status-requirement { background-color: var(--status-requirement); color: #212529; }
.badge.status-archived { background-color: var(--status-archived); color: #fff; }
.badge.status-pending { background-color: var(--status-pending); color: #fff; }

.log-message-cell {
    max-width: 520px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
    }

    .app-main { padding: 1rem; }
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
}
