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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Login Screen */
#loginScreen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 400px;
    width: 90%;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    color: #333;
    margin-bottom: 10px;
}

.login-header p {
    color: #666;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* Error Message */
.error-message {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 5px;
    margin-top: 15px;
    font-size: 13px;
}

/* Main App */
#mainApp {
    min-height: 100vh;
    background: #f5f7fa;
}

/* Header */
.app-header {
    background: white;
    padding: 15px 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left h1 {
    font-size: 24px;
    color: #333;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

#usernameDisplay {
    color: #666;
    font-size: 14px;
}

/* Navigation */
.app-nav {
    background: white;
    padding: 0 30px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    gap: 5px;
    overflow-x: auto;
}

.nav-item {
    padding: 15px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
    white-space: nowrap;
}

.nav-item:hover {
    background: #f8f9fa;
    color: #333;
}

.nav-item.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* Content */
.app-content {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

.page h2 {
    font-size: 28px;
    color: #333;
    margin-bottom: 20px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    text-align: center;
}

.stat-value {
    font-size: 48px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 16px;
    color: #666;
}

/* Info Card */
.info-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.info-card h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
}

.info-card p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
}

/* Filter Card */
.filter-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.filter-card h3 {
    font-size: 18px;
    color: #333;
    margin-bottom: 15px;
}

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

.filter-grid input,
.filter-grid select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.filter-grid input:focus,
.filter-grid select:focus {
    outline: none;
    border-color: #667eea;
}

/* Alert */
.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

/* Result Container */
.result-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 20px;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
}

.result-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    font-weight: 500;
    color: #333;
    border-bottom: 2px solid #dee2e6;
}

.result-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    color: #666;
}

.result-table tr:hover {
    background: #f8f9fa;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.pagination-controls span {
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

/* Button Sizes */
.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

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

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

.btn-danger {
    background: #dc3545;
}

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

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

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

/* Form Groups */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

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

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 10px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.detail-section {
    margin-bottom: 25px;
}

.detail-section h3 {
    font-size: 18px;
    color: #667eea;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

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

.detail-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
}

.detail-item strong {
    color: #555;
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    text-transform: uppercase;
}

.detail-observacoes {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #667eea;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.contratos-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contrato-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #28a745;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 15px;
    }

    .app-content {
        padding: 15px;
    }

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

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

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #28a745;
}

input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

.perm-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.perm-item:last-child {
    border-bottom: none;
}

.perm-section {
    margin-top: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 15px;
    background: #f9f9f9;
}

.perm-section h4 {
    margin-bottom: 15px;
    color: #333;
}

.perm-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.perm-grid .perm-item {
    border-bottom: none;
    background: white;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

/* Dark Mode Toggle Button */
.btn-dark-mode {
    background: #2c3e50;
    color: white;
    font-size: 18px;
    padding: 8px 16px;
}

.btn-dark-mode:hover {
    background: #34495e;
}

/* Dark Mode Styles */
body.dark-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode #loginScreen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

body.dark-mode .login-container {
    background: #1e1e2e;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

body.dark-mode .login-header h1,
body.dark-mode .login-header p {
    color: #e0e0e0;
}

body.dark-mode .form-group label {
    color: #e0e0e0;
}

body.dark-mode .form-group input {
    background: #2a2a3e;
    border-color: #3a3a4e;
    color: #e0e0e0;
}

body.dark-mode .form-group input:focus {
    border-color: #667eea;
    background: #2f2f3f;
}

body.dark-mode #mainApp {
    background: #0f0f1e;
}

body.dark-mode .app-header {
    background: #1e1e2e;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.dark-mode .header-left h1 {
    color: #e0e0e0;
}

body.dark-mode #usernameDisplay {
    color: #b0b0c0;
}

body.dark-mode .app-nav {
    background: #1e1e2e;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

body.dark-mode .nav-item {
    color: #b0b0c0;
}

body.dark-mode .nav-item:hover {
    background: #2a2a3e;
    color: #e0e0e0;
}

body.dark-mode .nav-item.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

body.dark-mode .page h2 {
    color: #e0e0e0;
}

body.dark-mode .stat-card,
body.dark-mode .info-card,
body.dark-mode .filter-card,
body.dark-mode .result-container,
body.dark-mode .pagination-controls {
    background: #1e1e2e;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

body.dark-mode .stat-label,
body.dark-mode .info-card h3,
body.dark-mode .info-card p,
body.dark-mode .filter-card h3 {
    color: #e0e0e0;
}

body.dark-mode .filter-grid input,
body.dark-mode .filter-grid select,
body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea {
    background: #2a2a3e;
    border-color: #3a3a4e;
    color: #e0e0e0;
}

body.dark-mode .filter-grid input:focus,
body.dark-mode .filter-grid select:focus,
body.dark-mode .form-group input:focus,
body.dark-mode .form-group select:focus,
body.dark-mode .form-group textarea:focus {
    border-color: #667eea;
    background: #2f2f3f;
}

body.dark-mode .result-table th {
    background: #2a2a3e;
    color: #e0e0e0;
    border-bottom-color: #3a3a4e;
}

body.dark-mode .result-table td {
    color: #b0b0c0;
    border-bottom-color: #2a2a3e;
}

body.dark-mode .result-table tr:hover {
    background: #252535;
}

body.dark-mode .no-results {
    color: #808090;
}

body.dark-mode .pagination-controls span {
    color: #b0b0c0;
}

body.dark-mode .alert-warning {
    background: #3a3020;
    border-color: #5a5030;
    color: #e0c080;
}

body.dark-mode .modal-overlay {
    background: rgba(0,0,0,0.85);
}

body.dark-mode .modal-content {
    background: #1e1e2e;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

body.dark-mode .modal-header {
    border-bottom-color: #3a3a4e;
}

body.dark-mode .modal-header h2 {
    color: #e0e0e0;
}

body.dark-mode .modal-close {
    color: #808090;
}

body.dark-mode .modal-close:hover {
    color: #e0e0e0;
}

body.dark-mode .modal-footer {
    border-top-color: #3a3a4e;
}

body.dark-mode .detail-section h3 {
    color: #667eea;
    border-bottom-color: #2a2a3e;
}

body.dark-mode .detail-item {
    background: #2a2a3e;
}

body.dark-mode .detail-item strong {
    color: #b0b0c0;
}

body.dark-mode .detail-observacoes {
    background: #2a2a3e;
    border-left-color: #667eea;
    color: #e0e0e0;
}

body.dark-mode .contrato-item {
    background: #2a2a3e;
    border-left-color: #28a745;
}

body.dark-mode .perm-section {
    background: #2a2a3e;
    border-color: #3a3a4e;
}

body.dark-mode .perm-section h4 {
    color: #e0e0e0;
}

body.dark-mode .perm-item {
    border-bottom-color: #3a3a4e;
    color: #e0e0e0;
}

body.dark-mode .perm-grid .perm-item {
    background: #252535;
    border-color: #3a3a4e;
}
