/* ═══════════════════════════════════════════
   DESIGN TOKENS & CSS VARIABLES
   ═══════════════════════════════════════════ */
   :root {
    --font-display: 'Outfit', 'Noto Sans Arabic', sans-serif;
    --font-body: 'DM Sans', 'Noto Sans Arabic', sans-serif;
    --radius: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  
  [data-theme="dark"] {
  --bg-root: #080b12;
  --bg-surface: rgba(255, 255, 255, 0.025);
  --bg-surface-hover: rgba(255, 255, 255, 0.055);
  --bg-card: rgba(255, 255, 255, 0.038);
  --bg-card-border: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-input-hover: rgba(255, 255, 255, 0.09);
  --bg-hover: rgba(255, 255, 255, 0.07);
  --bg-modal: #0d1117;
  --bg-modal-border: rgba(255, 255, 255, 0.1);
  --text-primary: #eef0f8;
  --text-secondary: #8892a4;
  --text-tertiary: #4e5668;

  --accent: #5de4c7;
  --accent-dim: rgba(93, 228, 199, 0.1);
  --accent-glow: rgba(93, 228, 199, 0.18);
  --accent-2: #80bfff;
  --accent-2-dim: rgba(128, 191, 255, 0.1);
  --accent-3: #c084fc;

  --danger: #ff6b6b;
  --danger-dim: rgba(255, 107, 107, 0.12);
  --danger-border: rgba(255, 107, 107, 0.3);

  --score-1: #ff7575;
  --score-1-bg: rgba(255, 117, 117, 0.12);
  --score-2: #ff9f43;
  --score-2-bg: rgba(255, 159, 67, 0.12);
  --score-3: #fcd34d;
  --score-3-bg: rgba(252, 211, 77, 0.12);
  --score-4: #4ade80;
  --score-4-bg: rgba(74, 222, 128, 0.12);
  --score-5: #5de4c7;
  --score-5-bg: rgba(93, 228, 199, 0.15);

  --divider: rgba(255, 255, 255, 0.065);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.35), 0 1px 4px rgba(0, 0, 0, 0.25);
  --shadow-modal: 0 24px 80px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 60px rgba(93, 228, 199, 0.06);
  --shadow-glow-strong: 0 0 30px rgba(93, 228, 199, 0.15);
}

[data-theme="light"] {
  --bg-root: #f0f2f8;
  --bg-surface: rgba(0, 0, 0, 0.018);
  --bg-surface-hover: rgba(0, 0, 0, 0.04);
  --bg-card: #ffffff;
  --bg-card-border: rgba(0, 0, 0, 0.07);
  --bg-input: rgba(0, 0, 0, 0.04);
  --bg-input-hover: rgba(0, 0, 0, 0.065);
  --bg-hover: rgba(0, 0, 0, 0.05);
  --bg-modal: #ffffff;
  --bg-modal-border: rgba(0, 0, 0, 0.1);
  --text-primary: #1a1f2e;
  --text-secondary: #5a6178;
  --text-tertiary: #8e96aa;

  --accent: #0da882;
  --accent-dim: rgba(13, 168, 130, 0.09);
  --accent-glow: rgba(13, 168, 130, 0.14);
  --accent-2: #2563eb;
  --accent-2-dim: rgba(37, 99, 235, 0.09);
  --accent-3: #9333ea;

  --danger: #dc2626;
  --danger-dim: rgba(220, 38, 38, 0.09);
  --danger-border: rgba(220, 38, 38, 0.25);

  --score-1: #dc2626;
  --score-1-bg: rgba(220, 38, 38, 0.08);
  --score-2: #d97706;
  --score-2-bg: rgba(217, 119, 6, 0.08);
  --score-3: #b45309;
  --score-3-bg: rgba(180, 83, 9, 0.08);
  --score-4: #16a34a;
  --score-4-bg: rgba(22, 163, 74, 0.08);
  --score-5: #0da882;
  --score-5-bg: rgba(13, 168, 130, 0.1);

  --divider: rgba(0, 0, 0, 0.065);
  --shadow-card: 0 2px 16px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 40px rgba(13, 168, 130, 0.04);
  --shadow-glow-strong: 0 0 24px rgba(13, 168, 130, 0.12);
}
  
  /* ═══════════════════════════════════════════
     BASE & RESET
     ═══════════════════════════════════════════ */
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { font-size: 16px; scroll-behavior: smooth; }
  body { font-family: var(--font-body); background: var(--bg-root); color: var(--text-primary); line-height: 1.6; min-height: 100vh; overflow-x: hidden; position: relative; }
  
  /* Custom Scrollbars */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--text-tertiary); border-radius: 3px; opacity: 0.5; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }
  
  .bg-noise { position: fixed; inset: 0; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.018'/%3E%3C/svg%3E"); background-repeat: repeat; pointer-events: none; z-index: 0; }
  
  .screen { display: none !important; position: relative; z-index: 1; }
  .screen.active { display: block !important; }
  #authScreen.active { display: flex !important; align-items: center; justify-content: center; min-height: 100vh;}
  .view { display: none; }
  .view.active { display: block; }
  
  h1, h2, h3 { font-family: var(--font-display); color: var(--text-primary); font-weight: 700; }
  
  .gradient-text {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    background-size: 200% 200%;
    animation: gradientAnim 5s ease infinite;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
    font-family: var(--font-display);
  }
  @keyframes gradientAnim { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
  
  .login-card { width: 100%; max-width: 420px; background: var(--bg-card); border: 1px solid var(--bg-card-border); border-radius: 24px; box-shadow: var(--shadow-modal); backdrop-filter: blur(24px); padding: 40px; }
  .login-header { text-align: center; margin-bottom: 30px; }
  .login-error { color: var(--danger); background: var(--danger-dim); padding: 10px; border-radius: 8px; margin-bottom: 15px; font-size: 0.85rem; border: 1px solid var(--danger-border); }
  
  .form-group { margin-bottom: 20px; text-align: left; }
  .form-group label { display: block; font-size: 0.75rem; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; font-weight: 600; }
  .form-group input, .form-group textarea { width: 100%; background: var(--bg-input); border: 1px solid var(--bg-card-border); color: var(--text-primary); padding: 10px 14px; border-radius: var(--radius-sm); outline: none; transition: var(--transition); }
  .form-group input:focus, .form-group textarea:focus { border-color: var(--accent); background: var(--bg-input-hover); }
  
  .btn { padding: 10px 20px; font-weight: 600; border-radius: var(--radius-sm); border: 1px solid var(--bg-card-border); background: var(--bg-card); color: var(--text-primary); cursor: pointer; transition: var(--transition); }
  .btn:hover:not(:disabled) { background: var(--bg-surface-hover); }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; }
  .btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; border: none; }
  .btn-accent:hover { filter: brightness(1.2); box-shadow: 0 0 15px var(--accent-glow); }
  .btn-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid var(--danger-border); }
  .btn-block { width: 100%; }
  .btn-icon { padding: 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; font-size: 1.2rem; }
  
  #appContainer { max-width: 1200px; margin: 0 auto; padding: 20px; }
  .app-header { display: flex; justify-content: space-between; align-items: center; background: var(--bg-card); padding: 20px; border-radius: var(--radius); margin-bottom: 30px; border: 1px solid var(--bg-card-border); backdrop-filter: blur(10px); }
  .header-actions { display: flex; gap: 15px; align-items: center; }
  .user-badge { background: var(--accent-dim); color: var(--accent); padding: 5px 12px; border-radius: 100px; font-size: 0.8rem; font-weight: 600; }
  .toolbar { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 20px; }
  
  /* Select Checkboxes */
  input[type="checkbox"] { appearance: none; width: 18px; height: 18px; border: 2px solid var(--text-tertiary); border-radius: 4px; cursor: pointer; position: relative; background: var(--bg-input); }
  input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
  input[type="checkbox"]:checked::after { content: '✓'; position: absolute; color: white; font-size: 12px; top: 50%; left: 50%; transform: translate(-50%, -50%); }
  
  /* Tables */
  .grid-wrapper { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--bg-card-border); overflow-x: auto; }
  .project-grid { width: 100%; border-collapse: collapse; text-align: left; }
  .project-grid th { background: var(--bg-surface); padding: 15px; font-size: 0.85rem; color: var(--text-secondary); text-transform: uppercase; font-weight: 600; border-bottom: 1px solid var(--divider); }
  .project-grid td { padding: 15px; border-bottom: 1px solid var(--divider); }
  .project-grid tbody tr { cursor: pointer; transition: var(--transition); }
  .project-grid tbody tr:hover { background: var(--bg-surface-hover); }
  
  /* Modals */
  .modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); z-index: 100; align-items: center; justify-content: center; padding: 20px; }
  .modal-overlay.open { display: flex; }
  .modal { background: var(--bg-modal); width: 100%; max-width: 900px; border-radius: var(--radius); border: 1px solid var(--bg-modal-border); display: flex; flex-direction: column; max-height: 90vh; overflow: hidden; box-shadow: var(--shadow-modal); }
  .modal-header { padding: 20px; border-bottom: 1px solid var(--divider); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
  .modal-close { background: transparent; border: none; color: var(--text-secondary); font-size: 1.5rem; cursor: pointer; }
  #projectForm { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .modal-body { padding: 20px; overflow-y: auto; flex: 1; }
  .modal-footer { padding: 20px; border-top: 1px solid var(--divider); display: flex; justify-content: flex-end; gap: 10px; background: var(--bg-surface); flex-shrink: 0; }
  
  /* Project forms */
  .project-details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
  .form-section-full { grid-column: 1 / -1; }
  .form-divider { border: 0; border-top: 1px solid var(--divider); margin: 20px 0; }
  .project-feedback-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
  
  /* Ratings */
  .modal-questions-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
  .modal-questions-table th, .modal-questions-table td { padding: 10px; border-bottom: 1px solid var(--divider); }
  .modal-questions-table th { color: var(--text-secondary); text-transform: uppercase; text-align: left; }
  .rating-select { display: flex; gap: 5px; }
  .rating-btn { width: 26px; height: 26px; border-radius: 4px; background: var(--bg-input); border: 1px solid var(--bg-card-border); color: var(--text-primary); cursor: pointer; }
  .rating-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
  .notes-input { width: 100%; background: var(--bg-input); border: 1px solid transparent; color: var(--text-primary); padding: 5px; border-radius: 4px; }
  .notes-input:focus { border-color: var(--accent); outline: none; }
  
  /* Comparisons */
  .compare-modal { max-width: 1100px; }
  .comparison-scroll-wrapper { width: 100%; overflow-x: auto; }
  .comparison-table { width: 100%; border-collapse: collapse; min-width: 600px; }
  .comparison-table th, .comparison-table td { padding: 12px; border: 1px solid var(--divider); text-align: center; }
  .comparison-table th:first-child, .comparison-table td:first-child { text-align: left; position: sticky; left: 0; background: var(--bg-modal); z-index: 2; border-right: 2px solid var(--divider); }
  .comparison-table thead th { background: var(--bg-surface); font-weight: 600; color: var(--text-secondary); text-transform: uppercase; font-size: 0.8rem; }
  .compare-score { font-weight: bold; font-size: 1.1rem; }
  .compare-note { display: block; font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; font-style: italic; }
  
  /* Toast */
  .toast-container { position: fixed; top: 20px; right: 20px; z-index: 1000; }
  .toast { background: var(--bg-card); border: 1px solid var(--accent); padding: 15px 20px; border-radius: 8px; color: var(--text-primary); margin-bottom: 10px; box-shadow: var(--shadow-modal); opacity: 0; transform: translateY(-10px); transition: all 0.3s; }
  .toast.visible { opacity: 1; transform: translateY(0); }