:root {
    /* Light Mode (Default) */
    --bg-dark: #f0f4f9;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(0, 0, 0, 0.1);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-blue: #0ea5e9;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-purple: #a855f7;
    --gradient-bg: linear-gradient(135deg, #f0f4f9 0%, #e2e8f0 100%);
    --sidebar-bg: #ffffff;
    --chart-text: #334155;
    --grid-line: rgba(0, 0, 0, 0.05);
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-text: #1e293b;
}

[data-theme="dark"] {
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #38bdf8;
    --accent-green: #4ade80;
    --accent-red: #f87171;
    --accent-purple: #c084fc;
    --gradient-bg: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --sidebar-bg: #1e293b;
    --chart-text: #cbd5e1;
    --grid-line: rgba(255, 255, 255, 0.05);
    --input-bg: #334155;
    --input-border: #475569;
    --input-text: #f1f5f9;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--gradient-bg);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Glassmorphism Utility */
.glass {
    background: var(--glass-bg);
    /* backdrop-filter: blur(12px); Performance Optimization */
    /* -webkit-backdrop-filter: blur(12px); Performance Optimization */
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.05);
}

/* Sidebar */
.sidebar {
    width: 260px;
    margin: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--sidebar-bg);
    border-radius: 16px;
    overflow: hidden;
    /* Prevent full sidebar scroll */
    height: calc(100vh - 32px);
    /* Full height minus margins */
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 20px;
    /* Reduced margin */
    flex-shrink: 0;
    /* Keep logo fixed */
}

.sidebar nav {
    flex: 1;
    /* Take available space */
    overflow-y: auto;
    /* Scroll inside nav if needed */
    margin-bottom: 20px;
    padding-right: 5px;
    /* Space for scrollbar */
}

/* Custom scrollbar for nav */
.sidebar nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar nav::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav li {
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--grid-line);
    flex-shrink: 0;
    /* Keep profile fixed at bottom */
}



.sidebar nav li:hover,
.sidebar nav li.active {
    background: rgba(56, 189, 248, 0.15);
    /* More visible in light */
    color: var(--accent-blue);
    font-weight: 500;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 16px 16px 16px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (max-width: 768px) {
    .main-content {
        padding: 10px !important;
    }

    .top-bar {
        padding: 10px 15px !important;
    }
}

.top-bar {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.view-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    /* Tighter gap */
}

@media (min-width: 1024px) {
    .kpi-grid {
        grid-template-columns: 2fr 1fr 1fr 1fr;
    }
}

.kpi-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
    overflow: hidden;
    min-height: 100px;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.kpi-card.green-accent::before {
    background: var(--accent-green);
}

.kpi-card.blue-accent::before {
    background: var(--accent-blue);
}

.kpi-card.red-accent::before {
    background: var(--accent-red);
}

.kpi-card.purple-accent::before {
    background: var(--accent-purple);
}

.kpi-card .icon {
    font-size: 1.5rem;
    margin-bottom: 5px;
    opacity: 0.8;
}

.kpi-card.green-accent .icon {
    color: var(--accent-green);
}

.kpi-card.blue-accent .icon {
    color: var(--accent-blue);
}

.kpi-card.red-accent .icon {
    color: var(--accent-red);
}

.kpi-card.purple-accent .icon {
    color: var(--accent-purple);
}

.kpi-card .value {
    font-size: 1.6rem;
    font-weight: 700;
    white-space: nowrap;
}

.kpi-grid .kpi-card:not(:first-child) .value {
    font-size: 1.4rem;
}

.kpi-card .label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Charts - COMPACT ROW */
.charts-grid {
    display: grid;
    /* Force 4 columns on large screens, scroll or wrap on small */
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    height: 280px;
    /* Fixed height for row */
    overflow: hidden;
    /* Hide overflow */
}

@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: repeat(2, 1fr);
        height: auto;
    }
}

.chart-container {
    padding: 15px;
    position: relative;
    height: 100%;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Flexbox trick for chartjs resizing */
}

.chart-container h3 {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
    /* Important for flex child */
}

/* Fade-in animation for charts and KPIs */
/* Cards Investimentos por Programa */
.invest-prog-card {
    background: #ffffff;
}
[data-theme="dark"] .invest-prog-card {
    background: var(--glass-bg);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-bar {
    0%, 100% { opacity: 0.25; }
    50% { opacity: 0.6; }
}
/* Bar chart placeholder: barras crescem de 0 até altura final */
@keyframes bar-grow-1 {
    from { height: 0%; opacity: 0; }
    to { height: 30%; opacity: 1; }
}
@keyframes bar-grow-2 {
    from { height: 0%; opacity: 0; }
    to { height: 55%; opacity: 1; }
}
@keyframes bar-grow-3 {
    from { height: 0%; opacity: 0; }
    to { height: 80%; opacity: 1; }
}
@keyframes bar-grow-4 {
    from { height: 0%; opacity: 0; }
    to { height: 45%; opacity: 1; }
}
@keyframes bar-grow-5 {
    from { height: 0%; opacity: 0; }
    to { height: 65%; opacity: 1; }
}
/* Horizontal bar chart placeholder: barras crescem da esquerda */
@keyframes bar-h-grow {
    from { max-width: 0%; opacity: 0; }
    to { opacity: 1; }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--glass-border) 25%, rgba(255,255,255,0.15) 50%, var(--glass-border) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}
.skeleton-bar { height: 14px; margin: 6px 0; }
.skeleton-bar-lg { height: 22px; margin: 8px 0; width: 60%; }
.skeleton-chart {
    height: 160px;
    margin-top: 12px;
    border-radius: 8px;
}
.chart-container.animate-in {
    animation: fadeInUp 0.6s ease-out forwards;
}
.kpi-card.animate-in {
    animation: fadeInUp 0.5s ease-out forwards;
}

/* Tables */
.recent-items,
.full-table-container {
    padding: 24px;
    overflow: hidden;
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--accent-blue);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.table-responsive {
    overflow-x: auto;
}

.full-height {
    height: calc(100vh - 200px);
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-primary);
}

th {
    text-align: left;
    padding: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

tr:hover td {
    background: rgba(0, 0, 0, 0.05);
    /* Light mode hover */
}

[data-theme="dark"] tr:hover td {
    background: rgba(255, 255, 255, 0.06);
}

/* Status Badges */
.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Colors for inputs in Light Mode needs contrast */
.table-controls input,
.table-controls select,
input,
select {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 8px;
    outline: none;
}

[data-theme="dark"] .table-controls input,
[data-theme="dark"] input,
[data-theme="dark"] select {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
}

[data-theme="dark"] select option {
    background: #1e293b;
    color: #f1f5f9;
}

/* Filtros de visão geral — adaptam ao tema */
.filter-select {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    padding: 5px 10px;
}

[data-theme="dark"] .filter-select {
    background: rgba(0, 0, 0, 0.3);
    color: #f1f5f9;
    border-color: #555;
}

.drop-zone {
    margin-top: 30px;
    border: 2px dashed var(--text-secondary);
    border-radius: 16px;
    padding: 60px;
    cursor: pointer;
    transition: all 0.3s;
}

.drop-zone:hover {
    border-color: var(--accent-blue);
    background: rgba(56, 189, 248, 0.05);
}

.drop-zone i {
    font-size: 3rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.drop-zone input {
    display: none;
}

.instructions {
    margin-top: 40px;
    text-align: left;
    background: var(--glass-bg);
    padding: 24px;
    border-radius: 12px;
}

.instructions li {
    margin-left: 20px;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.table-controls {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.table-controls input {
    flex: 1;
}

/* NEW: Filter Grid & Summaries for Projects View */
.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--sidebar-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    align-items: end;
}

.filter-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select,
.filter-group input {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--input-text);
    padding: 10px;
    border-radius: 8px;
    width: 100%;
    outline: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.filter-group select:focus {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.2);
}

/* Summary Cards */
.summary-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.summary-card-small {
    background: var(--sidebar-bg);
    padding: 20px;
    border-radius: 12px;
    border-left: 5px solid var(--accent-green);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.summary-card-small:last-child {
    border-left-color: var(--accent-blue);
}

.summary-card-small .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 6px;
}

.summary-card-small .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

#form-novo input,
#form-novo select {
    background: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    color: var(--input-text) !important;
}

/* Campo técnico — visualmente cinza mas editável (Nova Inclusão) */
#form-novo input.campo-tecnico,
#form-novo select.campo-tecnico {
    background: #adb5bd !important;
    border: 1px dashed #3b82f6 !important;
    color: #212529 !important;
    opacity: 1 !important;
}
#form-novo input.campo-tecnico::placeholder {
    color: #495057 !important;
}
[data-theme="dark"] #form-novo input.campo-tecnico,
[data-theme="dark"] #form-novo select.campo-tecnico {
    background: #374151 !important;
    color: #d1d5db !important;
}

/* Campo técnico bloqueado — totalmente desabilitado (Edição de registro existente) */
#form-novo input.campo-tecnico-bloqueado,
#form-novo select.campo-tecnico-bloqueado {
    background: #adb5bd !important;
    border: 1px dashed #3b82f6 !important;
    color: #212529 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    opacity: 1 !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}
#form-novo input.campo-tecnico-bloqueado::placeholder {
    color: #495057 !important;
}

/* Campo pendente do técnico — amarelo */
#form-novo input.campo-pendente-tecnico,
#form-novo select.campo-pendente-tecnico {
    background: #fde047 !important;
    border: 2px solid #eab308 !important;
    color: #1a1a1a !important;
    font-weight: bold !important;
}

/* Campo vencido do técnico — vermelho */
#form-novo input.campo-vencido-tecnico,
#form-novo select.campo-vencido-tecnico {
    background: #ef4444 !important;
    border: 2px solid #dc2626 !important;
    color: #ffffff !important;
    font-weight: bold !important;
}

/* Modal Technical Proposal Enhanced */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.modal-overlay.active {
    display: flex !important;
    opacity: 1;
}


@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content.tech-proposal {
    background: var(--bg-dark);
    width: 100%;
    max-width: 950px;
    max-height: 95vh;
    border-radius: 24px;
    border: 1px solid var(--accent-blue);
    position: relative;
    overflow-y: auto;
    padding: 50px;
    box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.7);
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content.tech-proposal {
    transform: scale(1);
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background: var(--accent-red);
    color: white;
    transform: rotate(90deg);
}

.tech-header {
    text-align: center;
    margin-bottom: 40px;
}

.azure-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.2rem;
    color: #0078d4;
    margin-bottom: 15px;
}

.azure-logo i {
    font-size: 2rem;
}

.tech-header h2 {
    font-size: 2.2rem;
    margin-bottom: 10px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tech-header .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.tech-proposal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.tech-card {
    background: var(--glass-bg);
    padding: 25px;
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    display: flex;
    gap: 20px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
}

.modal-overlay.active .tech-card {
    animation: cardEntry 0.5s ease forwards;
}

.modal-overlay.active .tech-card:nth-child(1) {
    animation-delay: 0.1s;
}

.modal-overlay.active .tech-card:nth-child(2) {
    animation-delay: 0.2s;
}

.modal-overlay.active .tech-card:nth-child(3) {
    animation-delay: 0.3s;
}

.modal-overlay.active .tech-card:nth-child(4) {
    animation-delay: 0.4s;
}

@keyframes cardEntry {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tech-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-blue);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.2);
}

.card-icon {
    font-size: 2.5rem;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: rgba(14, 165, 233, 0.1);
    border-radius: 12px;
    flex-shrink: 0;
}

.card-content h3 {
    font-size: 1.2rem;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.card-content p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-top: 10px;
}

/* Timeline */
.migration-timeline {
    margin-top: 20px;
    padding: 30px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

[data-theme="dark"] .migration-timeline {
    background: rgba(255, 255, 255, 0.02);
}

.migration-timeline h3 {
    margin-bottom: 25px;
    text-align: center;
    color: var(--accent-green);
}

.timeline-steps {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    position: relative;
}

.timeline-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 40px;
    right: 40px;
    height: 2px;
    background: var(--glass-border);
    z-index: 1;
}

.step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    z-index: 2;
}

.step-num {
    width: 40px;
    height: 40px;
    background: var(--sidebar-bg);
    border: 2px solid var(--accent-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-bottom: 12px;
    color: var(--accent-green);
    box-shadow: 0 0 15px rgba(74, 222, 128, 0.2);
}

.step-text {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    max-width: 120px;
}

@media (max-width: 768px) {
    .timeline-steps {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .timeline-steps::before {
        display: none;
    }

    .step {
        flex-direction: row;
        gap: 15px;
        text-align: left;
    }

    .step-text {
        max-width: none;
    }
}

.tech-footer {
    margin-top: 40px;
    text-align: center;
}

.tech-footer p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-style: italic;
    max-width: 600px;
    margin: 0 auto;
}

.ms-badge {
    background: #0078d4;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
}

.choice-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

.choice-card.accent:hover {
    box-shadow: 0 10px 30px -10px rgba(0, 120, 212, 0.3);
}