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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #ffffff;
    color: #333;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

body.sidebar-open {
    overflow: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    transition: margin-left 0.3s ease;
}

/* Sidebar não empurra o conteúdo - fica por cima */

.header {
    background: #ffffff;
    color: #1e3a8a;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-bottom: 3px solid #3b82f6;
    position: relative;
    z-index: 100;
    transition: margin-left 0.3s ease;
}

/* Header não é empurrado pelo sidebar */

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.header-left {
    flex: 1;
}

.header h1 {
    font-size: 2rem;
    color: #1e3a8a;
    font-weight: 700;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1.5rem;
}

.header-logo {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.logo-img {
    max-height: 70px;
    max-width: 200px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.header-tool {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #eff6ff;
    color: #1e3a8a;
    text-decoration: none;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.header-tool:hover {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1e40af;
    transform: rotate(90deg);
}

.header-tool.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #2563eb;
}

.main-nav {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #1e3a8a;
    text-decoration: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    transition: all 0.3s;
    font-weight: 500;
    background: #eff6ff;
    border: 2px solid transparent;
    white-space: nowrap;
    vertical-align: top;
}

.nav-item:hover {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1e40af;
    transform: translateY(-1px);
}

.nav-item.active {
    background: #3b82f6;
    color: #ffffff;
    border-color: #2563eb;
}

.nav-item.active .nav-icon {
    filter: brightness(0) invert(1);
}

.nav-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.nav-group {
    display: inline-flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    vertical-align: top;
    min-width: fit-content;
}

.nav-group-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.5px;
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
}

.nav-group-items {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-group .nav-item {
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

.main-content {
    flex: 1;
    padding: 2rem;
    transition: margin-left 0.3s ease;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 280px;
    height: 100vh;
    background: #ffffff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
    border-right: 3px solid #3b82f6;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    background: #f8fafc;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: #1e3a8a;
    margin: 0;
    font-weight: 700;
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: #e2e8f0;
    color: #1e3a8a;
}

#sidebar-open {
    background: #eff6ff;
    border: 2px solid transparent;
    color: #1e3a8a;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 1rem;
}

#sidebar-open:hover {
    background: #dbeafe;
    border-color: #3b82f6;
}

.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #475569;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-item:hover {
    background: #f1f5f9;
    color: #1e3a8a;
    border-left-color: #3b82f6;
}

.sidebar-item.active {
    background: #eff6ff;
    color: #1e3a8a;
    border-left-color: #3b82f6;
    font-weight: 600;
}

.sidebar-icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-text {
    flex: 1;
}

.sidebar-section {
    margin: 1rem 0;
}

.sidebar-section-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.5px;
    padding: 0.5rem 1.5rem;
    margin-bottom: 0.25rem;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 769px) {
    .sidebar-overlay {
        display: block;
    }
    
    .sidebar-overlay.active {
        opacity: 0.5;
        visibility: visible;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 280px;
    }
}

.footer {
    background: #333;
    color: white;
    width: 100%;
    padding: 1rem;
    margin-top: auto;
    transition: margin-left 0.3s ease;
}

/* Footer não é empurrado pelo sidebar */

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-section span {
    margin: 0 0.5rem;
    color: #ccc;
}

.footer a {
    color: #fff;
    text-decoration: none;
    transition: color 0.3s;
}

.footer a:hover {
    color: #3b82f6;
}

/* Cards e Boxes */
.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #3b82f6;
}

.card-header h2 {
    color: #1e3a8a;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Botões */
.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

/* Formulários */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

/* Tabelas */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

table th {
    background: #3b82f6;
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #eee;
}

table tr:hover {
    background: #f8f9fa;
}

table tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}

/* Alertas */
.alert {
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Dashboard Stats */
.stats-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 1rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.stat-card {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1 1 0;
    min-width: 0;
}

.stat-card h3 {
    color: #3b82f6;
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
    line-height: 1;
}

.stat-card p {
    color: #666;
    font-size: 0.8rem;
    margin: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #3b82f6;
}

.modal-header h2 {
    color: #1e3a8a;
    margin: 0;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    background: none;
}

.close:hover {
    color: #000;
}

/* Ações rápidas */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#materiais-table {
    background: #fff;
}

#materiais-table tbody tr.material-row {
    background: #fff;
}

#materiais-table tbody tr.material-row:hover {
    background: #f9fafb;
}

#materiais-table tbody tr.material-row td {
    padding: 0.75rem;
    vertical-align: middle;
}

#materiais-table tbody tr.material-row td select,
#materiais-table tbody tr.material-row td input[type="number"] {
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.9rem;
}

#materiais-table tbody tr.material-row td select:focus,
#materiais-table tbody tr.material-row td input[type="number"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    .header-content {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .header-left {
        width: 100%;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .header-logo {
        width: 100%;
        justify-content: center;
    }
    
    .logo-img {
        max-height: 60px;
        max-width: 150px;
    }
    
    .main-nav {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .stat-card {
        flex: 1 1 calc(50% - 0.375rem);
        min-width: 140px;
        padding: 0.75rem;
    }
    
    .stat-card h3 {
        font-size: 1.5rem;
    }
    
    .stat-card p {
        font-size: 0.75rem;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    table th,
    table td {
        padding: 0.5rem;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .footer-section {
        justify-content: center;
        flex-wrap: wrap;
    }
}

/* Impressão */
@media print {
    .header,
    .main-nav,
    .footer,
    .btn,
    .action-buttons {
        display: none;
    }
    
    .main-content {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
