:root {
    --bg-body: #f3f4f6; --bg-card: #ffffff; --text-main: #1f2937; --text-muted: #6b7280;
    --primary: #4f46e5; --primary-hover: #4338ca; --success: #10b981; --warning: #f59e0b;
    --danger: #ef4444; --info: #0ea5e9; --radius: 12px;
    --sidebar-bg: #1e293b; --sidebar-text: #94a3b8; --sidebar-active: #4f46e5;
    --border-color: rgba(255,255,255,0.5); --glass-bg: rgba(255, 255, 255, 0.8);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

[data-theme="dark"] {
    --bg-body: #0f172a; --bg-card: #1e293b; --text-main: #f1f5f9; --text-muted: #94a3b8;
    --primary: #6366f1; --primary-hover: #818cf8; --success: #22c55e; --warning: #f59e0b;
    --danger: #ef4444; --info: #38bdf8; --radius: 12px;
    --sidebar-bg: #020617; --sidebar-text: #64748b; --sidebar-active: #6366f1;
    --border-color: rgba(255,255,255,0.1); --glass-bg: rgba(30, 41, 59, 0.8);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; font-family: 'Segoe UI', system-ui, sans-serif; }
body { margin: 0; background-color: var(--bg-body); color: var(--text-main); display: flex; height: 100vh; overflow: hidden; transition: background-color 0.3s, color 0.3s; }

.security-badge { position: fixed; bottom: 10px; right: 10px; background: #10b981; color: white; padding: 5px 10px; border-radius: 20px; font-size: 0.7rem; z-index: 10000; opacity: 0.8; }

.theme-toggle { position: fixed; top: 20px; right: 20px; z-index: 10001; background: var(--glass-bg); backdrop-filter: blur(10px); border: 1px solid var(--border-color); color: var(--text-main); width: 45px; height: 45px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; transition: all 0.3s; box-shadow: var(--shadow); }
.theme-toggle:hover { transform: scale(1.1); }
.theme-toggle .fa-sun { display: none; }
[data-theme="dark"] .theme-toggle .fa-sun { display: block; }
[data-theme="dark"] .theme-toggle .fa-moon { display: none; }

.mobile-menu-toggle { display: none; position: fixed; top: 20px; left: 20px; z-index: 10002; background: var(--primary); color: white; width: 45px; height: 45px; border-radius: 8px; border: none; cursor: pointer; font-size: 1.2rem; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }

#login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(135deg, #1e293b 0%, #4f46e5 100%); z-index: 9999; display: flex; justify-content: center; align-items: center; flex-direction: column; }
.login-container { background: white; padding: 40px; border-radius: var(--radius); box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); width: 100%; max-width: 400px; animation: slideIn 0.5s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: translateY(0); } }
.login-logo { text-align: center; margin-bottom: 30px; font-size: 2rem; font-weight: 800; color: var(--primary); }
.login-logo i { font-size: 3rem; margin-bottom: 10px; display: block; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--text-main); }
.login-form input { width: 100%; padding: 12px 15px; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 1rem; transition: all 0.3s; }
.login-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
.login-btn { width: 100%; padding: 12px; background: var(--primary); color: white; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: background 0.3s; }
.login-btn:hover { background: var(--primary-hover); }
.login-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.login-error { color: var(--danger); text-align: center; margin-top: 15px; font-size: 0.9rem; display: none; padding: 10px; background: #fee2e2; border-radius: 6px; }

.sidebar { width: 260px; background: var(--sidebar-bg); color: white; padding: 20px; display: flex; flex-direction: column; flex-shrink: 0; transition: transform 0.3s ease, background-color 0.3s; z-index: 1000; }
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 999; }
.logo { font-size: 1.5rem; font-weight: 800; margin-bottom: 40px; color: white; display: flex; align-items: center; gap: 10px; }
.logo span { color: white; font-weight: 300; }
.user-badge { background: rgba(255,255,255,0.1); padding: 10px 15px; border-radius: 8px; margin-bottom: 20px; font-size: 0.85rem; display: flex; align-items: center; gap: 10px; border: 1px solid rgba(255,255,255,0.2); }
.user-badge i { font-size: 1.2rem; }
.user-badge.admin { background: rgba(79, 70, 229, 0.3); border-color: rgba(79, 70, 229, 0.5); }
.user-badge.client { background: rgba(16, 185, 129, 0.3); border-color: rgba(16, 185, 129, 0.5); }
.nav-item { padding: 12px 15px; margin-bottom: 5px; border-radius: 8px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; color: var(--sidebar-text); font-weight: 500; }
.nav-item:hover { background: #334155; color: white; }
.nav-item.active { background: var(--sidebar-active); color: white; }
.nav-item i { margin-right: 12px; width: 20px; text-align: center; }
.sidebar-footer { margin-top: auto; padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 0.75rem; color: white; text-align: center; line-height: 1.6; }
.logout-btn { margin-top: 10px; width: 100%; padding: 10px; background: rgba(239, 68, 68, 0.2); color: #fecaca; border: 1px solid rgba(239, 68, 68, 0.3); border-radius: 6px; cursor: pointer; font-size: 0.85rem; transition: all 0.2s; }
.logout-btn:hover { background: rgba(239, 68, 68, 0.4); }

.main-content { flex: 1; padding: 30px; overflow-y: auto; position: relative; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; flex-wrap: wrap; gap: 15px; }
h1 { margin: 0; font-size: 1.8rem; }

.search-box { position: relative; width: 300px; max-width: 100%; }
.search-box input { width: 100%; padding: 10px 15px 10px 40px; border: 1px solid var(--border-color); border-radius: 20px; outline: none; transition: 0.3s; background: var(--glass-bg); color: var(--text-main); }
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1); }
.search-box i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: #9ca3af; }

.dashboard-widgets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-bottom: 25px; }
.widget-card { background: var(--glass-bg); backdrop-filter: blur(10px); border: 1px solid var(--border-color); box-shadow: var(--shadow); padding: 20px; border-radius: var(--radius); display: flex; align-items: center; gap: 15px; transition: transform 0.2s; }
.widget-card:hover { transform: translateY(-2px); }
.widget-icon { width: 50px; height: 50px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.widget-info { display: flex; flex-direction: column; }
.widget-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
.widget-value { font-size: 1.5rem; font-weight: 800; color: var(--text-main); }

.btn { background: var(--primary); color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; transition: 0.2s; }
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-outline { background: var(--glass-bg); border: 1px solid var(--border-color); color: var(--text-main); padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; transition: 0.2s; backdrop-filter: blur(5px); }
.btn-outline:hover { background: rgba(255, 255, 255, 0.9); border-color: #9ca3af; }
[data-theme="dark"] .btn-outline:hover { background: rgba(30, 41, 59, 0.9); }
.btn-pdf { background: #dc2626; color: white; } .btn-pdf:hover { background: #b91c1c; }
.btn-icon { background: none; border: none; cursor: pointer; padding: 6px; font-size: 1.1rem; transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn-edit { color: var(--primary); } .btn-delete { color: #ef4444; } .btn-link { color: var(--info); }
.btn-archive { color: #64748b; } .btn-archive:hover { color: var(--warning); transform: scale(1.1); }
.btn-restore { color: var(--success); }

.view-section { display: none; animation: fadeIn 0.3s ease; }
.view-section.active-view { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; height: calc(100vh - 270px); overflow-x: auto; overflow-y: hidden; } 
.column { border-radius: var(--radius); padding: 15px; display: flex; flex-direction: column; transition: background-color 0.2s; height: 100%; background: var(--glass-bg); backdrop-filter: blur(5px); border: 1px solid var(--border-color); min-width: 300px; }
.column.drag-over { border: 2px dashed var(--primary); background: rgba(203, 213, 225, 0.8); }
.column-header { font-weight: 700; margin-bottom: 15px; display: flex; justify-content: space-between; color: var(--text-muted); text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px; }
.task-list { flex: 1; overflow-y: auto; padding-right: 5px; min-height: 100px; }

.card { padding: 15px; border-radius: 8px; margin-bottom: 15px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); border-left: 4px solid transparent; cursor: grab; transition: transform 0.2s, box-shadow 0.2s; user-select: none; display: flex; flex-direction: column; background: rgba(255, 255, 255, 0.75); backdrop-filter: blur(10px); border: 1px solid var(--border-color); }
[data-theme="dark"] .card { background: rgba(30, 41, 59, 0.75); }
.card:active { cursor: grabbing; } 
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.1); } 
.card.dragging { opacity: 0.5; border: 2px dashed #9ca3af; }

.status-todo .card { background: rgba(255, 255, 255, 0.75); border-left-color: var(--text-muted); }
[data-theme="dark"] .status-todo .card { background: rgba(30, 41, 59, 0.75); border-left-color: #64748b; }
.status-inprogress .card { background: rgba(254, 249, 195, 0.85); border-left-color: #ca8a04; }
[data-theme="dark"] .status-inprogress .card { background: rgba(113, 63, 18, 0.3); border-left-color: #eab308; }
.status-done .card { background: rgba(220, 252, 231, 0.85); border-left-color: var(--success); }
[data-theme="dark"] .status-done .card { background: rgba(20, 83, 45, 0.3); border-left-color: #22c55e; }
.card-info-box { font-size:0.75rem; color:var(--text-muted); margin-bottom:10px; background:var(--glass-bg); padding:8px; border-radius:6px; border:1px solid var(--border-color); }

.data-table { width: 100%; border-collapse: collapse; background: var(--glass-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); backdrop-filter: blur(10px); border: 1px solid var(--border-color); table-layout: fixed; }
.data-table th { background: rgba(248, 250, 252, 0.9); text-align: left; padding: 15px 10px; font-size: 0.85rem; text-transform: uppercase; color: var(--text-muted); font-weight: 700; border-bottom: 2px solid var(--border-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[data-theme="dark"] .data-table th { background: rgba(15, 23, 42, 0.9); }
.data-table td { padding: 15px 10px; border-bottom: 1px solid var(--border-color); vertical-align: middle; color: var(--text-main); text-align: left; overflow: hidden; text-overflow: ellipsis; }
.data-table tr:hover { background: rgba(249, 250, 251, 0.5); }
[data-theme="dark"] .data-table tr:hover { background: rgba(30, 41, 59, 0.5); }

.data-table th:nth-child(1), .data-table td:nth-child(1) { width: 18%; }
.data-table th:nth-child(2), .data-table td:nth-child(2) { width: 12%; }
.data-table th:nth-child(3), .data-table td:nth-child(3) { width: 16%; }
.data-table th:nth-child(4), .data-table td:nth-child(4) { width: 11%; }
.data-table th:nth-child(5), .data-table td:nth-child(5) { width: 11%; }
.data-table th:nth-child(6), .data-table td:nth-child(6) { width: 8%; }
.data-table th:nth-child(7), .data-table td:nth-child(7) { width: 10%; }
.data-table th:nth-child(8), .data-table td:nth-child(8) { width: 14%; text-align: right; }
.data-table td:last-child { text-align: right; white-space: nowrap; }

.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
.badge-todo { background: rgba(243, 244, 246, 0.9); color: #4b5563; } 
[data-theme="dark"] .badge-todo { background: rgba(75, 85, 99, 0.3); color: #d1d5db; }
.badge-inprogress { background: rgba(224, 231, 255, 0.9); color: var(--primary); } 
.badge-done { background: rgba(209, 250, 229, 0.9); color: var(--success); }
.badge-active { background: rgba(220, 252, 231, 0.9); color: #166534; } 
.badge-canceled { background: rgba(254, 226, 226, 0.9); color: #991b1b; }
.badge-admin { background: rgba(224, 231, 255, 0.9); color: #4f46e5; } 
.badge-client { background: rgba(219, 234, 254, 0.9); color: #1e40af; }
.badge-locked { background: rgba(254, 226, 226, 0.9); color: #991b1b; } 
.badge-unlocked { background: rgba(209, 250, 229, 0.9); color: #166534; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--glass-bg); backdrop-filter: blur(10px); border: 1px solid var(--border-color); box-shadow: var(--shadow); padding: 25px; border-radius: var(--radius); }
.stat-title { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--text-main); }
.text-green { color: var(--success); } .text-blue { color: var(--primary); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.settings-card { background: var(--glass-bg); backdrop-filter: blur(10px); border: 1px solid var(--border-color); box-shadow: var(--shadow); padding: 30px; border-radius: var(--radius); display: flex; flex-direction: column; }
.settings-icon { font-size: 2rem; margin-bottom: 15px; color: var(--primary); }
.settings-h3 { margin: 0 0 10px 0; font-size: 1.2rem; color: var(--text-main); }
.settings-p { color: var(--text-muted); margin-bottom: 20px; font-size: 0.9rem; line-height: 1.5; flex: 1; }

.user-status-active { color: var(--success); font-weight: 600; }
.user-status-locked { color: var(--danger); font-weight: 600; }
.user-row-locked { opacity: 0.6; background: rgba(249, 250, 251, 0.6); }

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 1000; padding: 20px; }
.modal-content { background: var(--glass-bg); backdrop-filter: blur(20px); border: 1px solid var(--border-color); padding: 0; border-radius: var(--radius); width: 1450px; max-width: 100%; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; }
.modal-header { position: sticky; top: 0; background: var(--glass-bg); backdrop-filter: blur(20px); z-index: 10; padding: 20px 30px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; color: var(--text-main); }
.modal-body { padding: 30px; overflow-y: auto; }
.modal-content-small { width: 600px; }
.modal-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 0.9rem; font-weight: 600; color: var(--text-main); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 6px; font-size: 0.95rem; background: var(--glass-bg); color: var(--text-main); }
.form-group textarea { resize: vertical; min-height: 80px; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; padding: 20px 30px; border-top: 1px solid var(--border-color); background: var(--glass-bg); position: sticky; bottom: 0; z-index: 10; }

input[readonly] { background-color: rgba(243, 244, 246, 0.6); color: #6b7280; cursor: not-allowed; }
[data-theme="dark"] input[readonly] { background-color: rgba(30, 41, 59, 0.6); }

.tool-container { background: var(--glass-bg); padding: 15px; border-radius: 8px; border: 1px solid var(--border-color); margin-top: 15px; backdrop-filter: blur(5px); }
.tool-header { font-weight: 600; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--text-main); }
.tool-list { list-style: none; padding: 0; margin: 0; max-height: 150px; overflow-y: auto; }
.tool-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border-color); font-size: 0.9rem; color: var(--text-main); }
.tool-item:last-child { border-bottom: none; }
.time-input-row { display: flex; gap: 5px; margin-bottom: 10px; }

.client-view #header-actions { display: none; }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--glass-bg); backdrop-filter: blur(10px); color: var(--text-main); padding: 15px 20px; border-radius: 8px; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-left: 4px solid var(--primary); animation: slideInRight 0.3s ease; max-width: 300px; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 25px; margin-bottom: 30px; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; }
.chart-container { background: var(--glass-bg); backdrop-filter: blur(10px); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 25px; box-shadow: var(--shadow); }
.chart-container h3 { margin: 0 0 20px 0; font-size: 1.1rem; color: var(--text-main); display: flex; align-items: center; gap: 10px; }
.chart-wrapper { position: relative; height: 300px; }
.chart-wrapper-small { position: relative; height: 250px; }

.profitability-indicator { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; }
.profitability-high { background: rgba(16, 185, 129, 0.2); color: #059669; border: 1px solid rgba(16, 185, 129, 0.3); }
.profitability-medium { background: rgba(245, 158, 11, 0.2); color: #d97706; border: 1px solid rgba(245, 158, 11, 0.3); }
.profitability-low { background: rgba(239, 68, 68, 0.2); color: #dc2626; border: 1px solid rgba(239, 68, 68, 0.3); }

.budget-progress { width: 100%; height: 8px; background: rgba(0,0,0,0.1); border-radius: 4px; overflow: hidden; margin-top: 8px; }
[data-theme="dark"] .budget-progress { background: rgba(255,255,255,0.1); }
.budget-progress-bar { height: 100%; border-radius: 4px; transition: width 0.5s ease, background-color 0.3s; }
.budget-progress-bar.low { background: var(--success); }
.budget-progress-bar.medium { background: var(--warning); }
.budget-progress-bar.high { background: var(--danger); }

.budget-info { display: flex; justify-content: space-between; font-size: 0.8rem; margin-top: 5px; color: var(--text-muted); }
.budget-alert { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); padding: 10px; border-radius: 6px; margin-top: 10px; font-size: 0.85rem; display: none; }
.budget-alert.show { display: flex; align-items: center; gap: 8px; }

.efficiency-score { display: flex; align-items: center; gap: 10px; }
.efficiency-circle { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem; position: relative; }
.efficiency-circle::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 4px solid transparent; border-top-color: currentColor; transform: rotate(-45deg); }
.efficiency-excellent { color: #10b981; }
.efficiency-good { color: #0ea5e9; }
.efficiency-warning { color: #f59e0b; }
.efficiency-danger { color: #ef4444; }

.profit-card { background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05)); border: 1px solid rgba(16, 185, 129, 0.2); }
.loss-card { background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05)); border: 1px solid rgba(239, 68, 68, 0.2); }

@media (max-width: 768px) {
    .mobile-menu-toggle { display: flex; align-items: center; justify-content: center; }
    .sidebar { position: fixed; left: 0; top: 0; height: 100vh; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { padding: 80px 15px 15px 15px; width: 100%; }
    .board { display: flex; overflow-x: auto; overflow-y: hidden; height: calc(100vh - 200px); }
    .column { min-width: 85vw; max-width: 85vw; }
    .dashboard-widgets, .settings-grid, .stats-grid, .charts-grid, .charts-row { grid-template-columns: 1fr; }
    .modal-content { width: 100%; height: 100%; max-height: 100vh; border-radius: 0; }
    .modal-grid-2 { grid-template-columns: 1fr; }
    .data-table { display: block; overflow-x: auto; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }