/**
 * ============================================================================
 * CLINIC-IN-A-BOX - MAIN STYLESHEET
 * ============================================================================
 */

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */

:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --primary-dark: #1e3a8a;
  --secondary: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #06b6d4;

  --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;

  --sidebar-width: 260px;
  --header-height: 64px;
  --border-radius: 8px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  --transition: all 0.2s ease;

  /* Semantic color tokens (light mode defaults) */
  --bg-page: var(--gray-100);
  --bg-card: #ffffff;
  --bg-card-hover: #f9fafb;
  --bg-input: #ffffff;
  --bg-code: var(--gray-100);
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-700);
  --text-muted: var(--gray-500);
  --text-on-card: var(--gray-800);
  --border-color: var(--gray-200);
  --border-light: var(--gray-100);
}

/* ============================================================================
   DARK MODE — "Midnight Cyber" Theme
   ============================================================================ */

[data-theme="dark"] {
  --bg-page: #0b0e18;
  --bg-card: #111527;
  --bg-card-hover: #161b33;
  --bg-card-elevated: #1a2040;
  --bg-input: #0f1325;
  --bg-code: #0a0d1a;
  --text-primary: #f0f2fa;
  --text-secondary: #b8c0d8;
  --text-muted: #6e78a0;
  --text-on-card: #d0d6e8;
  --border-color: rgba(99, 130, 255, 0.12);
  --border-light: rgba(99, 130, 255, 0.06);

  /* Inverted grays with blue undertone — brighter for readability */
  --gray-50: #0e1222;
  --gray-100: #111527;
  --gray-200: rgba(99, 130, 255, 0.12);
  --gray-300: rgba(99, 130, 255, 0.18);
  --gray-400: #6e78a0;
  --gray-500: #8890b0;
  --gray-600: #b8c0d8;
  --gray-700: #d0d6e8;
  --gray-800: #e8ecf5;
  --gray-900: #f0f2fa;

  /* Vibrant neon-tinged colors */
  --primary: #5b8cff;
  --primary-light: #7ba6ff;
  --primary-dark: #3d6fe8;
  --secondary: #fbbf24;
  --success: #00e68a;
  --danger: #ff5c72;
  --warning: #ffb830;
  --info: #00d4ff;

  /* Glow shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 0 1px rgba(91, 140, 255, 0.05);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 1px rgba(91, 140, 255, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 1px rgba(91, 140, 255, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 1px rgba(91, 140, 255, 0.12);

  /* Glow tokens */
  --glow-primary: 0 0 20px rgba(91, 140, 255, 0.15);
  --glow-success: 0 0 20px rgba(0, 230, 138, 0.15);
  --glow-danger: 0 0 20px rgba(255, 92, 114, 0.15);
  --glow-warning: 0 0 20px rgba(255, 184, 48, 0.15);

  color-scheme: dark;
}

/* ── Base ── */
[data-theme="dark"] body {
  background: var(--bg-page);
  color: var(--text-secondary);
}

[data-theme="dark"] h1, [data-theme="dark"] h2,
[data-theme="dark"] h3, [data-theme="dark"] h4,
[data-theme="dark"] h5, [data-theme="dark"] h6 {
  color: var(--text-primary);
}

/* ── Cards with glass effect ── */
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .profile-card,
[data-theme="dark"] .assessment-card,
[data-theme="dark"] .student-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .card:hover,
[data-theme="dark"] .profile-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(91, 140, 255, 0.25);
  box-shadow: var(--shadow-md), var(--glow-primary);
}

[data-theme="dark"] .stat-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-elevated) 100%);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .stat-card:hover {
  border-color: rgba(91, 140, 255, 0.3);
  box-shadow: var(--shadow-md), var(--glow-primary);
  transform: translateY(-2px);
}

[data-theme="dark"] .stat-card .stat-value,
[data-theme="dark"] .stat-card .stat-number {
  color: #7ba6ff;
  text-shadow: 0 0 30px rgba(91, 140, 255, 0.3);
}

/* ── Profile cards ── */
[data-theme="dark"] .profile-card .profile-name,
[data-theme="dark"] .profile-card h3 {
  color: #e4e8f7;
}

[data-theme="dark"] .profile-card .badge {
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

/* ── Inputs with glow focus ── */
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] select option {
  background: #1a1f38;
  color: #e4e8f7;
  padding: 8px;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
  border-color: #5b8cff;
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.15), var(--glow-primary);
  outline: none;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--text-muted);
}

/* ── Tables ── */
[data-theme="dark"] table th {
  background: linear-gradient(180deg, #151b35 0%, #111527 100%);
  color: #7ba6ff;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75em;
  letter-spacing: 0.5px;
  border-bottom: 2px solid rgba(91, 140, 255, 0.2);
}

[data-theme="dark"] table td {
  border-color: rgba(99, 130, 255, 0.06);
}

[data-theme="dark"] table tr:nth-child(even) td {
  background: rgba(91, 140, 255, 0.02);
}

[data-theme="dark"] table tr:hover td {
  background: rgba(91, 140, 255, 0.06);
}

/* ── Code blocks ── */
[data-theme="dark"] code {
  background: var(--bg-code);
  color: #00e6a0;
  border: 1px solid rgba(0, 230, 160, 0.1);
}

[data-theme="dark"] pre {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
}

/* ── Badges and tags with subtle glow ── */
[data-theme="dark"] .badge,
[data-theme="dark"] .tag {
  border: 1px solid rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .badge-success, [data-theme="dark"] .tag-success,
[data-theme="dark"] .badge[style*="background: #d1fae5"],
[data-theme="dark"] .tag[style*="background: #d1fae5"] {
  background: rgba(0, 230, 138, 0.12) !important;
  color: #00e68a !important;
  border-color: rgba(0, 230, 138, 0.2) !important;
}

[data-theme="dark"] .badge-danger, [data-theme="dark"] .tag-danger,
[data-theme="dark"] .badge[style*="background: #fee2e2"],
[data-theme="dark"] .tag[style*="background: #fee2e2"] {
  background: rgba(255, 92, 114, 0.12) !important;
  color: #ff5c72 !important;
  border-color: rgba(255, 92, 114, 0.2) !important;
}

[data-theme="dark"] .badge-warning, [data-theme="dark"] .tag-warning,
[data-theme="dark"] .badge[style*="background: #fef3c7"],
[data-theme="dark"] .tag[style*="background: #fef3c7"] {
  background: rgba(255, 184, 48, 0.12) !important;
  color: #ffb830 !important;
  border-color: rgba(255, 184, 48, 0.2) !important;
}

[data-theme="dark"] .badge-info, [data-theme="dark"] .tag-info,
[data-theme="dark"] .tag[style*="background: #dbeafe"],
[data-theme="dark"] .badge[style*="background: #dbeafe"] {
  background: rgba(91, 140, 255, 0.12) !important;
  color: #7ba6ff !important;
  border-color: rgba(91, 140, 255, 0.2) !important;
}

/* ── Buttons ── */
[data-theme="dark"] .btn-primary,
[data-theme="dark"] a.btn-primary,
[data-theme="dark"] button[class*="btn-primary"] {
  background: linear-gradient(135deg, #3d6fe8, #5b8cff) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 2px 12px rgba(91, 140, 255, 0.3);
}

[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] a.btn-primary:hover {
  background: linear-gradient(135deg, #4f7ff2, #6ba3ff) !important;
  box-shadow: 0 4px 20px rgba(91, 140, 255, 0.45), var(--glow-primary);
  text-decoration: none;
}

[data-theme="dark"] .btn-outline,
[data-theme="dark"] .btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

[data-theme="dark"] .btn-outline:hover,
[data-theme="dark"] .btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(91, 140, 255, 0.3);
  color: #7ba6ff;
  box-shadow: var(--glow-primary);
}

[data-theme="dark"] .btn-success {
  box-shadow: 0 2px 8px rgba(0, 230, 138, 0.2);
}

[data-theme="dark"] .btn-danger {
  box-shadow: 0 2px 8px rgba(255, 92, 114, 0.2);
}

/* ── Modals ── */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-body,
[data-theme="dark"] .dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg), 0 0 60px rgba(91, 140, 255, 0.05);
}

[data-theme="dark"] .modal-header {
  border-color: var(--border-color);
  background: linear-gradient(180deg, var(--bg-card-elevated) 0%, var(--bg-card) 100%);
}

[data-theme="dark"] .modal-footer {
  border-color: var(--border-color);
  background: var(--bg-card);
}

[data-theme="dark"] .modal-overlay,
[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

/* ── Toasts ── */
[data-theme="dark"] .toast {
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}

/* ── Scrollbars ── */
[data-theme="dark"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--bg-page);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: rgba(91, 140, 255, 0.2);
  border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(91, 140, 255, 0.35);
}

/* ── Search bar ── */
[data-theme="dark"] .search-bar,
[data-theme="dark"] input[type="search"],
[data-theme="dark"] .search-input {
  background: var(--bg-input);
  border-color: var(--border-color);
}

/* ── Misc ── */
[data-theme="dark"] hr {
  border-color: var(--border-color);
}

[data-theme="dark"] .empty-state,
[data-theme="dark"] .no-data {
  color: var(--text-muted);
}

[data-theme="dark"] a {
  color: #7ba6ff;
}

[data-theme="dark"] a:hover {
  color: #9dbfff;
}

[data-theme="dark"] ::selection {
  background: rgba(91, 140, 255, 0.3);
  color: #fff;
}

/* ── Nuclear override: force ALL white/light backgrounds dark ── */
/* Pages have embedded <style> blocks with background:white on various classes.
   This rule targets any div/section/main/article/aside/form with a computed
   white-ish background by using a broad selector list. */

/* ── Catch-all: any element with white/light background in dark mode ── */
[data-theme="dark"] .content-area,
[data-theme="dark"] .main-content,
[data-theme="dark"] .page-content,
[data-theme="dark"] .container,
[data-theme="dark"] .wrapper,
[data-theme="dark"] .panel,
[data-theme="dark"] .panel-body,
[data-theme="dark"] .section,
[data-theme="dark"] .section-content,
[data-theme="dark"] .box {
  background-color: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

/* ── Dashboard specific ── */
[data-theme="dark"] .dashboard-content,
[data-theme="dark"] .profile-list,
[data-theme="dark"] .recent-profiles,
[data-theme="dark"] .activity-panel,
[data-theme="dark"] .quick-actions,
[data-theme="dark"] .hero-stats {
  background-color: var(--bg-card);
  border-color: var(--border-color);
}

[data-theme="dark"] .profile-card,
[data-theme="dark"] .profile-item {
  background: var(--bg-card);
  border-color: var(--border-color);
}

[data-theme="dark"] .profile-card:hover,
[data-theme="dark"] .profile-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(91, 140, 255, 0.25);
}

/* ── Workspace specific ── */
[data-theme="dark"] .workspace-content,
[data-theme="dark"] .workspace-panel,
[data-theme="dark"] .part-sidebar,
[data-theme="dark"] .part-list,
[data-theme="dark"] .part-content,
[data-theme="dark"] .deliverable-area,
[data-theme="dark"] .deliverable-editor,
[data-theme="dark"] .output-option,
[data-theme="dark"] .output-card,
[data-theme="dark"] .option-card,
[data-theme="dark"] .work-area,
[data-theme="dark"] .editor-container,
[data-theme="dark"] .notes-area,
[data-theme="dark"] .evidence-area,
[data-theme="dark"] .attachments-area {
  background-color: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

[data-theme="dark"] .part-item,
[data-theme="dark"] .part-card {
  background: var(--bg-card);
  border-color: var(--border-color);
}

[data-theme="dark"] .part-item:hover,
[data-theme="dark"] .part-card:hover {
  background: var(--bg-card-hover);
}

[data-theme="dark"] .part-item.active,
[data-theme="dark"] .part-card.active {
  background: var(--bg-card-hover);
  border-color: rgba(91, 140, 255, 0.3);
}

[data-theme="dark"] .learning-activities,
[data-theme="dark"] .learning-box {
  background: rgba(91, 140, 255, 0.06);
  border-color: rgba(91, 140, 255, 0.15);
}

/* ── Progress page ── */
[data-theme="dark"] .progress-hero,
[data-theme="dark"] .progress-header,
[data-theme="dark"] .progress-stats {
  background: linear-gradient(135deg, #111527 0%, #151b35 100%);
  border-color: var(--border-color);
}

[data-theme="dark"] .progress-card,
[data-theme="dark"] .part-progress-card {
  background: var(--bg-card);
  border-color: var(--border-color);
}

[data-theme="dark"] .progress-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(91, 140, 255, 0.25);
}

/* ── Instructor page ── */
[data-theme="dark"] .instructor-content,
[data-theme="dark"] .student-list,
[data-theme="dark"] .review-queue,
[data-theme="dark"] .submission-card,
[data-theme="dark"] .submission-item,
[data-theme="dark"] .review-card {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

[data-theme="dark"] .submission-card:hover,
[data-theme="dark"] .submission-item:hover {
  background: var(--bg-card-hover);
}

[data-theme="dark"] .tab-content,
[data-theme="dark"] .tab-pane,
[data-theme="dark"] .tab-panel {
  background: transparent;
  color: var(--text-secondary);
}

[data-theme="dark"] .tabs .tab,
[data-theme="dark"] .tab-nav .tab-link,
[data-theme="dark"] .tab-btn {
  color: var(--text-muted);
}

[data-theme="dark"] .tabs .tab.active,
[data-theme="dark"] .tab-nav .tab-link.active,
[data-theme="dark"] .tab-btn.active {
  color: #7ba6ff;
  border-color: #5b8cff;
}

/* ── Admin page ── */
[data-theme="dark"] .admin-content,
[data-theme="dark"] .guac-panel,
[data-theme="dark"] .lane-list,
[data-theme="dark"] .group-list,
[data-theme="dark"] .deploy-form,
[data-theme="dark"] .connection-tree {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

/* ── Interview page ── */
[data-theme="dark"] .chat-container,
[data-theme="dark"] .chat-messages,
[data-theme="dark"] .chat-input-area,
[data-theme="dark"] .message-bubble {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

[data-theme="dark"] .message-bubble.user {
  background: rgba(91, 140, 255, 0.12);
  border-color: rgba(91, 140, 255, 0.2);
}

[data-theme="dark"] .message-bubble.assistant {
  background: var(--bg-card-hover);
}

/* ── Intake form ── */
[data-theme="dark"] .form-section,
[data-theme="dark"] .form-group,
[data-theme="dark"] .form-card,
[data-theme="dark"] .intake-section {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-secondary);
}

[data-theme="dark"] .form-section-header,
[data-theme="dark"] .section-header {
  color: var(--text-primary);
}

[data-theme="dark"] label {
  color: var(--text-secondary);
}

/* ── Generator page ── */
[data-theme="dark"] .generator-form,
[data-theme="dark"] .generator-options,
[data-theme="dark"] .option-group {
  background: var(--bg-card);
  border-color: var(--border-color);
}

/* ── General white background killers ── */
[data-theme="dark"] div[style*="background: white"],
[data-theme="dark"] div[style*="background:#fff"],
[data-theme="dark"] div[style*="background: #fff"],
[data-theme="dark"] div[style*="background-color: white"],
[data-theme="dark"] div[style*="background-color:#fff"],
[data-theme="dark"] div[style*="background-color: #fff"],
[data-theme="dark"] section[style*="background: white"],
[data-theme="dark"] section[style*="background:#fff"] {
  background: var(--bg-card) !important;
  color: var(--text-secondary) !important;
}

/* ── Dropdown and popover ── */
[data-theme="dark"] .dropdown,
[data-theme="dark"] .dropdown-content,
[data-theme="dark"] .popover,
[data-theme="dark"] .tooltip-content {
  background: var(--bg-card-elevated);
  border-color: var(--border-color);
  color: var(--text-secondary);
  box-shadow: var(--shadow-lg);
}

/* ── Status badges ── */
[data-theme="dark"] .status-badge,
[data-theme="dark"] .badge-pending {
  background: rgba(255, 184, 48, 0.12);
  color: #ffb830;
  border: 1px solid rgba(255, 184, 48, 0.2);
}

[data-theme="dark"] .badge-active,
[data-theme="dark"] .status-active {
  background: rgba(0, 230, 138, 0.12);
  color: #00e68a;
  border: 1px solid rgba(0, 230, 138, 0.2);
}

/* ── Progress bars ── */
[data-theme="dark"] .progress-bar,
[data-theme="dark"] progress {
  background: rgba(91, 140, 255, 0.1);
}

[data-theme="dark"] .progress-fill,
[data-theme="dark"] progress::-webkit-progress-bar {
  background: rgba(91, 140, 255, 0.1);
}

[data-theme="dark"] progress::-webkit-progress-value {
  background: linear-gradient(90deg, #3d6fe8, #5b8cff);
}

/* ── Header / top bar ── */
[data-theme="dark"] .top-bar,
[data-theme="dark"] .header-bar,
[data-theme="dark"] .page-header {
  background: var(--bg-page);
  border-color: var(--border-color);
}

/* ── Search input in header ── */
[data-theme="dark"] .search-container input,
[data-theme="dark"] .header-search input {
  background: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-primary);
}

/* ── Checkbox and radio custom styling ── */
[data-theme="dark"] input[type="checkbox"],
[data-theme="dark"] input[type="radio"] {
  accent-color: #5b8cff;
}

/* ── Rich text editor areas ── */
[data-theme="dark"] [contenteditable],
[data-theme="dark"] .ql-editor,
[data-theme="dark"] .editor-content,
[data-theme="dark"] .rich-text-editor {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-color);
}

/* ── File upload areas ── */
[data-theme="dark"] .upload-area,
[data-theme="dark"] .file-drop-zone,
[data-theme="dark"] .dropzone {
  background: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-muted);
}

/* ── Ensure all white backgrounds are caught ── */
[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-gray-50 {
  background-color: var(--bg-card) !important;
}

/* Smooth transition for theme changes */
body,
.card, .stat-card, .profile-card, .assessment-card, .student-card,
input, textarea, select,
table th, table td,
.modal-content, .toast,
.sidebar, .sidebar-footer,
h1, h2, h3, h4, h5, h6,
.btn, button, a, .badge, .tag {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ============================================================================
   RESET & BASE
   ============================================================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--gray-900);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }

p {
  margin-bottom: 1rem;
}

/* ============================================================================
   FORMS
   ============================================================================ */

.form-group {
  margin-bottom: 1.25rem;
  position: relative;
}

select.form-input,
select.form-select {
  position: relative;
  z-index: 1;
  cursor: pointer;
  -webkit-appearance: menulist;
  appearance: menulist;
}

.form-label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--gray-700);
  font-size: 0.9rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg-card, white);
  transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input.error,
.form-select.error {
  border-color: var(--danger);
}

.form-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.form-hint {
  color: var(--gray-500);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-300);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.btn-outline:hover:not(:disabled) {
  background: var(--gray-100);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
}

.btn-sm {
  padding: 0.5rem 0.875rem;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 1rem 1.75rem;
  font-size: 1.05rem;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
}

/* ============================================================================
   CARDS
   ============================================================================ */

.card {
  background: var(--bg-card, white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.card-title {
  font-weight: 600;
  color: var(--gray-800);
  font-size: 1rem;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

/* ============================================================================
   BADGES
   ============================================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

.badge-smb { background: #dbeafe; color: #1e40af; }
.badge-nonprofit { background: #d1fae5; color: #065f46; }
.badge-utility { background: #fef3c7; color: #92400e; }
.badge-k12 { background: #ede9fe; color: #5b21b6; }

.badge-beginner { background: #d1fae5; color: #065f46; }
.badge-intermediate { background: #fef3c7; color: #92400e; }
.badge-advanced { background: #fee2e2; color: #991b1b; }

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

/* ============================================================================
   TABLES
   ============================================================================ */

.table-container {
  overflow-x: auto;
}

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

.table th,
.table td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

.table th {
  background: var(--gray-50);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray-600);
}

.table tbody tr:hover {
  background: var(--gray-50);
}

.table td {
  font-size: 0.9rem;
}

/* ============================================================================
   PAGINATION
   ============================================================================ */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  flex-wrap: wrap;
  gap: 1rem;
}

.pagination-info {
  color: var(--gray-500);
  font-size: 0.9rem;
}

.pagination-buttons {
  display: flex;
  gap: 0.25rem;
}

.page-btn {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--gray-300);
  background: var(--bg-card, white);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
  background: var(--gray-100);
}

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================================
   ALERTS & NOTIFICATIONS
   ============================================================================ */

.alert {
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-info {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background: var(--bg-card, white);
  padding: 1rem 1.25rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  max-width: 400px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--info); }

.toast-icon {
  font-size: 1.25rem;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.toast-message {
  font-size: 0.875rem;
  color: var(--gray-500);
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 1.25rem;
  line-height: 1;
}

/* ============================================================================
   MODALS
   ============================================================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.25rem;
}

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

.modal,
.modal-dialog {
  background: var(--bg-card, white);
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem;
  border-bottom: 1px solid var(--gray-200);
}

.modal-title {
  font-weight: 600;
  font-size: 1.125rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
}

.modal-close:hover {
  color: var(--gray-600);
}

.modal-body {
  padding: 1.25rem;
  max-height: 60vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.loading-spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--border-radius);
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================================================
   UTILITIES
   ============================================================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-small { font-size: 0.875rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

.d-flex { display: flex; }
.d-none { display: none; }
.d-block { display: block; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }

.relative { position: relative; }

/* ============================================================================
   PROGRESS BAR
   ============================================================================ */

.progress-bar {
  height: 0.5rem;
  background: var(--gray-200);
  border-radius: 0.25rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 0.25rem;
  transition: width 0.3s ease;
}
