:root {
    --primary: #003366;
    --primary-light: #0066CC;
    --primary-dark: #002244;
    --accent: #00a8e8;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #868e96;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    --sidebar-width: 250px;
    --header-height: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: var(--gray-100); color: var(--gray-800); }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width); background: var(--primary); color: #fff;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    display: flex; flex-direction: column; transition: transform 0.3s;
}
.sidebar-header { padding: 20px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h1 { font-size: 22px; margin-bottom: 2px; }
.sidebar-header small { opacity: 0.7; font-size: 12px; }
.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; padding: 12px 20px; color: rgba(255,255,255,0.8);
    text-decoration: none; transition: all 0.2s; cursor: pointer; border: none; background: none;
    width: 100%; font-size: 14px; text-align: left; font-family: inherit;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item .icon { width: 24px; margin-right: 10px; text-align: center; font-size: 16px; }
.sidebar-footer { padding: 15px 20px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 13px; }
.sidebar-footer .user-name { font-weight: 600; }
.sidebar-footer .logout { color: rgba(255,255,255,0.6); cursor: pointer; text-decoration: underline; }
.sidebar-footer .logout:hover { color: #fff; }

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column;
}
.topbar {
    height: var(--header-height); background: #fff; border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; padding: 0 25px; justify-content: space-between;
}
.topbar h2 { font-size: 18px; color: var(--primary); }
.topbar-actions { display: flex; gap: 10px; }
.content-area { padding: 25px; flex: 1; }

/* Cards */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; margin-bottom: 25px; }
.card {
    background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    border: 1px solid var(--gray-200);
}
.card-stat { text-align: center; }
.card-stat .value { font-size: 36px; font-weight: 700; color: var(--primary); }
.card-stat .label { font-size: 14px; color: var(--gray-600); margin-top: 5px; }
.card-stat.success .value { color: var(--success); }
.card-stat.warning .value { color: var(--warning); }
.card-stat.accent .value { color: var(--accent); }

/* Tables */
.table-container { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border: 1px solid var(--gray-200); overflow: hidden; }
.table-header { padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--gray-200); }
.table-header h3 { font-size: 16px; color: var(--gray-800); }
table { width: 100%; border-collapse: collapse; }
thead th {
    background: var(--gray-50); padding: 12px 15px; text-align: left; font-size: 13px;
    font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}
tbody td { padding: 12px 15px; font-size: 14px; border-bottom: 1px solid var(--gray-100); }
tbody tr:hover { background: var(--gray-50); }

/* Buttons */
.btn {
    padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer;
    font-size: 14px; font-weight: 500; transition: all 0.2s; display: inline-flex;
    align-items: center; gap: 6px; text-decoration: none; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: 6px;
    font-size: 14px; transition: border-color 0.3s; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(0,102,204,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group-full { grid-column: 1 / -1; }

/* Badges */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600;
}
.badge-rascunho { background: var(--gray-200); color: var(--gray-700); }
.badge-enviada { background: #e3f2fd; color: #1976d2; }
.badge-aprovada { background: #e8f5e9; color: #2e7d32; }
.badge-reprovada { background: #fce4ec; color: #c62828; }

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 200; display: none;
    align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff; border-radius: 12px; width: 90%; max-width: 800px; max-height: 90vh;
    overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
    padding: 20px 25px; border-bottom: 1px solid var(--gray-200); display: flex;
    justify-content: space-between; align-items: center; position: sticky; top: 0;
    background: #fff; z-index: 1; border-radius: 12px 12px 0 0;
}
.modal-header h3 { font-size: 18px; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--gray-500); }
.modal-body { padding: 25px; }
.modal-footer { padding: 15px 25px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }
.modal-lg { max-width: 1100px; }

/* Search */
.search-bar {
    display: flex; gap: 10px; margin-bottom: 20px;
}
.search-bar input {
    flex: 1; padding: 10px 14px; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 14px;
}
.search-bar input:focus { outline: none; border-color: var(--primary-light); }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 999; }
.toast {
    padding: 12px 20px; border-radius: 8px; margin-bottom: 10px; color: #fff;
    font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); animation: slideIn 0.3s;
    max-width: 400px;
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary-light); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Items selector for proposals */
.item-selector { border: 1px solid var(--gray-300); border-radius: 8px; margin-bottom: 15px; }
.item-selector-header { padding: 10px 15px; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; }
.item-selector-body { max-height: 300px; overflow-y: auto; }
.item-row {
    display: flex; align-items: center; padding: 8px 15px; border-bottom: 1px solid var(--gray-100);
    gap: 10px; font-size: 13px;
}
.item-row:hover { background: var(--gray-50); }
.item-row input[type="number"] { width: 70px; padding: 4px 8px; border: 1px solid var(--gray-300); border-radius: 4px; text-align: center; }
.item-row .item-name { flex: 1; }
.item-row .item-price { width: 120px; text-align: right; font-weight: 600; }

/* Section editor */
.section-editor { margin-bottom: 15px; border: 1px solid var(--gray-300); border-radius: 8px; overflow: hidden; }
.section-header {
    display: flex; align-items: center; padding: 10px 15px; background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200); gap: 10px;
}
.section-header input { flex: 1; border: none; background: transparent; font-weight: 600; font-size: 14px; }
.section-header input:focus { outline: none; }
.section-body textarea { width: 100%; border: none; padding: 15px; min-height: 120px; resize: vertical; font-family: inherit; font-size: 14px; }
.section-body textarea:focus { outline: none; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab {
    padding: 10px 20px; cursor: pointer; font-size: 14px; font-weight: 500;
    color: var(--gray-600); border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: all 0.2s; background: none; border-top: none; border-left: none; border-right: none;
    font-family: inherit;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab:hover { color: var(--primary-light); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .cards-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .modal { width: 95%; }
}

/* Notification dropdown */
.notif-dropdown {
    position: absolute; top: 36px; right: -10px; width: 360px; max-height: 440px;
    background: #fff; border: 1px solid var(--gray-200); border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15); z-index: 300; overflow: hidden;
}
.notif-dropdown-header {
    padding: 12px 16px; border-bottom: 1px solid var(--gray-200);
    display: flex; justify-content: space-between; align-items: center;
    background: var(--gray-50);
}
.notif-dropdown-header strong { font-size: 14px; color: var(--gray-800); }
.notif-dropdown-body { max-height: 370px; overflow-y: auto; }
.notif-item {
    padding: 12px 16px; border-bottom: 1px solid var(--gray-100);
    cursor: pointer; transition: background 0.2s; font-size: 13px;
}
.notif-item:hover { background: var(--gray-50); }
.notif-item.unread { background: #f0f4ff; border-left: 3px solid var(--primary-light); }
.notif-item .notif-msg { color: var(--gray-800); line-height: 1.4; }
.notif-item .notif-time { color: var(--gray-500); font-size: 11px; margin-top: 4px; }

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--gray-500); }
.spinner {
    display: inline-block; width: 30px; height: 30px; border: 3px solid var(--gray-300);
    border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-500); }
.empty-state .icon { font-size: 48px; margin-bottom: 15px; }
.empty-state p { font-size: 16px; }

/* Analysis cards */
.analysis-card {
    background: #fff; border: 1px solid var(--gray-200); border-radius: 8px; padding: 15px; margin-bottom: 10px;
}
.analysis-card h4 { color: var(--primary); margin-bottom: 8px; }
.analysis-card .tags { display: flex; flex-wrap: wrap; gap: 5px; }
.analysis-card .tag {
    background: var(--gray-100); padding: 3px 8px; border-radius: 4px; font-size: 12px;
    color: var(--gray-700); cursor: pointer;
}
.analysis-card .tag:hover { background: var(--primary-light); color: #fff; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}
