/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --purple: #7c3aed;
    --purple-light: #ede9fe;
    --pink: #db2777;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --sidebar-width: 240px;
    --sidebar-collapsed: 64px;
    --topbar-height: 60px;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}
html { font-size: 14px; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--gray-100); color: var(--gray-800); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    position: relative;
    background-color: #0d1b2e;
    background-image:
        radial-gradient(ellipse at 25% 30%, rgba(37,99,235,0.18) 0%, transparent 55%),
        radial-gradient(ellipse at 75% 70%, rgba(30,58,138,0.22) 0%, transparent 55%),
        linear-gradient(160deg, #0a1628 0%, #102040 50%, #0d1b2e 100%);
}
.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 59px, rgba(255,255,255,0.018) 59px, rgba(255,255,255,0.018) 60px),
        repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(255,255,255,0.018) 59px, rgba(255,255,255,0.018) 60px);
    pointer-events: none;
}
.login-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem 2.5rem 2rem;
    width: 100%;
    box-shadow: 0 24px 64px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.06);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo { max-height: 60px; max-width: 200px; object-fit: contain; margin-bottom: .9rem; display: block; margin-left: auto; margin-right: auto; }
.login-icon-wrap { width: 68px; height: 68px; background: linear-gradient(135deg, #1e3a8a, #2563eb); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto .9rem; font-size: 1.8rem; color: #fff; box-shadow: 0 4px 16px rgba(37,99,235,0.35); }
.login-title { font-size: 1.45rem; font-weight: 700; color: #1e293b; margin-bottom: .25rem; letter-spacing: -.01em; }
.login-subtitle { font-size: .8rem; color: #94a3b8; letter-spacing: .06em; text-transform: uppercase; font-weight: 500; }
.login-form .form-group { margin-bottom: 1.1rem; }
.login-form label { display: block; font-weight: 600; margin-bottom: .35rem; color: #475569; font-size: .82rem; letter-spacing: .02em; text-transform: uppercase; text-align: center; }
.login-form input { display: block; width: 100%; padding: .72rem 1rem; border: 1.5px solid #e2e8f0; border-radius: 8px; font-size: .95rem; background: #f8fafc; color: #1e293b; transition: border-color .18s, box-shadow .18s, background .18s; }
.login-form input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); background: #fff; }
.login-actions { text-align: center; margin-top: 1.6rem; }
.btn-login { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; background: linear-gradient(135deg, #1d3a8a, #2563eb); color: #fff; border: none; padding: .72rem 2.4rem; border-radius: 8px; font-size: .92rem; font-weight: 600; cursor: pointer; transition: opacity .18s, transform .12s, box-shadow .18s; letter-spacing: .01em; min-width: 140px; box-shadow: 0 4px 14px rgba(37,99,235,0.3); }
.btn-login:hover { opacity: .92; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(37,99,235,0.38); }
.btn-login:active { transform: translateY(0); opacity: 1; }
.login-recovery { text-align: center; margin-top: 1.2rem; font-size: .83rem; }
.login-recovery a { color: #2563eb; text-decoration: none; font-weight: 500; }
.login-recovery a:hover { text-decoration: underline; }
.login-messages { margin-bottom: 1.2rem; }
.login-help-text { font-size: .84rem; color: #64748b; text-align: center; margin-bottom: 1.4rem; line-height: 1.6; }
.login-footer { margin-top: 1.4rem; color: rgba(255,255,255,0.28); font-size: .75rem; text-align: center; letter-spacing: .02em; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar { position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh; background: var(--gray-900); color: #fff; display: flex; flex-direction: column; z-index: 100; transition: width .25s ease; overflow: hidden; }
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar-header { display: flex; align-items: center; justify-content: center; gap: .75rem; padding: 1.2rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-header .logo-icon { font-size: 1.5rem; color: var(--primary-light); min-width: 28px; text-align: center; }
.sidebar-title { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.collapsed .sidebar-title { display: none; }
.nav-list, .sidebar-menu { list-style: none; flex: 1; padding: .5rem 0; overflow-y: auto; }
.nav-list li a, .sidebar-menu li a { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.2rem; color: var(--gray-300); transition: all .15s; white-space: nowrap; border-left: 3px solid transparent; }
.nav-list li a:hover, .sidebar-menu li a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-list li a.active, .sidebar-menu li a.active { background: rgba(37,99,235,.25); color: #fff; border-left-color: var(--primary); }
.nav-list li a i, .sidebar-menu li a i { width: 20px; text-align: center; font-size: 1rem; min-width: 20px; }
.collapsed .nav-list li a span, .collapsed .sidebar-menu li a span { display: none; }
.nav-badge { background: var(--danger); color: #fff; font-size: .7rem; padding: 2px 7px; border-radius: 10px; margin-left: auto; }
.sidebar-footer { padding: 1rem 1.2rem; border-top: 1px solid rgba(255,255,255,.1); }
.user-info { display: flex; align-items: center; gap: .5rem; color: var(--gray-300); font-size: .85rem; margin-bottom: .5rem; }
.user-info i { font-size: 1.3rem; }
.collapsed .user-info span, .collapsed .sidebar-footer .logout-btn span { display: none; }
.perfil-badge { background: rgba(37,99,235,.3); padding: 1px 6px; border-radius: 4px; font-size: .7rem; color: var(--primary-light); }
.logout-btn { display: flex; align-items: center; gap: .5rem; color: var(--gray-400); font-size: .85rem; padding: .4rem 0; }
.logout-btn:hover { color: var(--danger); text-decoration: none; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content, .content { margin-left: var(--sidebar-width); min-height: 100vh; transition: margin-left .25s ease; }
.sidebar.collapsed ~ .main-content, .sidebar.collapsed ~ .content { margin-left: var(--sidebar-collapsed); }
.topbar { position: sticky; top: 0; z-index: 50; height: var(--topbar-height); background: #fff; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem; box-shadow: var(--shadow); }
.menu-toggle { background: none; border: none; font-size: 1.2rem; color: var(--gray-600); cursor: pointer; padding: .5rem; border-radius: 6px; }
.menu-toggle:hover { background: var(--gray-100); }
.page-title { flex: 1; font-size: 1.3rem; font-weight: 700; color: var(--gray-800); }
.topbar-actions { display: flex; gap: .5rem; }
.topbar-btn { position: relative; background: none; border: none; font-size: 1.1rem; color: var(--gray-500); padding: .5rem; border-radius: 8px; cursor: pointer; }
.topbar-btn:hover { background: var(--gray-100); color: var(--gray-800); text-decoration: none; }
.topbar-badge { position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff; font-size: .6rem; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.content-area, .page-content { padding: 1.5rem; }

/* ── Sidebar extras ──────────────────────────────────────── */
.sidebar-header i { font-size: 1.5rem; color: var(--primary-light); min-width: 28px; text-align: center; }
.sidebar-header span { font-size: 1rem; font-weight: 700; white-space: nowrap; }
.badge-notif { background: var(--danger); color: #fff; font-size: .65rem; padding: 2px 6px; border-radius: 10px; margin-left: auto; }
.notif-icon { position: relative; font-size: 1.2rem; color: var(--gray-500); padding: .4rem; }
.notif-icon:hover { color: var(--gray-800); text-decoration: none; }
.notif-badge { position: absolute; top: -2px; right: -4px; background: var(--danger); color: #fff; font-size: .6rem; min-width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.logout-link { display: flex; align-items: center; gap: .5rem; color: var(--gray-400); font-size: .85rem; padding: .4rem 0; }
.logout-link:hover { color: var(--danger); text-decoration: none; }
.user-details { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: .85rem; color: var(--gray-200); }
.user-role { font-size: .7rem; color: var(--gray-400); }
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,.4); z-index: 150; }
.sidebar-overlay.active { display: block; }
.menu-separator { padding: .6rem 1.2rem .3rem; margin-top: .5rem; border-top: 1px solid rgba(255,255,255,.1); }
.menu-separator span { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-400); }
/* Menu collapsible (configurações e sistema) */
.menu-collapsible { cursor: pointer; user-select: none; transition: background 0.15s ease; }
.menu-collapsible:hover { background: rgba(255,255,255,.08); }
.menu-arrow { transition: transform 0.25s ease; display: inline-block; margin-right: 0.25rem; }

/* Menu group — container para itens de menu colapsáveis */
.menu-group { list-style: none; padding: 0; margin: 0; }
.menu-group li { padding: 0; margin: 0; list-style: none; }
.menu-group li a { display: flex; align-items: center; gap: .75rem; padding: .5rem 1.2rem .5rem 2.4rem; color: var(--gray-300); transition: all .15s; white-space: nowrap; border-left: 3px solid transparent; }
.menu-group li a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }

/* ── Flash Messages ───────────────────────────────────────── */
.flash-container { padding: .75rem 1.5rem 0; }
.alert { display: flex; align-items: center; gap: .75rem; padding: .85rem 1rem; border-radius: var(--radius); margin-bottom: .5rem; font-size: .9rem; animation: slideIn .3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.alert-success { background: var(--success-light); color: #065f46; border-left: 4px solid var(--success); }
.alert-danger { background: var(--danger-light); color: #991b1b; border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #92400e; border-left: 4px solid var(--warning); }
.alert-info { background: var(--primary-light); color: #1e40af; border-left: 4px solid var(--primary); }
.alert-close { margin-left: auto; background: none; border: none; font-size: 1.2rem; cursor: pointer; opacity: .5; }
.alert-close:hover { opacity: 1; }

/* ── Cards ────────────────────────────────────────────────── */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.5rem; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-200); }
.card-header h3 { font-size: 1rem; font-weight: 700; color: var(--gray-800); display: flex; align-items: center; gap: .5rem; }
.card-header.danger { background: var(--danger-light); }
.card-header.warning { background: var(--warning-light); }
.card-body { padding: 1.25rem; }
.card-body.no-pad { padding: 0; }

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; display: flex; align-items: center; gap: 1rem; border-left: 4px solid var(--gray-200); transition: transform .15s, box-shadow .15s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.stat-clickable { cursor: pointer; }
.stat-card.stat-clickable:hover { border-left-color: var(--primary); }
.stat-card.stat-danger { border-left-color: var(--danger); }
.stat-card.stat-warning { border-left-color: var(--warning); }
.stat-card.stat-success { border-left-color: var(--success); }
.stat-card.stat-primary { border-left-color: var(--primary); }
.stat-card.stat-purple { border-left-color: var(--purple); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.teal { background: #ccfbf1; color: #0d9488; }
.stat-icon.gray { background: #f1f5f9; color: #64748b; }
.stat-icon.orange { background: #fed7aa; color: #ea580c; }
.stat-info { display: flex; flex-direction: column; }
.stat-number { font-size: 1.6rem; font-weight: 800; color: var(--gray-800); line-height: 1.1; }
.stat-label { font-size: .78rem; color: var(--gray-500); font-weight: 500; }

/* ── Charts ───────────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-bottom: 1.5rem; }
.charts-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; margin-bottom: 1.5rem; }
.chart-container { position: relative; height: 280px; padding: .5rem; }
.chart-container canvas { max-height: 100%; }

/* ── Tables ────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.table th { background: var(--gray-50); color: var(--gray-600); font-weight: 600; text-transform: uppercase; font-size: .72rem; letter-spacing: .3px; padding: .65rem .75rem; text-align: left; border-bottom: 2px solid var(--gray-200); white-space: nowrap; }
.table th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 3px; transition: color .15s; }
.table th a:hover { color: var(--primary); }
.table th a small { font-size: .75em; opacity: .75; }
.table td { padding: .6rem .75rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table tbody tr:hover { background: var(--gray-50); }
.table-compact td { padding: .45rem .6rem; }
.row-danger { background: #fef2f2 !important; }
.row-danger:hover { background: #fee2e2 !important; }
.row-critical { background: #fff7ed !important; }
.row-critical:hover { background: #fed7aa !important; }
.row-warning { background: #fffbeb !important; }
.row-warning:hover { background: #fef3c7 !important; }

/* ── Badges ───────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.badge-recebido { background: #dbeafe; color: #1e40af; }
.badge-em_analise { background: #fef3c7; color: #92400e; }
.badge-em_elaboracao { background: #ede9fe; color: #5b21b6; }
.badge-aguardando_validacao { background: #fce7f3; color: #9d174d; }
.badge-aprovado { background: #d1fae5; color: #065f46; }
.badge-concluido { background: #d1fae5; color: #065f46; }
.badge-devolvido { background: #fee2e2; color: #991b1b; }
.badge-cancelado { background: #f1f5f9; color: #475569; }
.badge-arquivado { background: #f1f5f9; color: #64748b; }
.badge-vencido { background: var(--danger); color: #fff; }
.badge-critico { background: #dc2626; color: #fff; }
.badge-urgente { background: #f59e0b; color: #fff; }
.badge-ok { background: #10b981; color: #fff; }
.badge-concluido-ok { background: #6b7280; color: #fff; }
.badge-pri-baixa { background: #e2e8f0; color: #475569; }
.badge-pri-media { background: #dbeafe; color: #1d4ed8; }
.badge-pri-alta { background: #fef3c7; color: #d97706; }
.badge-pri-critica { background: #fee2e2; color: #dc2626; }
.badge-sig-publico { background: #d1fae5; color: #065f46; }
.badge-sig-interno { background: #dbeafe; color: #1e40af; }
.badge-sig-restrito { background: #fef3c7; color: #92400e; }
.badge-sig-confidencial { background: #fee2e2; color: #991b1b; }
.badge-danger { background: var(--danger); color: #fff; }
.badge-warning { background: var(--warning); color: #fff; }
.badge-success { background: var(--success); color: #fff; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.1rem; border: none; border-radius: 8px; font-size: .85rem; font-weight: 600; cursor: pointer; transition: all .15s; text-decoration: none !important; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--gray-300); color: var(--gray-600); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-sm { padding: .35rem .75rem; font-size: .78rem; }
.btn-xs { padding: .25rem .5rem; font-size: .72rem; }
.btn-icon { padding: .45rem; width: 34px; height: 34px; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1.5rem; }
.form-section { margin-bottom: 1.5rem; }
.form-section-title { font-size: 1rem; font-weight: 700; color: var(--gray-700); padding-bottom: .5rem; border-bottom: 2px solid var(--primary-light); margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem 1.25rem; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem 1.25rem; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .75rem; align-items: end; }
.form-group { display: flex; flex-direction: column; }
.form-group label { font-weight: 600; margin-bottom: .3rem; color: var(--gray-600); font-size: .82rem; letter-spacing: .01em; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: .6rem .8rem; border: 1.5px solid var(--gray-200); border-radius: 8px;
    font-size: .9rem; font-family: inherit; color: var(--gray-800);
    transition: border-color .2s, box-shadow .2s; background: #fff; line-height: 1.5;
}
.form-group select {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right .7rem center; background-size: 16px;
    padding-right: 2.25rem; cursor: pointer;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: #fff; }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-help { font-size: .78rem; color: var(--gray-400); margin-top: .25rem; line-height: 1.4; }
.form-actions { display: flex; gap: .75rem; padding-top: 1rem; }
.full-width { grid-column: 1 / -1; }
.form-actions-filter { display: flex; gap: .5rem; align-items: end; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 500 !important; }
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

/* ── Pipeline ─────────────────────────────────────────────── */
.pipeline-flow { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: 1rem; }
.pipeline-step { display: flex; flex-direction: column; align-items: center; padding: .75rem 1rem; border-radius: var(--radius); border: 2px solid var(--gray-200); min-width: 100px; text-align: center; transition: all .15s; }
.pipeline-step:hover { border-color: var(--primary); }
.pipeline-step .step-count { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.pipeline-step .step-label { font-size: .7rem; color: var(--gray-500); font-weight: 500; }
.pipeline-stage { display: flex; flex-direction: column; align-items: center; padding: .75rem 1rem; border-radius: 12px; min-width: 110px; text-align: center; transition: all .2s; position: relative; }
.pipeline-count { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.pipeline-label { font-size: .68rem; font-weight: 600; margin-top: .3rem; text-transform: uppercase; letter-spacing: .3px; }
.pipeline-arrow { color: var(--gray-300); font-size: 1.2rem; }

/* ── Bar Charts (CSS) ─────────────────────────────────────── */
.chart-bars { display: flex; flex-direction: column; gap: .5rem; }
.bar-item { display: flex; align-items: center; gap: .75rem; }
.bar-label { width: 140px; font-size: .8rem; color: var(--gray-600); text-align: right; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 26px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); border-radius: 4px; display: flex; align-items: center; justify-content: flex-end; padding-right: .5rem; color: #fff; font-size: .75rem; font-weight: 600; min-width: 30px; transition: width .3s; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: .75rem; padding: 1rem; }
.pagination-info { font-size: .85rem; color: var(--gray-500); }

/* ── Detail Page ──────────────────────────────────────────── */
.oficio-header { display: flex; align-items: center; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.5rem; }
.oficio-header h2 { font-size: 1.3rem; }
.oficio-header .badges { display: flex; gap: .4rem; flex-wrap: wrap; }
.oficio-header .actions { margin-left: auto; display: flex; gap: .5rem; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; margin-bottom: 1.5rem; }
.detail-section h4 { font-size: .9rem; font-weight: 700; color: var(--gray-700); margin-bottom: .75rem; padding-bottom: .4rem; border-bottom: 2px solid var(--primary-light); display: flex; align-items: center; gap: .4rem; }
.detail-row { display: flex; padding: .35rem 0; font-size: .85rem; }
.detail-row .label { width: 130px; font-weight: 600; color: var(--gray-500); flex-shrink: 0; }
.detail-row .value { color: var(--gray-800); flex: 1; }
.alert-banner { padding: 1rem 1.25rem; border-radius: var(--radius); margin-bottom: 1rem; display: flex; align-items: center; gap: .75rem; font-weight: 600; }
.alert-banner.banner-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fca5a5; }
.alert-banner.banner-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-banner.banner-info { background: var(--primary-light); color: #1e40af; border: 1px solid #93c5fd; }
.bloqueado-banner { background: var(--gray-100); color: var(--gray-600); padding: .75rem 1rem; border-radius: var(--radius); border: 1px solid var(--gray-300); margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; font-size: .9rem; }

/* ── Notifications ────────────────────────────────────────── */
.notif-item { display: flex; align-items: flex-start; gap: .75rem; padding: .85rem 1rem; border-bottom: 1px solid var(--gray-100); cursor: pointer; transition: background .15s; }
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: #eff6ff; border-left: 3px solid var(--primary); }
.notif-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--primary-light); color: var(--primary); }
.notif-content { flex: 1; }
.notif-title { font-weight: 600; font-size: .88rem; }
.notif-msg { color: var(--gray-500); font-size: .82rem; }
.notif-time { font-size: .72rem; color: var(--gray-400); }

/* ── Signature ────────────────────────────────────────────── */
.signature-box { background: var(--success-light); border: 2px solid var(--success); border-radius: var(--radius); padding: 1rem; display: flex; align-items: center; gap: 1rem; }
.signature-box i { font-size: 2rem; color: var(--success); }
.signature-info { font-size: .85rem; }
.signature-hash { font-family: monospace; font-size: .72rem; color: var(--gray-500); word-break: break-all; }

/* ── Versioning ───────────────────────────────────────────── */
.version-badge { background: var(--purple-light); color: var(--purple); padding: 2px 6px; border-radius: 4px; font-size: .7rem; font-weight: 700; }
.file-size { color: var(--gray-400); font-size: .78rem; }

/* ── Top Criticas ─────────────────────────────────────────── */
.criticas-list { display: flex; flex-direction: column; gap: .5rem; }
.critica-item { display: flex; align-items: center; gap: 1rem; padding: .75rem 1rem; border-radius: 8px; background: var(--gray-50); border: 1px solid var(--gray-200); }
.critica-rank { width: 28px; height: 28px; border-radius: 50%; background: var(--danger); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; flex-shrink: 0; }
.critica-info { flex: 1; }
.critica-name { font-weight: 700; font-size: .9rem; }
.critica-stats { font-size: .78rem; color: var(--gray-500); display: flex; gap: 1rem; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--gray-400); font-size: .95rem; }
.empty-state i { font-size: 2rem; margin-bottom: .5rem; display: block; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--gray-400) !important; }

/* ── Horizontal bar charts ────────────────────────────────── */
.horizontal-bars { display: flex; flex-direction: column; gap: .6rem; }
.hbar-item { display: flex; align-items: center; gap: .75rem; }
.hbar-label { max-width: 250px; font-size: .82rem; color: var(--gray-600); font-weight: 500; white-space: normal; word-wrap: break-word; flex-shrink: 0; line-height: 1.3; }
.hbar-track { flex: 1; height: 24px; background: var(--gray-100); border-radius: 6px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #60a5fa); border-radius: 6px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; color: #fff; font-size: .72rem; font-weight: 600; min-width: 28px; transition: width .4s ease; }
.hbar-value { font-size: .82rem; font-weight: 700; color: var(--gray-700); min-width: 30px; text-align: right; }

/* ── Grid helpers ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 1rem; }

/* ── Export buttons ───────────────────────────────────────── */
.export-buttons { display: flex; gap: .5rem; }
.btn-excel { background: #059669; color: #fff; }
.btn-excel:hover { background: #047857; }
.btn-pdf { background: #dc2626; color: #fff; }
.btn-pdf:hover { background: #b91c1c; }

/* ── Attachment upload ────────────────────────────────────── */
.anexo-row { display: flex; gap: .75rem; align-items: center; margin-bottom: .5rem; padding: .75rem; background: var(--gray-50); border-radius: 8px; }
.anexo-row input[type="file"] { flex: 1; }
.anexo-row select { flex: 1; min-width: 150px; }
.btn-add-anexo { border: 2px dashed var(--gray-300); color: var(--gray-500); background: transparent; width: 100%; padding: .75rem; border-radius: 8px; cursor: pointer; font-size: .85rem; }
.btn-add-anexo:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .charts-grid-2 { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr; }
}

/* ── Mobile: sidebar como drawer overlay ──────────────────── */
@media (max-width: 768px) {
    /* Sidebar oculta por padrão — desliza da esquerda quando .open */
    .sidebar {
        width: var(--sidebar-width) !important;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 200;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.35);
    }
    /* Textos sempre visíveis quando o drawer abre */
    .sidebar .sidebar-title,
    .sidebar .nav-list span,
    .sidebar .sidebar-menu li a span,
    .sidebar .user-info span,
    .sidebar .user-details,
    .sidebar .logout-btn span,
    .sidebar .logout-link span,
    .sidebar .menu-separator { display: initial !important; }

    /* Conteúdo ocupa tela toda */
    .main-content, .content { margin-left: 0 !important; }

    /* Topbar */
    .page-title { font-size: 1rem; }

    /* Grids */
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filters-grid { grid-template-columns: 1fr 1fr; }
    .pipeline-flow { flex-direction: column; }
    .pipeline-arrow { transform: rotate(90deg); }
    .oficio-header { flex-direction: column; align-items: flex-start; }
    .oficio-header .actions { margin-left: 0; }

    /* Card headers com botões: empilha em 2 linhas se necessário */
    .card-header { flex-wrap: wrap; gap: .5rem; }

    /* Tabela: scroll horizontal em telas pequenas */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 600px; }
    .table th, .table td { white-space: nowrap; padding: .5rem .6rem; font-size: .82rem; }

    /* Paginação */
    .pagination { flex-wrap: wrap; gap: .25rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .filters-grid { grid-template-columns: 1fr; }
    .content-area, .page-content { padding: .75rem; }
    .card-header h3 { font-size: .95rem; }
    .btn-sm { font-size: .78rem; padding: .3rem .6rem; }
    /* Modal ocupa quase toda a tela */
    .modal-content { min-width: 94vw; max-width: 94vw; }
}

/* ── Print ─────────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .flash-container, .btn, .form-actions, .menu-toggle, .export-buttons { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    body { background: #fff; }
}

/* ── Info Grid (ver_oficio) ───────────────────────────── */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 24px; }
.info-grid .full-width { grid-column: 1 / -1; }
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-item label { font-size: .78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.info-item label::after { content: ":"; }
.info-item span { font-size: .92rem; color: var(--text-primary); }

/* ── Bulk Selection & Actions ─────────────────────────────── */
.row-checkbox, .select-all-checkbox {
    accent-color: var(--primary);
    cursor: pointer;
    width: 18px;
    height: 18px;
}

tr.row-selected {
    background: var(--primary-light) !important;
}

.bulk-toolbar {
    background: var(--primary-light);
    border-bottom: 2px solid var(--primary);
    padding: 0.65rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.bulk-info {
    font-weight: 600;
    color: var(--gray-700);
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
}

.bulk-actions {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .bulk-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .bulk-actions {
        flex-wrap: wrap;
    }
}

/* ── Modal Dialog ────────────────────────────────────────── */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 400px;
    max-width: 600px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h5 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-header .close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-header .close-modal:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.modal-footer .btn {
    margin: 0;
}

@media (max-width: 600px) {
    .modal-content {
        min-width: 90%;
        max-width: 90%;
    }
}

/* ── Form Validation (Real-time Feedback) ─────────────────── */

/* Campo com erro */
.field-error input,
.field-error select,
.field-error textarea {
    border-color: var(--danger) !important;
    background-color: #fff8f8 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.12);
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Campo preenchido corretamente */
.field-ok input:not([type="checkbox"]):not([type="file"]),
.field-ok select,
.field-ok textarea {
    border-color: #28a745 !important;
    background-color: #f8fff9 !important;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Mensagem de erro inline */
.validation-hint {
    font-size: 0.78rem;
    margin-top: 4px;
    display: none;
}
.error-hint {
    color: var(--danger);
}
.error-hint::before {
    content: "⚠ ";
}

/* Asterisco obrigatório gerado por JS */
.required-star {
    color: var(--danger);
    font-weight: 700;
}

/* Contador de caracteres */
.char-counter {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 3px;
    transition: color 0.2s;
}
.char-counter.counter-warning {
    color: #e67e22;
    font-weight: 600;
}
.char-counter.counter-over {
    color: var(--danger);
    font-weight: 700;
}


/* Animação de erro no botão submit */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-6px); }
    40%       { transform: translateX(6px); }
    60%       { transform: translateX(-4px); }
    80%       { transform: translateX(4px); }
}
.btn-shake {
    animation: shake 0.4s ease;
}

/* Ícone de check no campo OK (decorativo, CSS only) */
.field-ok::after {
    content: "✓";
    color: #28a745;
    font-size: 0.85rem;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}
.field-ok {
    position: relative;
}

/* ── Dashboard Live Refresh ───────────────────────────────── */
.dashboard-live-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Bolinha pulsante */
.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #28a745;
    flex-shrink: 0;
    transition: background 0.3s;
}
.live-dot.dot-online  { background: #28a745; }
.live-dot.dot-offline { background: #dc3545; }
.live-dot.pulsing {
    animation: dotPulse 0.8s ease;
}
@keyframes dotPulse {
    0%   { transform: scale(1);   opacity: 1; }
    50%  { transform: scale(1.7); opacity: 0.6; }
    100% { transform: scale(1);   opacity: 1; }
}

.live-label {
    font-weight: 700;
    color: #28a745;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
}

.live-updated {
    flex: 1;
    transition: color 0.3s;
}
.live-updated.live-offline { color: #dc3545; }

.live-refresh-btn {
    margin-left: auto;
    padding: 3px 10px;
    font-size: 0.75rem;
}

/* Animação de highlight ao atualizar valor */
@keyframes kpiHighlight {
    0%   { background: transparent; }
    30%  { background: rgba(59, 130, 246, 0.18); border-radius: 6px; }
    100% { background: transparent; }
}
.kpi-updated {
    animation: kpiHighlight 1.2s ease;
}

/* Spin no ícone de refresh */
.fa-spin {
    animation: fa-spin 0.8s linear infinite;
}
@keyframes fa-spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── Export Grid (Relatórios) ─────────────────────────────── */
.export-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
.export-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: 1.5rem 1rem;
    min-height: 110px;
    border-radius: var(--radius);
    border: 2px solid transparent;
    text-align: center;
    text-decoration: none !important;
    transition: transform .15s, box-shadow .15s;
    cursor: pointer;
}
.export-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    text-decoration: none !important;
}
.export-card i { font-size: 2rem; margin-bottom: .25rem; }
.export-card strong { font-size: .92rem; color: var(--gray-800); }
.export-card span { font-size: .76rem; color: var(--text-muted); line-height: 1.4; }

.export-excel      { background:#f0fdf4; border-color:#10b981; }
.export-excel      i { color:#10b981; }
.export-excel-full { background:#ecfdf5; border-color:#059669; }
.export-excel-full i { color:#059669; }
.export-csv        { background:#f0f9ff; border-color:#0ea5e9; }
.export-csv        i { color:#0ea5e9; }
.export-sla        { background:#faf5ff; border-color:#8b5cf6; }
.export-sla        i { color:#8b5cf6; }
.export-pdf        { background:#fff1f2; border-color:#ef4444; }
.export-pdf        i { color:#ef4444; }
.export-audit      { background:#fff7ed; border-color:#f59e0b; }
.export-audit      i { color:#f59e0b; }

@media (max-width: 1024px) {
    .export-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .export-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .export-grid { grid-template-columns: 1fr 1fr; }
}
