/* =====================================================
   NR-01 Gov - Design System
   ===================================================== */

:root {
    --primary:       #1a3a5c;
    --primary-light: #2563a8;
    --primary-dark:  #0f2540;
    --accent:        #00b4d8;
    --accent2:       #0077b6;
    --success:       #059669;
    --warning:       #d97706;
    --danger:        #dc2626;
    --info:          #2563eb;
    --muted:         #6b7280;

    --risk-aceitavel: #6ee7b7;
    --risk-baixo:     #86efac;
    --risk-medio:     #fde68a;
    --risk-alto:      #fca5a5;
    --risk-critico:   #f87171;
    --risk-critico-bg:#fef2f2;

    --sidebar-w: 260px;
    --topbar-h:  60px;

    --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
    --radius: 8px;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 14px;
    color: #1e293b;
    background: #f1f5f9;
    line-height: 1.5;
}

/* ─── SIDEBAR ─────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--primary);
    color: #fff;
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform .3s;
}

.sidebar-brand {
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; gap: 10px;
}

.sidebar-brand .logo-icon {
    width: 36px; height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 16px; color: #fff;
    flex-shrink: 0;
}

.sidebar-brand .brand-text { line-height: 1.2; }
.sidebar-brand .brand-name { font-weight: 700; font-size: 15px; }
.sidebar-brand .brand-sub { font-size: 10px; opacity: .65; text-transform: uppercase; letter-spacing: .5px; }

.sidebar-org {
    margin: 12px 12px 8px;
    background: rgba(255,255,255,.08);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
}
.sidebar-org .org-label { opacity: .6; text-transform: uppercase; letter-spacing: .4px; font-size: 10px; }
.sidebar-org .org-name { font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 0; }

.nav-section { margin-top: 8px; }
.nav-section-title {
    padding: 6px 18px 4px;
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .8px;
    opacity: .45; color: #fff;
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 18px;
    color: rgba(255,255,255,.8);
    text-decoration: none;
    font-size: 13px; font-weight: 450;
    border-left: 3px solid transparent;
    transition: all .15s;
    cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; border-left-color: rgba(255,255,255,.3); }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item .badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 10px; font-weight: 700; }

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.sidebar-footer .user-info { flex: 1; min-width: 0; }
.sidebar-footer .user-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .user-role { font-size: 10px; opacity: .6; }
.sidebar-footer .logout-btn { color: rgba(255,255,255,.6); text-decoration: none; font-size: 16px; }
.sidebar-footer .logout-btn:hover { color: #fff; }

/* ─── TOPBAR ──────────────────────────────────────── */
.topbar {
    position: fixed; top: 0; left: var(--sidebar-w); right: 0;
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center; padding: 0 24px;
    z-index: 99;
    gap: 16px;
}

.topbar-title { font-size: 16px; font-weight: 600; color: var(--primary); flex: 1; }
.topbar-breadcrumb { font-size: 12px; color: var(--muted); flex: 1; }
.topbar-breadcrumb a { color: var(--muted); text-decoration: none; }
.topbar-breadcrumb a:hover { color: var(--primary-light); }

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.notif-btn {
    position: relative; background: none; border: none; cursor: pointer;
    color: var(--muted); font-size: 18px; padding: 4px;
}
.notif-btn .badge {
    position: absolute; top: 0; right: 0;
    background: var(--danger); color: #fff;
    border-radius: 50%; width: 16px; height: 16px;
    font-size: 9px; display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

/* ─── MAIN CONTENT ────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    padding-top: var(--topbar-h);
    min-height: 100vh;
}

.page-body { padding: 24px; }

/* ─── CARDS ────────────────────────────────────────── */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid #e2e8f0;
}
.card-header {
    padding: 16px 20px 14px;
    border-bottom: 1px solid #f1f5f9;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
}
.card-header h5 { font-size: 14px; font-weight: 600; color: var(--primary); margin: 0; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid #f1f5f9; background: #f8fafc; border-radius: 0 0 var(--radius) var(--radius); }

/* ─── STAT CARDS ───────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid #e2e8f0;
    display: flex; align-items: flex-start; gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.stat-icon.bg-primary { background: #eff6ff; color: var(--primary-light); }
.stat-icon.bg-success { background: #ecfdf5; color: var(--success); }
.stat-icon.bg-warning { background: #fffbeb; color: var(--warning); }
.stat-icon.bg-danger  { background: #fef2f2; color: var(--danger); }
.stat-icon.bg-purple  { background: #f5f3ff; color: #7c3aed; }

.stat-info .stat-value { font-size: 28px; font-weight: 700; line-height: 1; color: var(--primary); }
.stat-info .stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-info .stat-change { font-size: 11px; margin-top: 6px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ─── GRID ─────────────────────────────────────────── */
.row { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 20px; }
.col { flex: 1; min-width: 0; }
.col-2 { flex: 0 0 calc(50% - 10px); }
.col-3 { flex: 0 0 calc(33.333% - 14px); }
.col-4 { flex: 0 0 calc(25% - 15px); }
.col-full { flex: 0 0 100%; }

/* ─── TABELAS ──────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table.data-table {
    width: 100%; border-collapse: collapse;
}
table.data-table th {
    background: #f8fafc; padding: 10px 14px;
    text-align: left; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .5px;
    color: var(--muted); border-bottom: 1px solid #e2e8f0;
    white-space: nowrap;
}
table.data-table td {
    padding: 12px 14px; border-bottom: 1px solid #f1f5f9;
    font-size: 13px; vertical-align: middle;
}
table.data-table tr:hover td { background: #f8fafc; }
table.data-table tr:last-child td { border-bottom: none; }

/* ─── BADGES ───────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 9px; border-radius: 20px;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .3px;
}
.badge-success  { background: #dcfce7; color: #166534; }
.badge-warning  { background: #fef9c3; color: #854d0e; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-muted    { background: #f1f5f9; color: #475569; }
.badge-purple   { background: #f5f3ff; color: #6d28d9; }
.badge-primary  { background: #dbeafe; color: #1d4ed8; }

/* Badges de risco */
.risk-badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.risk-aceitavel { background: #d1fae5; color: #065f46; }
.risk-baixo     { background: #dcfce7; color: #14532d; }
.risk-medio     { background: #fef9c3; color: #78350f; }
.risk-alto      { background: #fee2e2; color: #7f1d1d; }
.risk-critico   { background: #fecaca; color: #450a0a; animation: pulse-risk 1.5s ease infinite; }

@keyframes pulse-risk {
    0%, 100% { opacity: 1; }
    50%       { opacity: .6; }
}

/* ─── FORMULÁRIOS ──────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
    width: 100%; padding: 9px 12px;
    border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 13px; color: #1e293b; font-family: var(--font);
    background: #fff; transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(37,99,168,.1); }
.form-control:disabled { background: #f1f5f9; color: var(--muted); cursor: not-allowed; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.form-error { font-size: 11px; color: var(--danger); margin-top: 4px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }

/* ─── BOTÕES ───────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 6px;
    font-size: 13px; font-weight: 600; font-family: var(--font);
    border: 1px solid transparent; cursor: pointer;
    text-decoration: none; transition: all .15s;
    white-space: nowrap; line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }

.btn-primary { background: var(--primary-light); color: #fff; border-color: var(--primary-light); }
.btn-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #047857; }
.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-ghost   { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: #f1f5f9; color: #374151; }

/* ─── PROGRESSO ────────────────────────────────────── */
.progress { background: #e2e8f0; border-radius: 10px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 10px; transition: width .4s ease; }
.progress-bar.bg-success { background: var(--success); }
.progress-bar.bg-warning { background: var(--warning); }
.progress-bar.bg-danger  { background: var(--danger); }
.progress-bar.bg-primary { background: var(--primary-light); }

/* ─── FASE STEPPER ─────────────────────────────────── */
.phase-stepper {
    display: flex; align-items: flex-start; gap: 0;
    padding: 20px 0; overflow-x: auto;
}
.phase-step { flex: 1; min-width: 120px; display: flex; flex-direction: column; align-items: center; position: relative; }
.phase-step::before {
    content: ''; position: absolute; top: 16px; right: -50%;
    width: 100%; height: 2px; background: #e2e8f0; z-index: 0;
}
.phase-step:last-child::before { display: none; }
.phase-step.done::before   { background: var(--success); }
.phase-step.active::before { background: var(--primary-light); }

.phase-dot {
    width: 32px; height: 32px; border-radius: 50%;
    background: #e2e8f0; color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; z-index: 1; position: relative;
    border: 2px solid #e2e8f0; transition: all .2s;
}
.phase-step.done   .phase-dot { background: var(--success); color: #fff; border-color: var(--success); }
.phase-step.active .phase-dot { background: var(--primary-light); color: #fff; border-color: var(--primary-light); box-shadow: 0 0 0 4px rgba(37,99,168,.15); }
.phase-step.locked .phase-dot { background: #f1f5f9; color: #cbd5e1; }

.phase-label { font-size: 11px; margin-top: 8px; text-align: center; color: var(--muted); font-weight: 500; }
.phase-step.active .phase-label { color: var(--primary-light); font-weight: 700; }
.phase-step.done   .phase-label { color: var(--success); }

/* ─── MATRIZ DE RISCO ──────────────────────────────── */
.risk-matrix { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; }
.matrix-cell {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; border-radius: 4px; cursor: default;
    transition: transform .15s;
}
.matrix-cell:hover { transform: scale(1.08); z-index: 1; }
.matrix-cell.nivel-1 { background: #d1fae5; color: #065f46; }
.matrix-cell.nivel-2 { background: #dcfce7; color: #14532d; }
.matrix-cell.nivel-3 { background: #fef9c3; color: #713f12; }
.matrix-cell.nivel-4 { background: #fed7aa; color: #7c2d12; }
.matrix-cell.nivel-5 { background: #fecaca; color: #450a0a; }

/* ─── ALERTS ───────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid transparent; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ─── MODAL ────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 999; padding: 20px;
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
    background: #fff; border-radius: 10px; max-width: 700px; width: 100%;
    max-height: 90vh; overflow-y: auto;
    transform: scale(.95); transition: transform .2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header { padding: 18px 22px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; }
.modal-header h4 { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid #e2e8f0; display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }

/* ─── ORGOGRAMA ────────────────────────────────────── */
.org-tree ul { list-style: none; padding-left: 24px; position: relative; }
.org-tree ul::before { content: ''; position: absolute; left: 8px; top: 0; bottom: 0; border-left: 2px solid #e2e8f0; }
.org-tree li { position: relative; padding: 4px 0; }
.org-tree li::before { content: ''; position: absolute; left: -16px; top: 16px; width: 16px; height: 2px; background: #e2e8f0; }
.org-node {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 7px 12px; border-radius: 6px;
    background: #fff; border: 1px solid #e2e8f0;
    font-size: 12px; cursor: pointer;
    transition: all .15s; box-shadow: var(--shadow);
}
.org-node:hover { border-color: var(--primary-light); box-shadow: var(--shadow-md); }
.org-node.has-risk { border-color: var(--warning); }
.org-node.risk-critico { border-color: var(--danger); background: #fef2f2; }

/* ─── RESPONSIVO ───────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar { left: 0; }
    .col-2, .col-3, .col-4 { flex: 0 0 100%; }
    .form-row { flex-direction: column; }
}

/* ─── UTILIDADES ───────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary-light); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12 { font-size: 12px; }
.fs-11 { font-size: 11px; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }

/* ─── LOGIN PAGE ───────────────────────────────────── */
.login-page {
    min-height: 100vh; background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--accent2) 100%);
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
    background: #fff; border-radius: 12px; padding: 40px;
    width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
}
.login-logo {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    margin-bottom: 28px;
}
.login-logo .logo-icon {
    width: 48px; height: 48px; background: var(--primary);
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: #fff; font-weight: 800;
}
.login-logo .logo-text h2 { font-size: 20px; font-weight: 800; color: var(--primary); }
.login-logo .logo-text p { font-size: 11px; color: var(--muted); }
