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

:root {
    --primary: #3b82f6;
    --primary-dark: #1e40af;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --light: #f3f4f6;
    --dark: #1f2937;
    --text: #374151;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--light);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 20px 0;
    margin-bottom: 30px;
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
}

nav {
    display: flex;
    gap: 30px;
}

nav a {
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    transition: color 0.3s;
}

nav a:hover,
nav a.active {
    color: var(--primary);
}

/* Main Content */
main {
    margin-bottom: 40px;
}

.page-title {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 30px;
    color: var(--dark);
}

.page-subtitle {
    color: #6b7280;
    margin-top: -15px;
    margin-bottom: 25px;
}

.page-header {
    margin-bottom: 20px;
}

.page-header__title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.page-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.unidade-selector {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 200px;
    max-width: 240px;
}

.unidade-selector label {
    font-weight: 600;
    color: #4b5563;
}

.unidade-selector select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    width: 100%;
}

#unidade-contexto {
    color: #6b7280;
    font-size: 12px;
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    transition: box-shadow 0.3s;
}

.card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.card-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--dark);
}

.card-header {
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
    padding-bottom: 12px;
}

.card-header__row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.card-header__row h2 {
    margin: 0;
}

.card-header__row p {
    margin: 4px 0 0;
    color: #6b7280;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.tabela-vazia {
    text-align: center;
    color: #9ca3af;
    padding: 30px 10px;
}

/* Grid */
.grid {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Ferramentas */
.tools-header {
    display: flex;
    gap: 30px;
    align-items: stretch;
}

.tools-header__copy {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tools-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 12px;
    color: var(--primary);
}

.tools-lead {
    color: #4b5563;
}

.tools-header__cta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tools-header__meta {
    flex-basis: 320px;
    background: #0f172a;
    color: white;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tools-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 12px;
}

.tools-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    font-size: 13px;
}

.tools-stat strong {
    font-size: 20px;
    display: block;
}

.tools-panels {
    margin-top: 40px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.tool-panel {
    background: white;
    border-radius: 18px;
    padding: 24px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 15px 35px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tool-panel__header {
    display: flex;
    gap: 14px;
    align-items: center;
}

.tool-panel__icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.18), rgba(59, 130, 246, 0.05));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.tool-panel__body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tool-panel__button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 12px;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Indicadores */
.indicador {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.indicador.completo {
    background: linear-gradient(135deg, var(--secondary) 0%, #059669 100%);
}

.indicador.andamento {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
}

.indicador.nao-iniciado {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

.indicador-valor {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 5px;
}

.indicador-label {
    font-size: 14px;
    opacity: 0.9;
}

/* Tabelas */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    background-color: var(--light);
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--dark);
    border-bottom: 2px solid #e5e7eb;
    cursor: pointer;
    user-select: none;
}

th:hover {
    background-color: #e5e7eb;
}

td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
}

tbody tr:hover {
    background-color: var(--light);
}

tbody tr.completo {
    background-color: #f0fdf4;
}

tbody tr.andamento {
    background-color: #fffbeb;
}

tbody tr.nao-iniciado {
    background-color: #fef2f2;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background-color: #cffafe;
    color: #164e63;
}

/* Botões */
.btn {
    display: inline-block;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background-color: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background-color: #059669;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Formulários */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input[type="checkbox"],
input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
}

.checkbox-item label {
    margin-bottom: 0;
    margin-left: 8px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.15);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 24px;
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text);
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* Filtros */
.filtros {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.filtro-grupo {
    display: flex;
    flex-direction: column;
}

.filtro-grupo label {
    margin-bottom: 5px;
    font-size: 13px;
}

.filtro-grupo select,
.filtro-grupo input {
    font-size: 13px;
}

/* Paginação */
.paginacao {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin-top: 20px;
}

.paginacao a,
.paginacao span {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text);
    font-size: 13px;
}

.paginacao a:hover {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.paginacao .ativo {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Gráficos */
.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 20px;
}

/* Alertas */
.alert {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-success {
    background-color: #f0fdf4;
    border-color: var(--secondary);
    color: #065f46;
}

.alert-danger {
    background-color: #fef2f2;
    border-color: var(--danger);
    color: #991b1b;
}

.alert-warning {
    background-color: #fffbeb;
    border-color: var(--warning);
    color: #92400e;
}

.alert-info {
    background-color: #f0f9ff;
    border-color: var(--info);
    color: #164e63;
}

/* Loading */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsivo */
@media (max-width: 768px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    nav {
        gap: 15px;
    }

    table {
        font-size: 12px;
    }

    th,
    td {
        padding: 8px;
    }

    .filtros {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .tools-header {
        flex-direction: column;
    }

    .tools-header__meta {
        flex-basis: auto;
    }

    .tools-header__cta {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Modo Escuro */
body.dark-mode {
    background-color: #1f2937;
    color: #e5e7eb;
}

body.dark-mode .card,
body.dark-mode .filtros,
body.dark-mode header {
    background-color: #374151;
    color: #e5e7eb;
}

body.dark-mode table {
    background-color: #374151;
    color: #e5e7eb;
}

body.dark-mode thead {
    background-color: #4b5563;
}

body.dark-mode th {
    color: #e5e7eb;
    border-bottom-color: #4b5563;
}

body.dark-mode td {
    border-bottom-color: #4b5563;
}

body.dark-mode tbody tr:hover {
    background-color: #4b5563;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: #4b5563;
    color: #e5e7eb;
    border-color: #5a6b7a;
}

body.dark-mode .modal-content {
    background-color: #374151;
    color: #e5e7eb;
}

body.dark-mode .page-title {
    color: #e5e7eb;
}
