:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius: 18px;
    --radius-sm: 12px;
    --sidebar-width: 280px;
    --transition: all 0.25s ease;
    --font: Arial, Helvetica, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
}

body {
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* =========================
   SIDEBAR
   ========================= */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #fff;
    padding: 22px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
}

.brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.brand h2 {
    margin: 0;
    font-size: 18px;
}

.brand span {
    color: #cbd5e1;
    font-size: 13px;
}

.sidebar-close {
    background: transparent;
    color: #fff;
    border: 0;
    font-size: 18px;
    display: none;
    cursor: pointer;
}

.sidebar-user {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255,255,255,0.06);
    margin-bottom: 24px;
}

.avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    flex-shrink: 0;
}

.avatar.small {
    width: 40px;
    height: 40px;
    font-size: 14px;
}

.sidebar-user strong,
.topbar-user strong {
    display: block;
    font-size: 14px;
}

.sidebar-user small,
.topbar-user small {
    color: #cbd5e1;
    font-size: 12px;
}

/* =========================
   MENU
   ========================= */
.menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-group-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    margin-top: 14px;
    margin-bottom: 4px;
    padding: 0 6px;
    font-weight: 700;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 14px;
    color: #e5e7eb;
    transition: all 0.25s ease;
}

.menu-link i {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.menu-link span {
    display: block;
    line-height: 1.35;
}

.menu-link:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    transform: translateX(2px);
}

.menu-link.activo {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.menu-dropdown-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 14px;
    color: #e5e7eb;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.25s ease;
    font: inherit;
    text-align: left;
}

.menu-dropdown-toggle:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.menu-dropdown-toggle.activo {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.menu-dropdown-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.menu-dropdown-left i {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.menu-dropdown-left span {
    line-height: 1.35;
}

.menu-dropdown-arrow {
    transition: transform 0.25s ease;
    font-size: 12px;
    flex-shrink: 0;
}

.menu-dropdown-toggle.activo .menu-dropdown-arrow {
    transform: rotate(180deg);
}

.menu-submenu {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding-left: 12px;
    margin-top: 4px;
    margin-bottom: 4px;
    margin-left: 8px;
    border-left: 1px solid rgba(255,255,255,0.12);
}

.menu-submenu.aberto {
    display: flex;
}

.menu-submenu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    color: #cbd5e1;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.25s ease;
}

.menu-submenu a:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.menu-submenu a.activo {
    background: rgba(255,255,255,0.10);
    color: #fff;
}

.menu-submenu a i {
    width: 14px;
    text-align: center;
    font-size: 12px;
    flex-shrink: 0;
}

.menu-submenu a span {
    line-height: 1.35;
}

.menu-logout {
    margin-top: 10px;
    background: rgba(220, 38, 38, 0.14);
    color: #fecaca !important;
}

.menu-logout:hover {
    background: rgba(220, 38, 38, 0.22);
}

/* =========================
   MAIN / TOPBAR
   ========================= */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    transition: var(--transition);
}

.topbar {
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-title {
    margin: 0;
    font-size: 22px;
}

.topbar-subtitle {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.topbar-user {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 8px 12px;
    border-radius: 14px;
}

.topbar-user small {
    color: var(--muted);
}

/* =========================
   BOTAO MENU MOBILE
   ========================= */
.menu-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 12px;
    border: none;
    background: #1e293b;
    color: #ffffff;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    z-index: 1100;
    position: relative;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.18);
    transition: all 0.25s ease;
}

.menu-toggle:hover {
    background: #0f172a;
    transform: translateY(-1px);
}

.menu-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
}

.menu-toggle i {
    color: #1e293b !important;
    background: #1e293b;
    font-size: 20px;
    line-height: 1;
}

.content {
    padding: 24px;
}

/* =========================
   CARDS
   ========================= */
.grelha-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.card h3 {
    margin: 0 0 10px;
    font-size: 15px;
    color: var(--muted);
    font-weight: 600;
}

.card p {
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
}

/* =========================
   PAGE HEADER
   ========================= */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.page-header h1 {
    margin: 0;
    font-size: 28px;
}

.page-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.page-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* =========================
   BUTTONS
   ========================= */
.btn,
button,
.botao-link,
.page-actions a,
.page-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.btn:hover,
button:hover,
.botao-link:hover,
.page-actions a:hover,
.page-actions button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secundario {
    background: #e2e8f0;
    color: #0f172a;
}

.btn-secundario:hover {
    background: #cbd5e1;
}

.btn-perigo {
    background: var(--danger);
}

.btn-perigo:hover {
    background: #b91c1c;
}

.btn-success {
    background: var(--success);
}

.btn-success:hover {
    background: #15803d;
}

.btn-warning {
    background: var(--warning);
}

.btn-warning:hover {
    background: #b45309;
}

/* =========================
   FORMS
   ========================= */
.formulario {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    outline: none;
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

textarea {
    resize: vertical;
    min-height: 110px;
}

.form-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* =========================
   TABLES
   ========================= */
.table-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.tabela {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.tabela th,
.tabela td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.tabela thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.tabela tbody tr:hover {
    background: #f8fbff;
}

.acoes {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.acoes a {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    background: #eff6ff;
    color: var(--primary);
}

.acoes a:last-child {
    background: #fef2f2;
    color: var(--danger);
}

/* =========================
   ALERTS
   ========================= */
.alerta {
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 18px;
    font-weight: 500;
}

.alerta-sucesso {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alerta-erro {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alerta-aviso {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* =========================
   LOGIN
   ========================= */
.pagina-login {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at top left, rgba(37,99,235,0.18), transparent 35%),
        radial-gradient(circle at bottom right, rgba(14,165,233,0.15), transparent 30%),
        linear-gradient(135deg, #0f172a, #1e293b);
}

.caixa-login {
    width: 100%;
    max-width: 430px;
    background: rgba(255,255,255,0.98);
    padding: 34px;
    border-radius: 24px;
    box-shadow: 0 24px 50px rgba(0,0,0,0.22);
}

.caixa-login h1 {
    margin: 0 0 10px;
    font-size: 28px;
}

.subtitulo-login {
    margin: 0 0 24px;
    color: var(--muted);
}

/* =========================
   BADGES / HELPERS
   ========================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-neutral {
    background: #e2e8f0;
    color: #334155;
}

.badge-primary {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-info {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-purple {
    background: #f3e8ff;
    color: #7e22ce;
}

.badge-orange {
    background: #ffedd5;
    color: #c2410c;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-approved {
    background: #dcfce7;
    color: #166534;
}

.badge-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.text-muted {
    color: var(--muted);
}

.empty-state {
    padding: 30px;
    text-align: center;
    color: var(--muted);
}

.card-info {
    background: linear-gradient(135deg, #eff6ff, #f8fafc);
    border: 1px solid #dbeafe;
}

.card-info h4 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #1d4ed8;
}

.card-info p {
    margin: 0;
    font-size: 14px;
    color: #475569;
}

/* =========================
   SUMMARY / TOOLBAR
   ========================= */
.top-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.top-summary .card {
    padding: 18px;
}

.top-summary .card p {
    font-size: 24px;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-mini {
    background: var(--surface);
    border-radius: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.stat-mini h4 {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--muted);
}

.stat-mini p {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
}

.toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    align-items: end;
}

.toolbar form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: end;
    width: 100%;
}

.toolbar .form-group {
    min-width: 180px;
    margin: 0;
}

.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* =========================
   FILTERS / DETAILS
   ========================= */
.filters-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
    margin-bottom: 20px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    align-items: end;
}

.section-space {
    margin-bottom: 20px;
}

.detail-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
    margin-bottom: 20px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.detail-item {
    padding: 14px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.detail-item.full {
    grid-column: 1 / -1;
}

.detail-item h4 {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-item p {
    margin: 0;
    font-size: 15px;
    color: var(--text);
    white-space: pre-wrap;
}

.progress-wrap {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
    border-radius: 999px;
}

/* =========================
   REPORTS
   ========================= */
.report-section {
    margin-bottom: 24px;
}

.report-title {
    margin: 0 0 14px;
    font-size: 18px;
    font-weight: 700;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.kpi-card h4 {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--muted);
}

.kpi-card p {
    margin: 0;
    font-size: 26px;
    font-weight: 700;
}

.inline-info {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 14px;
}

.print-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* =========================
   DASHBOARD
   ========================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    gap: 20px;
    margin-bottom: 24px;
    align-items: start;
}

.dashboard-stack {
    display: grid;
    gap: 20px;
    min-width: 0;
}

.chart-card,
.shortcuts-card,
.activity-card {
    min-width: 0;
    overflow: hidden;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.shortcut-btn {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid var(--line);
    transition: var(--transition);
    min-width: 0;
}

.shortcut-btn:hover {
    transform: translateY(-2px);
    border-color: #bfdbfe;
    background: #eff6ff;
}

.shortcut-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 18px;
    flex-shrink: 0;
}

.shortcut-text {
    min-width: 0;
    flex: 1;
}

.shortcut-text strong {
    display: block;
    font-size: 14px;
    color: var(--text);
    line-height: 1.35;
    word-break: break-word;
}

.shortcut-text span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
    word-break: break-word;
}

.mini-list {
    display: grid;
    gap: 12px;
}

.mini-list-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid var(--line);
    min-width: 0;
}

.mini-list-item > div:first-child {
    min-width: 0;
    flex: 1;
}

.mini-list-item > div:last-child {
    flex-shrink: 0;
    text-align: right;
}

.mini-list-item strong {
    display: block;
    margin-bottom: 4px;
    line-height: 1.35;
    word-break: break-word;
}

.mini-list-item small {
    color: var(--muted);
    line-height: 1.4;
    word-break: break-word;
}

/* =========================
   OVERLAY / MOBILE
   ========================= */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 999;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 992px) {
    .menu-toggle,
    .sidebar-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    .main {
        margin-left: 0;
    }

    .topbar {
        padding: 16px;
    }

    .topbar-title {
        font-size: 18px;
    }

    .topbar-subtitle {
        font-size: 12px;
    }

    .content {
        padding: 16px;
    }

    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .topbar .menu-toggle,
    .topbar .menu-toggle i {
        color: #ffffff !important;
        background: #1e293b !important;
    }
}

@media (max-width: 768px) {
    .mini-list-item {
        flex-direction: column;
    }

    .mini-list-item > div:last-child {
        text-align: left;
    }
}

@media (max-width: 640px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-right {
        width: 100%;
    }

    .topbar-user {
        width: 100%;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .card p {
        font-size: 26px;
    }

    .caixa-login {
        padding: 24px;
        border-radius: 18px;
    }

    .shortcut-btn {
        padding: 12px;
    }

    .shortcut-icon {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
}

/* =========================
   PRINT
   ========================= */
@media print {
    .sidebar,
    .topbar,
    .page-actions,
    .print-actions,
    .filters-card {
        display: none !important;
    }

    .main,
    .content {
        margin: 0 !important;
        padding: 0 !important;
    }

    body {
        background: #fff !important;
    }

    .table-card,
    .detail-card,
    .kpi-card,
    .filters-card,
    .chart-card,
    .shortcuts-card,
    .activity-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}