:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent: #f59e0b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --radius: 8px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-width); background: var(--text); color: #fff; position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; transition: width .2s; z-index: 100; }
.sidebar.collapsed { width: 0; overflow: hidden; }
.sidebar-brand { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand h2 { font-size: 1.25rem; }
.sidebar-brand small { color: var(--text-muted); font-size: .75rem; }
.sidebar-nav { list-style: none; padding: 8px 0; }
.sidebar-nav li a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #cbd5e1; text-decoration: none; font-size: .9rem; transition: background .15s; }
.sidebar-nav li a:hover, .sidebar-nav li a.active { background: var(--primary); color: #fff; }
.sidebar-nav .nav-section { padding: 16px 20px 4px; font-size: .7rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1px; }

/* Content */
.content { margin-left: var(--sidebar-width); flex: 1; min-height: 100vh; transition: margin-left .2s; }
.sidebar.collapsed ~ .content { margin-left: 0; }
.topbar { height: var(--topbar-height); background: var(--card); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 50; }
.sidebar-toggle { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: .9rem; color: var(--text-muted); }
.page-content { padding: 24px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h2 { font-size: 1.15rem; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; }
.stat-card .stat-label { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }
.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.danger { border-left: 4px solid var(--danger); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: var(--radius); font-size: .875rem; cursor: pointer; text-decoration: none; transition: background .15s; font-weight: 500; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-ai { background: linear-gradient(135deg, #8b5cf6, #6366f1); color: #fff; }
.btn-ai:hover { background: linear-gradient(135deg, #7c3aed, #4f46e5); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; font-size: .8rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: .5px; }
tr:hover { background: #f8fafc; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; font-family: inherit; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { appearance: auto; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: .75rem; font-weight: 600; }
.badge-planning { background: #dbeafe; color: #1d4ed8; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-on_hold { background: #fef3c7; color: #92400e; }
.badge-completed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-not_started { background: #e2e8f0; color: #475569; }
.badge-in_progress { background: #dbeafe; color: #1d4ed8; }
.badge-low { background: #d1fae5; color: #065f46; }
.badge-medium { background: #fef3c7; color: #92400e; }
.badge-high { background: #fed7aa; color: #9a3412; }
.badge-critical { background: #fee2e2; color: #991b1b; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal { background: var(--card); border-radius: var(--radius); width: 90%; max-width: 700px; max-height: 80vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header button { background: none; border: none; font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 20px; }
.modal-body pre { background: var(--bg); padding: 16px; border-radius: var(--radius); white-space: pre-wrap; font-size: .85rem; line-height: 1.6; }

/* AI */
.ai-loading { text-align: center; padding: 40px; color: var(--primary); font-size: 1.1rem; }
.ai-result { line-height: 1.7; }
.ai-result h4 { margin: 12px 0 6px; }
.ai-result ul { padding-left: 20px; }
.ai-result li { margin-bottom: 4px; }

/* Gantt */
.gantt-container { overflow-x: auto; position: relative; }
.gantt-table { min-width: 300px; }
.gantt-chart { position: relative; min-height: 200px; }
.gantt-row { display: flex; align-items: center; height: 36px; border-bottom: 1px solid var(--border); position: relative; }
.gantt-bar { height: 22px; border-radius: 4px; background: var(--primary); position: absolute; min-width: 4px; display: flex; align-items: center; padding: 0 6px; font-size: .7rem; color: #fff; white-space: nowrap; overflow: hidden; }
.gantt-bar.milestone { width: 16px !important; height: 16px; transform: rotate(45deg); background: var(--accent); border-radius: 2px; }
.gantt-header { display: flex; border-bottom: 2px solid var(--border); font-size: .7rem; color: var(--text-muted); }
.gantt-header-cell { text-align: center; border-right: 1px solid var(--border); padding: 4px 0; min-width: 36px; }
.gantt-grid-cell { min-width: 36px; border-right: 1px solid #f1f5f9; height: 100%; }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 5; }
.gantt-bar-progress { height: 100%; background: rgba(255,255,255,.3); border-radius: 4px 0 0 4px; }

/* WBS Tree */
.wbs-tree { padding: 0; }
.wbs-node { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); margin: 4px 0; background: var(--card); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.wbs-node:hover { border-color: var(--primary); }
.wbs-children { padding-left: 28px; border-left: 2px solid var(--border); margin-left: 14px; }
.wbs-code { font-weight: 700; color: var(--primary); margin-right: 8px; }

/* Progress bar */
.progress { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s; }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* Login page */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1e293b, #334155); }
.login-box { background: var(--card); padding: 40px; border-radius: var(--radius); width: 100%; max-width: 400px; }
.login-box h1 { text-align: center; margin-bottom: 8px; }
.login-box .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: .9rem; }
.login-box .btn { width: 100%; justify-content: center; padding: 12px; }
.alert { padding: 10px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: .9rem; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }

/* EVM Chart area */
.evm-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.evm-metric { text-align: center; padding: 16px; background: var(--bg); border-radius: var(--radius); }
.evm-metric .value { font-size: 1.5rem; font-weight: 700; }
.evm-metric .label { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 0; overflow: hidden; }
    .sidebar.show { width: var(--sidebar-width); }
    .content { margin-left: 0 !important; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
