/* ============================================================
   Sistema de Protocolo — Gabinete Municipal de Cazombo
   Tema institucional — Cores da Bandeira de Angola
   Vermelho #CC092F | Preto #0D0D0D | Amarelo #FFCB00
   ============================================================ */

/* Fonte carregada via <link> no HTML (evita bloqueio por CSP em @import). */

:root {
    --angola-red:       #CC092F;
    --angola-red-dark:  #A00725;
    --angola-red-light: #E8193F;
    --angola-black:     #0D0D0D;
    --angola-black-soft:#1A1A1A;
    --angola-yellow:    #FFCB00;
    --angola-yellow-dark:#D4A900;
    --angola-yellow-light:#FFE566;

    --primary-color:    var(--angola-red);
    --secondary-color:  var(--angola-black);
    --accent-color:     var(--angola-yellow);
    --sidebar-width:    270px;
    --sidebar-bg:       var(--angola-black);
    --text-muted:       #6c757d;
    --bg-body:          #F0F2F5;
    --bg-card:          #FFFFFF;
    --border-light:     #E8ECF0;
    --shadow-sm:        0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:        0 4px 16px rgba(0,0,0,.08);
    --shadow-lg:        0 10px 40px rgba(0,0,0,.12);
    --radius:           10px;
    --radius-lg:        14px;
}

/* ---- Bootstrap overrides ---- */
.btn-primary {
    --bs-btn-bg: var(--angola-red);
    --bs-btn-border-color: var(--angola-red);
    --bs-btn-hover-bg: var(--angola-red-dark);
    --bs-btn-hover-border-color: var(--angola-red-dark);
    --bs-btn-active-bg: var(--angola-red-dark);
    --bs-btn-active-border-color: var(--angola-red-dark);
    --bs-btn-focus-shadow-rgb: 204, 9, 47;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.btn-outline-primary {
    --bs-btn-color: var(--angola-red);
    --bs-btn-border-color: var(--angola-red);
    --bs-btn-hover-bg: var(--angola-red);
    --bs-btn-hover-border-color: var(--angola-red);
    --bs-btn-active-bg: var(--angola-red-dark);
    --bs-btn-active-border-color: var(--angola-red-dark);
}

.btn-warning {
    --bs-btn-bg: var(--angola-yellow);
    --bs-btn-border-color: var(--angola-yellow-dark);
    --bs-btn-color: var(--angola-black);
    --bs-btn-hover-bg: var(--angola-yellow-dark);
    --bs-btn-hover-border-color: var(--angola-yellow-dark);
    --bs-btn-hover-color: var(--angola-black);
    font-weight: 600;
}

.text-primary { color: var(--angola-red) !important; }
.bg-primary   { background-color: var(--angola-red) !important; }
.border-primary { border-color: var(--angola-red) !important; }

.page-link { color: var(--angola-red); }
.page-item.active .page-link {
    background-color: var(--angola-red);
    border-color: var(--angola-red);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--angola-red-light);
    box-shadow: 0 0 0 0.2rem rgba(204, 9, 47, 0.15);
}

/* ---- Base ---- */
body {
    font-family: 'Source Sans 3', 'Segoe UI', Tahoma, sans-serif;
    background-color: var(--bg-body);
    color: #2c3e50;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--angola-red); }
a:hover { color: var(--angola-red-dark); }

/* ---- Faixa da bandeira ---- */
.flag-stripe {
    height: 4px;
    background: linear-gradient(
        to right,
        var(--angola-red) 0%, var(--angola-red) 33.33%,
        var(--angola-black) 33.33%, var(--angola-black) 66.66%,
        var(--angola-yellow) 66.66%, var(--angola-yellow) 100%
    );
    flex-shrink: 0;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--angola-black);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(204,9,47,.25) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255,203,0,.12) 0%, transparent 50%);
    pointer-events: none;
}

.login-page .flag-stripe {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    height: 5px;
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: 24px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 44px 40px 36px;
    box-shadow: var(--shadow-lg);
    border-top: 4px solid var(--angola-red);
}

.login-emblem {
    width: 88px;
    height: 88px;
    margin: 0 auto 16px;
    background: linear-gradient(145deg, var(--angola-black-soft), var(--angola-black));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--angola-yellow);
    box-shadow: 0 4px 20px rgba(255,203,0,.2);
}

.login-logo-img {
    max-width: 100%;
    height: auto;
    max-height: 90px;
    margin: 0 auto 12px;
    display: block;
    object-fit: contain;
}

.login-motto {
    color: var(--angola-black-soft);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.login-emblem i {
    font-size: 2.4rem;
    color: var(--angola-yellow);
}

.login-card h4 {
    color: var(--angola-black);
    font-weight: 700;
    font-size: 1.15rem;
    line-height: 1.4;
}

.login-card .login-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

.login-divider span {
    color: var(--angola-red);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.login-card .input-group-text {
    background: #f8f9fa;
    border-color: var(--border-light);
    color: var(--angola-red);
}

.login-card .form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #495057;
}

.login-footer {
    text-align: center;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.login-footer .flag-mini {
    display: inline-flex;
    gap: 0;
    height: 3px;
    width: 60px;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.login-footer .flag-mini span:nth-child(1) { flex: 1; background: var(--angola-red); }
.login-footer .flag-mini span:nth-child(2) { flex: 1; background: var(--angola-black); }
.login-footer .flag-mini span:nth-child(3) { flex: 1; background: var(--angola-yellow); }

/* ============================================================
   LAYOUT — SIDEBAR
   ============================================================ */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--angola-black-soft) 0%, var(--angola-black) 100%);
    transition: margin-left 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-header {
    padding: 20px 16px 16px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

.sidebar-brand {
    display: block;
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

.sidebar-brand:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(255,203,0,.2);
}

.sidebar-logo-img {
    width: 100%;
    height: auto;
    max-height: 72px;
    object-fit: contain;
    display: block;
}

.sidebar-motto {
    color: var(--angola-yellow);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 4px;
    line-height: 1.3;
}

.sidebar-system-label {
    color: rgba(255,255,255,.45);
    font-size: 0.75rem;
    display: block;
}

.sidebar-emblem {
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
    background: rgba(255,255,255,.05);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--angola-yellow);
}

.sidebar-emblem i {
    font-size: 1.8rem;
    color: var(--angola-yellow);
}

.sidebar-header h6 {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.sidebar-header small {
    color: rgba(255,255,255,.45);
    font-size: 0.78rem;
    letter-spacing: 0.02em;
}

.sidebar .nav {
    padding: 8px 0 16px;
    flex: 1 1 auto;
    min-height: 0;
}

.sidebar-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: scroll;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--angola-yellow) rgba(255, 255, 255, 0.12);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-body::-webkit-scrollbar {
    width: 10px;
}

.sidebar-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-left: 1px solid rgba(255, 255, 255, 0.04);
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(255, 203, 0, 0.9) 0%, rgba(204, 9, 47, 0.75) 100%);
    border-radius: 6px;
    border: 2px solid rgba(13, 13, 13, 0.35);
    min-height: 48px;
}

.sidebar-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #FFCB00 0%, var(--angola-red) 100%);
}

.sidebar-menu {
    padding: 6px 0 12px;
}

.sidebar-nav-label {
    list-style: none;
    padding: 14px 20px 6px;
    margin: 0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 203, 0, 0.55);
    pointer-events: none;
    user-select: none;
}

.sidebar-nav-label:first-child {
    padding-top: 10px;
}

.sidebar-nav-label-audit {
    color: rgba(255, 203, 0, 0.75);
}

.sidebar-nav-label + .nav-item .nav-link,
.sidebar-nav-label + .nav-item + .nav-item .nav-link {
    margin-top: 0;
}

.sidebar .nav-link {
    color: rgba(255,255,255,.72);
    padding: 10px 16px;
    margin: 2px 10px;
    border-radius: 10px;
    border-left: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 1.25;
}

.sidebar .nav-link span {
    flex: 1;
    min-width: 0;
}

.sidebar .nav-link-sub {
    margin-left: 18px;
    margin-right: 10px;
    padding-left: 14px;
    font-size: 0.86rem;
    border-left: 2px solid rgba(255, 203, 0, 0.2);
    border-radius: 0 10px 10px 0;
}

.sidebar .nav-link-sub i {
    font-size: 0.95rem;
    width: 18px;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,.1);
    transform: translateX(2px);
}

.sidebar .nav-link-sub:hover {
    border-left-color: rgba(255, 203, 0, 0.55);
}

.sidebar .nav-link.active {
    color: var(--angola-black);
    background: linear-gradient(135deg, var(--angola-yellow) 0%, #ffe566 100%);
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(255,203,0,.28);
    transform: none;
}

.sidebar .nav-link.active.nav-link-sub {
    border-left-color: var(--angola-red);
}

.sidebar .nav-link i {
    width: 20px;
    font-size: 1.05rem;
    opacity: 0.9;
    flex-shrink: 0;
    text-align: center;
}

.sidebar .nav-link.active i {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer small {
    color: rgba(255,255,255,.3);
    font-size: 0.72rem;
}

/* ============================================================
   CONTENT & NAVBAR
   ============================================================ */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content.expanded {
    margin-left: 0;
}

.top-navbar {
    background: var(--bg-card) !important;
    border-bottom: 1px solid var(--border-light);
    padding: 0;
    min-height: auto;
    box-shadow: var(--shadow-sm);
    flex-direction: column;
    align-items: stretch;
}

.top-navbar-main {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 56px;
    padding: 8px 16px;
    gap: 8px;
}

.top-navbar-search {
    width: 100%;
    padding: 0 16px 12px;
}

.sidebar-toggle-btn {
    padding: 6px 8px !important;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(13, 13, 13, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

body.sidebar-open {
    overflow: hidden;
}

.top-navbar .navbar-brand-text {
    font-weight: 600;
    color: var(--angola-black);
    font-size: 0.95rem;
}

.top-navbar .btn-link {
    color: var(--angola-black) !important;
    text-decoration: none;
}

.top-navbar .btn-link:hover {
    color: var(--angola-red) !important;
}

.navbar-logo-link {
    text-decoration: none;
    background: #fff;
    border-radius: 8px;
    padding: 4px 10px;
    border: 1px solid var(--border-light);
    transition: box-shadow 0.2s;
}

.navbar-logo-link:hover {
    box-shadow: var(--shadow-sm);
}

.navbar-logo {
    height: 36px;
    width: auto;
    object-fit: contain;
    display: block;
}

.top-navbar .nav-icon-btn {
    color: var(--angola-black-soft);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background 0.2s;
}

.top-navbar .nav-icon-btn:hover {
    background: rgba(204,9,47,.06);
    color: var(--angola-red);
}

.user-menu-toggle {
    color: var(--angola-black) !important;
    text-decoration: none !important;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.user-menu-toggle:hover {
    background: rgba(204,9,47,.06);
}

.user-menu-toggle i {
    color: var(--angola-red);
}

main.container-fluid {
    flex: 1;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    margin-bottom: 1.75rem;
}

.page-header h2 {
    color: var(--angola-black);
    font-weight: 700;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-header h2 i {
    color: var(--angola-red);
}

.page-header p.text-muted {
    font-size: 0.925rem;
}

.page-header-accent {
    width: 48px;
    height: 4px;
    background: linear-gradient(to right, var(--angola-red), var(--angola-yellow));
    border-radius: 2px;
    margin-top: 8px;
}

/* ============================================================
   CARDS & STATS
   ============================================================ */
.card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
    padding: 14px 20px;
}

.card-header h5 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--angola-black);
    margin: 0;
}

.card-header h5 i {
    color: var(--angola-red);
    margin-right: 6px;
}

.stat-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    position: relative;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card.stat-total::after    { background: var(--angola-red); }
.stat-card.stat-hoje::after     { background: #28a745; }
.stat-card.stat-pendentes::after{ background: var(--angola-yellow); }
.stat-card.stat-urgentes::after { background: var(--angola-red-dark); }
.stat-card.stat-concluidos::after { background: #17a2b8; }
.stat-card.stat-arquivados::after { background: var(--angola-black-soft); }

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.stat-card .card-body {
    padding: 1.25rem 1.25rem 1.1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--angola-black);
    line-height: 1.1;
}

.stat-card small.text-muted {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-documents th {
    background: linear-gradient(to bottom, #fafbfc, #f3f5f7);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #495057;
    border-bottom: 2px solid var(--border-light);
    padding: 12px 16px;
    white-space: nowrap;
}

.table-documents td {
    padding: 12px 16px;
    vertical-align: middle;
    font-size: 0.9rem;
}

.table-documents tbody tr {
    transition: background 0.15s;
}

.table-documents tbody tr:hover {
    background: rgba(204,9,47,.03);
}

.table-documents a {
    font-weight: 600;
    text-decoration: none;
}

.table-documents a:hover {
    text-decoration: underline;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    padding: 5px 10px;
    border-radius: 6px;
}

/* ============================================================
   FORMS
   ============================================================ */
.form-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.form-section h5 {
    color: var(--angola-black);
    font-weight: 700;
    font-size: 1rem;
    border-bottom: 2px solid var(--angola-yellow);
    padding-bottom: 10px;
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section h5 i {
    color: var(--angola-red);
}

.form-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #495057;
}

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: linear-gradient(to bottom, var(--angola-red), var(--angola-yellow));
    border-radius: 1px;
}

.timeline-item {
    position: relative;
    padding-bottom: 22px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -25px;
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--angola-red);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--angola-red);
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    border-left: 4px solid;
}

.alert-success { border-left-color: #28a745; }
.alert-danger  { border-left-color: var(--angola-red); }
.alert-warning { border-left-color: var(--angola-yellow-dark); }
.alert-info    { border-left-color: #17a2b8; }

/* ============================================================
   NOTIFICATIONS
   ============================================================ */
.notification-dropdown {
    width: 340px;
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius);
}

.notification-dropdown .dropdown-item.fw-bold {
    border-left: 3px solid var(--angola-yellow);
}

/* ============================================================
   PRIORITY ROWS
   ============================================================ */
.priority-muito_urgente {
    border-left: 4px solid var(--angola-red) !important;
    background: rgba(204,9,47,.02) !important;
}

.priority-urgente {
    border-left: 4px solid var(--angola-yellow) !important;
    background: rgba(255,203,0,.04) !important;
}

/* ============================================================
   BUTTON GROUP FILTERS
   ============================================================ */
.btn-group .btn-outline-secondary.active,
.btn-group .btn-outline-primary.active {
    background-color: var(--angola-red);
    border-color: var(--angola-red);
    color: #fff;
}

.btn-group .btn-outline-primary {
    font-size: 0.82rem;
    font-weight: 500;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-header {
    background: var(--angola-black-soft);
    color: #fff;
    border-bottom: 3px solid var(--angola-yellow);
}

.modal-header .btn-close {
    filter: invert(1);
}

.modal-title {
    font-weight: 600;
}

/* ============================================================
   LIST GROUP
   ============================================================ */
.list-group-item-action:hover {
    background: rgba(204,9,47,.04);
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    .sidebar, .top-navbar, .no-print, .btn, .pagination, .flag-stripe {
        display: none !important;
    }
    .content { margin-left: 0 !important; }
    body { background: white; }
}

/* ============================================================
   RESPONSIVE — Todos os dispositivos
   Breakpoints: 576 (sm), 768 (md), 992 (lg), 1200 (xl)
   ============================================================ */

/* Tablet e abaixo */
@media (max-width: 991.98px) {
    .top-navbar-main {
        padding: 8px 12px;
    }

    .navbar-brand-text {
        font-size: 0.85rem !important;
        max-width: 180px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .page-content {
        padding: 1rem !important;
    }

    .stat-card .card-body {
        padding: 1rem;
    }

    .stat-card h3 {
        font-size: 1.5rem;
    }

    .form-section {
        padding: 1.25rem;
    }

    .card .card-body {
        padding: 1rem;
    }

    .modal-dialog {
        margin: 0.75rem;
    }

    .notification-dropdown {
        width: min(320px, calc(100vw - 24px));
    }
}

/* Mobile */
@media (max-width: 767.98px) {
    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        width: min(var(--sidebar-width), 88vw);
        z-index: 1001;
    }

    .sidebar.show {
        margin-left: 0;
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
    }

    .sidebar.show.collapsed {
        margin-left: 0;
    }

    .sidebar.collapsed:not(.show) {
        margin-left: calc(-1 * var(--sidebar-width));
    }

    .content {
        margin-left: 0 !important;
        width: 100%;
    }

    .content.expanded {
        margin-left: 0 !important;
    }

    .top-navbar-main {
        min-height: 52px;
    }

    .navbar-brand-text {
        display: none !important;
    }

    .navbar-actions .user-menu-toggle span {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .page-header {
        margin-bottom: 1.25rem;
    }

    .page-header h2 {
        font-size: 1.25rem;
    }

    .page-header .btn,
    .page-header .btn-group {
        width: 100%;
    }

    .page-header.d-flex .btn-group,
    .page-header.d-flex > .btn {
        flex: 1 1 auto;
    }

    .page-header.d-flex {
        flex-direction: column;
        align-items: stretch !important;
    }

    .page-header.d-flex > *:last-child:not(h2):not(p):not(.page-header-accent) {
        width: 100%;
    }

    .page-header .d-flex.gap-2 {
        flex-wrap: wrap;
    }

    .page-header .d-flex.gap-2 .btn {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 120px;
    }

    .stat-card {
        margin-bottom: 0;
    }

    .table-responsive {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive::after {
        content: '';
        display: block;
        height: 1px;
    }

    .table {
        font-size: 0.875rem;
    }

    .table th,
    .table td {
        white-space: nowrap;
    }

    .table .btn-group,
    .table .btn-sm {
        flex-wrap: nowrap;
    }

    .table-actions-cell {
        min-width: 120px;
    }

    .btn-group-responsive {
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
    }

    .btn-group-responsive .btn {
        flex: 1 1 auto;
    }

    .form-section .row > [class*="col-"] {
        margin-bottom: 0.25rem;
    }

    .form-actions,
    .d-flex.gap-2.justify-content-end,
    .card-footer.d-flex {
        flex-direction: column;
    }

    .form-actions .btn,
    .card-footer .btn {
        width: 100%;
    }

    .modal-dialog {
        max-width: calc(100vw - 1rem);
    }

    .modal-fullscreen-sm-down {
        margin: 0;
        max-width: 100%;
    }

    .toast-container {
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
    }

    .toast-container .toast {
        width: 100%;
        max-width: 100%;
    }

    .search-box-mobile .search-results {
        max-height: 50vh;
    }

    .navbar-search {
        max-width: 100%;
    }

    .search-results {
        max-height: 60vh;
        overflow-y: auto;
    }

    .signature-pad-box {
        min-height: 140px;
    }

    .signature-canvas {
        height: 140px !important;
    }

    .documento-detalhes .col-md-6,
    .documento-detalhes .col-lg-4,
    .page-content .card-body > .row > [class*="col-md-"],
    .page-content .card-body > .row > [class*="col-lg-"] {
        margin-bottom: 0.75rem;
    }

    .login-card {
        padding: 28px 20px;
        margin: 16px;
        width: calc(100% - 32px);
        max-width: 420px;
    }

    .login-page {
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }

    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }

    .page-link {
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar .nav-link {
        min-height: 44px;
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .top-navbar .nav-icon-btn,
    .user-menu-toggle {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* Telefone pequeno */
@media (max-width: 575.98px) {
    .page-content {
        padding: 0.75rem !important;
    }

    .top-navbar-main {
        padding: 6px 10px;
        gap: 4px;
    }

    .top-navbar-search {
        padding: 0 10px 10px;
    }

    .stat-card h3 {
        font-size: 1.35rem;
    }

    .stat-card .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .card-header h5,
    .form-section h5 {
        font-size: 0.95rem;
    }

    .table {
        font-size: 0.8125rem;
    }

    .badge {
        font-size: 0.7rem;
    }

    .dropdown-menu {
        max-width: calc(100vw - 24px);
    }

    .navbar-actions .user-menu-toggle .bi-person-circle {
        margin-right: 0 !important;
    }

    .navbar-actions .user-menu-toggle span {
        display: none !important;
    }

    .login-card {
        padding: 24px 16px;
    }

    .login-card h1 {
        font-size: 1.35rem;
    }
}

/* Desktop largo */
@media (min-width: 992px) {
    .top-navbar-main {
        padding: 0 24px;
        min-height: 62px;
    }

    .navbar-search {
        margin-left: 1rem;
        margin-right: auto;
    }
}

@media (min-width: 1200px) {
    .page-content {
        padding: 1.5rem 2rem !important;
    }
}

/* ============================================================
   DINÂMICO — Animações, pesquisa, toasts, loader
   ============================================================ */

.page-loader {
    position: fixed;
    inset: 0;
    background: var(--bg-body);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.35s ease, visibility 0.35s;
}

.page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border-light);
    border-top-color: var(--angola-red);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.page-content {
    animation: fadeSlideIn 0.45s ease-out;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeSlideIn 0.5s ease-out both;
}

.animate-delay-1 { animation-delay: 0.05s; }
.animate-delay-2 { animation-delay: 0.12s; }
.animate-delay-3 { animation-delay: 0.2s; }
.animate-delay-4 { animation-delay: 0.28s; }

/* Pesquisa rápida na navbar */
.navbar-search {
    flex: 1;
    max-width: 340px;
}

.search-box {
    position: relative;
}

.search-box > .bi-search {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.search-box input {
    padding-left: 32px;
    border-radius: 20px;
    background: var(--bg-body);
    border-color: var(--border-light);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.search-box input:focus {
    background: #fff;
    box-shadow: 0 0 0 3px rgba(204, 9, 47, 0.12);
}

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1050;
}

.search-result-item {
    display: block;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}

.search-result-item:last-child { border-bottom: none; }

.search-result-item:hover {
    background: rgba(204, 9, 47, 0.05);
    color: inherit;
}

.search-result-item strong {
    color: var(--angola-red);
    display: block;
}

.search-result-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.search-result-item small {
    display: block;
    color: #6c757d;
    margin-top: 2px;
}

.search-loading,
.search-empty {
    padding: 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Relógio navbar */
.navbar-clock {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    padding: 4px 10px;
    background: var(--bg-body);
    border-radius: 6px;
}

/* Badge notificações */
.badge-pulse {
    animation: badgePulse 0.6s ease;
}

@keyframes badgePulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-50%, -50%) scale(1.25); }
}

.notification-dropdown .dropdown-item.unread {
    border-left: 3px solid var(--angola-yellow);
}

/* Linhas clicáveis */
tr[data-href] {
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

tr[data-href]:hover {
    background: rgba(204, 9, 47, 0.05) !important;
}

tr[data-href]:active {
    transform: scale(0.998);
}

/* Filtro de tabela */
.table-filter-input {
    border-radius: 20px;
    background: var(--bg-body);
}

.table-filter-input:focus {
    background: #fff;
}

/* Toasts */
.toast-container .toast {
    min-width: 280px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.35s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* Botão refresh */
#refreshStats .bi-arrow-clockwise {
    transition: transform 0.4s ease;
}

#refreshStats:not(:disabled):hover .bi-arrow-clockwise {
    transform: rotate(180deg);
}

#refreshStats:disabled .bi-arrow-clockwise {
    animation: spin 0.8s linear infinite;
}

/* Cards com entrada suave nos gráficos */
.card canvas {
    animation: fadeSlideIn 0.6s ease-out 0.3s both;
}

/* Assinatura electrónica */
.signature-pad-box {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius);
    background: #fff;
    position: relative;
    overflow: hidden;
}

.signature-pad-box:hover {
    border-color: rgba(204, 9, 47, 0.35);
}

.signature-canvas {
    display: block;
    width: 100%;
    cursor: crosshair;
    touch-action: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 39px,
        rgba(0, 0, 0, 0.04) 39px,
        rgba(0, 0, 0, 0.04) 40px
    );
}

.signature-pad-actions {
    padding: 8px 10px;
    border-top: 1px solid var(--border-light);
    background: #fafbfc;
}

.signature-pad-wrapper.signature-error .signature-pad-box {
    border-color: var(--angola-red);
    box-shadow: 0 0 0 3px rgba(204, 9, 47, 0.12);
}

.signature-preview-box {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px;
    background: #fafbfc;
    text-align: center;
}

.signature-preview-box img {
    max-height: 80px;
    max-width: 100%;
}

.assinatura-impressao {
    text-align: center;
    min-height: 90px;
}

.assinatura-impressao img {
    max-height: 70px;
    max-width: 220px;
    display: block;
    margin: 0 auto 6px;
}

.badge-assinatura-eletronica {
    display: inline-block;
    font-size: 0.65rem;
    background: rgba(204, 9, 47, 0.1);
    color: var(--angola-red);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.assinatura-vazia hr {
    margin-top: 40px;
}

.despacho-assinatura img {
    max-height: 60px;
    margin-top: 8px;
}

/* Mostrar/ocultar palavra-passe — estilo institucional Cazombo */
.password-input-group {
    flex-wrap: nowrap;
    align-items: stretch;
    overflow: visible;
}

.password-field {
    position: relative;
    overflow: visible;
}

.password-field .form-control {
    padding-right: 48px;
}

.password-input-group .form-control {
    border-right: none;
    min-width: 0;
}

.password-input-group .password-toggle {
    border: 1px solid #ced4da;
    border-left: none;
}

.password-toggle {
    flex-shrink: 0;
    width: 44px;
    min-width: 44px;
    height: auto;
    min-height: 38px;
    padding: 0;
    margin: 0;
    border: none;
    background: linear-gradient(180deg, #fafbfc 0%, #f0f2f5 100%);
    color: #495057;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    transition: color 0.2s, background 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.password-field .password-toggle {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    min-height: 38px;
    border-radius: 10px;
    border: 1px solid #e2e6ea;
    box-shadow: 0 1px 2px rgba(13, 13, 13, 0.04);
}

.input-group .password-toggle {
    border-radius: 0 0.375rem 0.375rem 0;
}

.password-toggle-icon {
    position: relative;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(13, 13, 13, 0.06);
    transition: background 0.2s, transform 0.2s;
}

.password-toggle-icon i {
    font-size: 1.1rem;
    line-height: 1;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.password-toggle:hover {
    color: var(--angola-red);
    background: linear-gradient(180deg, #fff 0%, #fff5f6 100%);
    border-color: rgba(204, 9, 47, 0.25);
}

.password-toggle:hover .password-toggle-icon {
    background: rgba(204, 9, 47, 0.1);
    transform: scale(1.06);
}

.password-toggle.is-visible {
    color: var(--angola-red);
    background: linear-gradient(180deg, #fff8f0 0%, #fff3e0 100%);
    border-color: rgba(255, 203, 0, 0.45);
    box-shadow: inset 0 0 0 1px rgba(255, 203, 0, 0.2);
}

.password-toggle.is-visible .password-toggle-icon {
    background: linear-gradient(135deg, rgba(204, 9, 47, 0.12) 0%, rgba(255, 203, 0, 0.18) 100%);
}

.password-toggle.is-visible .password-toggle-icon i {
    color: var(--angola-red);
}

.password-toggle.is-visible .password-toggle-icon::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 2px;
    background: var(--angola-red);
    border-radius: 1px;
    transform: rotate(-35deg);
    opacity: 0.85;
}

.password-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(204, 9, 47, 0.18);
}

.password-toggle.password-toggle-pulse .password-toggle-icon {
    animation: passwordTogglePulse 0.28s ease;
}

@keyframes passwordTogglePulse {
    0% { transform: scale(1); }
    45% { transform: scale(1.14); }
    100% { transform: scale(1); }
}

/* Login — tema escuro */
.login-card .password-input-group .form-control {
    border-right: none;
}

.login-card .input-group .password-toggle {
    background: linear-gradient(180deg, #f8f9fa 0%, #eef1f4 100%);
    border-color: var(--border-light);
    color: var(--angola-red);
}

.login-card .password-toggle .password-toggle-icon {
    background: rgba(204, 9, 47, 0.08);
}

.login-card .password-toggle .password-toggle-icon i {
    color: var(--angola-red);
}

.login-card .password-toggle:hover {
    color: #fff;
    background: linear-gradient(180deg, rgba(204, 9, 47, 0.35) 0%, rgba(204, 9, 47, 0.2) 100%);
    border-color: rgba(255, 203, 0, 0.35);
}

.login-card .password-toggle:hover .password-toggle-icon {
    background: rgba(255, 203, 0, 0.2);
}

.login-card .password-toggle.is-visible {
    color: #FFCB00;
    background: linear-gradient(180deg, rgba(204, 9, 47, 0.4) 0%, rgba(13, 13, 13, 0.3) 100%);
    border-color: rgba(255, 203, 0, 0.5);
    box-shadow: inset 0 0 0 1px rgba(255, 203, 0, 0.15);
}

.login-card .password-toggle.is-visible .password-toggle-icon {
    background: rgba(255, 203, 0, 0.22);
}

.login-card .password-toggle.is-visible .password-toggle-icon i {
    color: var(--angola-red);
}

.login-card .password-toggle.is-visible .password-toggle-icon::after {
    background: var(--angola-yellow);
}

