:root {
  --primary: #0D9488;
  --primary-dark: #0F766E;
  --primary-light: #5EEAD4;
  --primary-bg: #F0FDFA;
  --secondary: #6366F1;
  --danger: #EF4444;
  --warning: #F59E0B;
  --success: #10B981;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --sidebar-width: 260px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

.sidebar {
  width: var(--sidebar-width); background: white;
  border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; gap: 12px; }
.sidebar-logo { width: 40px; height: 40px; background: var(--primary); border-radius: 10px; display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 18px; }
.sidebar-title h2 { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.sidebar-title span { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-section { margin-bottom: 8px; }
.nav-section-label { font-size: 11px; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--gray-600); font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer; transition: all 0.15s ease; border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-item.active { background: var(--primary-bg); color: var(--primary-dark); font-weight: 600; }
.nav-item .nav-icon { font-size: 20px; width: 24px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--gray-200); }
.user-info { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.user-avatar { width: 36px; height: 36px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: 600; font-size: 14px; }
.user-details { flex: 1; min-width: 0; }
.user-details .name { font-size: 13px; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-details .role { font-size: 11px; color: var(--gray-400); text-transform: capitalize; }
.btn-logout { background: none; border: none; color: var(--gray-400); cursor: pointer; font-size: 18px; padding: 4px; transition: color 0.15s; }
.btn-logout:hover { color: var(--danger); }

.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; }
.page-header { background: white; border-bottom: 1px solid var(--gray-200); padding: 20px 32px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.page-header p { font-size: 13px; color: var(--gray-500); margin-top: 2px; }
.page-body { padding: 24px 32px; }
.hamburger { display: none; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--gray-700); padding: 4px; }
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 99; }

.card { background: white; border-radius: var(--radius); border: 1px solid var(--gray-200); padding: 20px; transition: box-shadow 0.2s; }
.card:hover { box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 600; color: var(--gray-800); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; border-radius: var(--radius); border: 1px solid var(--gray-200); padding: 20px; display: flex; align-items: flex-start; gap: 16px; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.stat-icon.teal { background: #CCFBF1; color: var(--primary); }
.stat-icon.blue { background: #DBEAFE; color: #3B82F6; }
.stat-icon.amber { background: #FEF3C7; color: #D97706; }
.stat-icon.red { background: #FEE2E2; color: #EF4444; }
.stat-icon.purple { background: #EDE9FE; color: #7C3AED; }
.stat-icon.green { background: #D1FAE5; color: #059669; }
.stat-info h3 { font-size: 28px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-info p { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 14px; color: var(--gray-800); background: white; transition: border-color 0.15s, box-shadow 0.15s; font-family: inherit; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,0.1); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--gray-700); cursor: pointer; }
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: all 0.15s ease; font-family: inherit; text-decoration: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger { background: #FEE2E2; color: #991B1B; }
.badge-info { background: #DBEAFE; color: #1E40AF; }

.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--gray-200); font-size: 14px; }
th { font-weight: 600; color: var(--gray-500); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; background: var(--gray-50); }
tr:hover td { background: var(--gray-50); }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-200); margin-bottom: 24px; overflow-x: auto; }
.tab { padding: 10px 20px; border: none; background: none; font-size: 14px; font-weight: 500; color: var(--gray-500); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; transition: all 0.15s; }
.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

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

.edu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.edu-card { background: white; border-radius: var(--radius); border: 1px solid var(--gray-200); overflow: hidden; cursor: pointer; transition: all 0.2s; }
.edu-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.edu-card-thumb { height: 160px; display: flex; align-items: center; justify-content: center; font-size: 48px; color: white; }
.edu-card-body { padding: 16px; }
.edu-card-body h3 { font-size: 15px; font-weight: 600; color: var(--gray-800); margin-bottom: 8px; line-height: 1.4; }
.edu-card-body p { font-size: 13px; color: var(--gray-500); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.edu-card-footer { padding: 12px 16px; border-top: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.edu-category { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--primary); }

.chat-container { display: flex; flex-direction: column; height: calc(100vh - 200px); min-height: 400px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-bubble { max-width: 70%; padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.5; }
.chat-bubble.sent { align-self: flex-end; background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.chat-bubble.received { align-self: flex-start; background: var(--gray-100); color: var(--gray-800); border-bottom-left-radius: 4px; }
.chat-bubble .time { font-size: 11px; opacity: 0.7; margin-top: 4px; }
.chat-input-bar { display: flex; gap: 12px; padding: 16px; border-top: 1px solid var(--gray-200); background: white; }
.chat-input-bar input { flex: 1; }
.chat-list-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--gray-100); cursor: pointer; transition: background 0.15s; }
.chat-list-item:hover { background: var(--gray-50); }
.chat-list-item.active { background: var(--primary-bg); }

.risk-meter { display: flex; align-items: center; gap: 12px; }
.risk-bar { flex: 1; height: 8px; background: var(--gray-200); border-radius: 999px; overflow: hidden; }
.risk-bar-fill { height: 100%; border-radius: 999px; transition: width 0.5s ease; }
.risk-low .risk-bar-fill { background: var(--success); }
.risk-medium .risk-bar-fill { background: var(--warning); }
.risk-high .risk-bar-fill { background: var(--danger); }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal { background: white; border-radius: var(--radius); width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--gray-400); }
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 12px; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0D9488 0%, #6366F1 100%); padding: 20px; }
.login-card { background: white; border-radius: 20px; padding: 48px 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.login-card h1 { text-align: center; font-size: 26px; font-weight: 700; color: var(--gray-900); margin-bottom: 8px; }
.login-card .subtitle { text-align: center; font-size: 14px; color: var(--gray-500); margin-bottom: 32px; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 20px; background: var(--primary); border-radius: 16px; display: flex; align-items: center; justify-content: center; color: white; font-size: 28px; font-weight: 700; }
.login-error { background: #FEE2E2; color: #991B1B; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.demo-accounts { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--gray-200); }
.demo-accounts h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-400); margin-bottom: 10px; }
.demo-account { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--gray-50); border-radius: var(--radius-sm); margin-bottom: 6px; font-size: 13px; cursor: pointer; transition: background 0.15s; }
.demo-account:hover { background: var(--primary-bg); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-400); }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--gray-600); margin-bottom: 8px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item label { font-size: 12px; color: var(--gray-400); display: block; }
.detail-item span { font-size: 14px; font-weight: 500; color: var(--gray-800); }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .page-header { padding: 16px 20px; }
  .page-header h1 { font-size: 18px; }
  .page-body { padding: 16px 20px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-row, .grid-2 { grid-template-columns: 1fr; }
  .form-row-3, .grid-3 { grid-template-columns: 1fr; }
  .edu-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .chat-bubble { max-width: 85%; }
  .modal { max-width: 100%; margin: 10px; }
  .login-card { padding: 32px 24px; }
  .stat-card { padding: 14px; }
  .stat-icon { width: 40px; height: 40px; font-size: 20px; }
  .stat-info h3 { font-size: 22px; }
  table { font-size: 13px; }
  th, td { padding: 8px 10px; }
  .tabs { gap: 0; }
  .tab { padding: 8px 14px; font-size: 13px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-body { padding: 12px 16px; }
}
