  /* ── Legacy tokens — الآن مُعرَّفة في tokens.css ──
     هذا الـ block يُبقي التوافق مع المكونات القديمة ── */
  :root {
    --mono: 'IBM Plex Mono', monospace;
    --sans: 'IBM Plex Sans Arabic', sans-serif;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }

  /* ══ VISUAL ENHANCEMENTS ════════════════════════════════════════
     تحسينات بصرية حقيقية — ألوان حيوية، typography، animations
     ══════════════════════════════════════════════════════════════ */

  /* ─ Body: خط accent على يسار الصفحة ─ */
  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    min-height: 100vh;
    font-size: 14px;
  }

  /* ─ Page Title: أكبر وأقوى ─ */
  .page-title {
    font-size: 24px !important;
    font-weight: 700 !important;
    letter-spacing: -0.03em !important;
    background: linear-gradient(135deg, #f0f0f2 40%, #9d8fff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  /* ─ Stat value: أكبر وأجرأ ─ */
  .stat-value {
    font-size: 28px !important;
    font-weight: 800 !important;
    letter-spacing: -0.04em !important;
    line-height: 1 !important;
  }
  .stat-label {
    font-size: 10px !important;
    font-weight: 600 !important;
    letter-spacing: 0.1em !important;
    text-transform: uppercase !important;
    color: var(--text3) !important;
    margin-bottom: 6px !important;
  }

  /* ─ Accent glow على اليوم الحالي ─ */
  .cal-day.today {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px rgba(124,106,255,0.25), inset 0 0 0 1px rgba(124,106,255,0.4) !important;
    background: rgba(124,106,255,0.12) !important;
  }
  .cal-day.today .day-num { color: var(--accent) !important; font-weight: 700 !important; }

  /* ─ has-value: أوضح ─ */
  .cal-day.has-value {
    background: rgba(124,106,255,0.15) !important;
    border-color: rgba(124,106,255,0.4) !important;
  }

  /* ─ Logo glow ─ */
  #appHeaderLogo {
    text-shadow: 0 0 30px rgba(124,106,255,0.6) !important;
  }

  /* ─ Active nav: glow ─ */
  .hn-btn.active .hn-icon {
    filter: drop-shadow(0 0 6px rgba(124,106,255,0.6));
  }

  /* ─ calc-row highlight: أوضح ─ */
  .calc-row.highlight {
    background: rgba(45,212,138,0.06);
    border-radius: 10px;
    padding: 8px 10px;
    margin: 4px 0;
    border: 1px solid rgba(45,212,138,0.2);
  }
  .calc-row.highlight .calc-label { color: var(--green) !important; font-weight: 600; }

  /* ─ Page animations ─ */
  .page.active { animation: pageIn 0.25s ease both; }
  @keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: none; }
  }

  /* ─ Button hover: lift effect ─ */
  button:not(.cal-btn):not(.cal-day):not(.mob-nav-item):not(.nav-item):not(.hn-btn) {
    transition: transform 0.15s, box-shadow 0.15s;
  }

  /* ─ Countdown: accent border ─ */
  #cycleCountdown {
    border: 1px solid rgba(124,106,255,0.2) !important;
    background: rgba(124,106,255,0.05) !important;
    border-radius: 14px;
  }

  /* ─ Right panel widget title ─ */
  .rp-widget-title {
    font-size: 10px !important;
    font-weight: 700 !important;
    letter-spacing: 0.12em !important;
    text-transform: uppercase !important;
    color: var(--accent) !important;
  }

  /* ─ Summary title ─ */
  .summary-title {
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: 0.1em !important;
    text-transform: uppercase !important;
    color: var(--text3) !important;
    margin-bottom: 14px !important;
  }

  /* ─ Toast: pill shape ─ */
  .toast {
    border-radius: 9999px !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em !important;
    padding: 10px 24px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
  }

  /* ─ Scrollbar accent ─ */
  ::-webkit-scrollbar-thumb:hover {
    background: var(--accent) !important;
  }

  /* ─ Input focus: accent ring ─ */
  .inp:focus, input:focus, textarea:focus, select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(124,106,255,0.2) !important;
    outline: none !important;
  }

  /* ─ Section dividers: accent ─ */
  .nav-sep {
    background: rgba(124,106,255,0.15) !important;
  }



  /* Layout */
  /* ═══════════════════════════════════════════════
     FACEBOOK-STYLE LAYOUT
     Header ثابت + Sidebar يسار + Main وسط + Right Panel
     ═══════════════════════════════════════════════ */

  /* ── Top Header ── */
  #appHeader {
    position: fixed; top: 0; left: 0; right: 0; height: 58px;
    background: #0e0e10;
    border-bottom: 2px solid rgba(124,106,255,0.25);
    z-index: 1000; display: flex; align-items: center;
    padding: 0 20px; gap: 12px;
    box-shadow: 0 2px 20px rgba(0,0,0,0.5);
  }
  #appHeaderLogo {
    font-family: 'Georgia', serif; font-size: 21px; font-weight: 700;
    color: var(--accent);
    letter-spacing: 3px; flex-shrink: 0;
    text-transform: uppercase; cursor: pointer;
    display: flex; align-items: center; gap: 8px;
    text-shadow: 0 0 20px rgba(124,106,255,0.5);
  }
  #appHeaderLogo .logo-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent); box-shadow: 0 0 6px var(--accent);
  }
  #headerNav {
    display: flex; align-items: center; gap: 2px;
    flex: 1; justify-content: center;
    padding: 0 8px;
  }
  .hn-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 8px; cursor: pointer;
    color: var(--text3); font-size: 13px;
    transition: all 0.15s; position: relative;
    border: none; background: none;
    font-weight: 500; font-family: var(--sans);
    white-space: nowrap;
  }
  .hn-btn:hover { background: rgba(255,255,255,0.06); color: var(--text2); }
  .hn-btn.active { color: var(--text); background: rgba(255,255,255,0.08); }
  .hn-btn.active::after {
    content: ''; position: absolute; bottom: -10px; left: 20%; right: 20%;
    height: 2px; background: var(--accent);
    border-radius: 2px 2px 0 0;
    box-shadow: 0 0 8px rgba(124,106,255,0.6);
  }
  .hn-btn .hn-icon { font-size: 13px; line-height: 1; opacity: 0.75; }
  .hn-btn.active .hn-icon { opacity: 1; }
  .hn-btn .hn-badge {
    position: absolute; top: 2px; right: 6px;
    background: var(--red); color: #fff; border-radius: 8px;
    font-size: 9px; padding: 1px 4px; font-family: var(--mono);
    font-weight: 700; min-width: 14px; text-align: center;
  }
  #headerActions {
    display: flex; align-items: center; gap: 4px; flex-shrink: 0;
  }
  .ha-btn {
    width: 32px; height: 32px; border-radius: 7px;
    background: transparent; border: 1px solid transparent;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text3);
    transition: all 0.15s; position: relative;
  }
  .ha-btn:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.10);
    color: var(--text);
  }
  .ha-btn svg { display: block; flex-shrink: 0; }
  .ha-btn-friends:hover { color: var(--accent); background: rgba(124,106,255,0.10); border-color: rgba(124,106,255,0.25); }
  .ha-btn-theme:hover { color: var(--amber); background: rgba(245,166,35,0.10); border-color: rgba(245,166,35,0.25); }
  .ha-btn .ha-badge {
    position: absolute; top: 2px; right: 2px;
    background: var(--red); color: #fff; border-radius: 50%;
    width: 14px; height: 14px; font-size: 9px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
  }
  #headerUserBtn {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 10px 4px 4px; border-radius: 9999px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    cursor: pointer; transition: all 0.15s; flex-shrink: 0;
  }
  #headerUserBtn:hover {
    border-color: rgba(124,106,255,0.45);
    box-shadow: 0 0 0 3px rgba(124,106,255,0.12);
  }
  #headerUserAvatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent); display: flex; align-items: center;
    justify-content: center; font-size: 13px; font-weight: 700;
    color: #fff; font-family: var(--mono); flex-shrink: 0; overflow: hidden;
  }
  #headerUserAvatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
  #headerUserName { font-size: 12px; font-weight: 500; color: var(--text); max-width: 80px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

  /* ── 3-Column Layout ── */
  .app {
    display: grid;
    grid-template-columns: 280px 1fr 300px;
    min-height: 100vh;
    padding-top: 56px;
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
  }
  .sidebar {
    background: transparent;
    border-left: none;
    padding: 16px 12px;
    display: flex; flex-direction: column; gap: 2px;
    position: sticky; top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
  }
  .sidebar::-webkit-scrollbar { width: 0; }
  .main {
    padding: 16px 8px;
    overflow-y: auto;
    min-height: calc(100vh - 56px);
    border-right: 1px solid var(--border);
    border-left: 1px solid var(--border);
  }
  #rightPanel {
    padding: 16px 12px;
    position: sticky; top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
  }
  #rightPanel::-webkit-scrollbar { width: 0; }

  /* ── Sidebar Nav Redesign ── */
  .nav-item {
    padding: 10px 14px; border-radius: 10px; cursor: pointer;
    color: var(--text2); font-size: 14px; transition: all 0.15s;
    display: flex; align-items: center; gap: 12px;
    font-weight: 400;
  }
  .nav-item:hover { background: var(--surface2); color: var(--text); }
  .nav-item.active {
    background: rgba(124,106,255,0.15);
    color: var(--accent); font-weight: 500;
    border-right: 3px solid var(--accent);
    padding-right: 11px;
  }
  .nav-icon { font-size: 18px; width: 24px; text-align: center; }
  .nav-sep { height: 1px; background: var(--border); margin: 8px 4px; }

  /* ── Sidebar User Card ── */
  #sidebarUserCard {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 12px;
    margin-bottom: 8px; cursor: pointer;
    transition: background 0.15s;
  }
  #sidebarUserCard:hover { background: var(--surface2); }
  #sidebarUserCard .su-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--accent); display: flex; align-items: center;
    justify-content: center; font-size: 16px; font-weight: 700;
    color: #fff; flex-shrink: 0; overflow: hidden;
  }
  #sidebarUserCard .su-avatar img { width:100%; height:100%; object-fit:cover; border-radius:50%; }
  #sidebarUserCard .su-info { flex: 1; min-width: 0; }
  #sidebarUserCard .su-name { font-size: 14px; font-weight: 600; color: var(--text); }
  #sidebarUserCard .su-role { font-size: 11px; color: var(--text3); margin-top: 1px; }

  /* ── Right Panel Widgets ── */
  .rp-widget {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: var(--radius-xl, 16px);
    padding: var(--space-4, 16px);
    margin-bottom: var(--space-3, 12px);
    transition: border-color var(--transition-base, 0.15s), background var(--transition-base, 0.15s);
  }
  .rp-widget:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.11);
  }
  .rp-widget-title {
    font-size: 12px; font-weight: 600; color: var(--text3);
    text-transform: uppercase; letter-spacing: 0.08em;
    margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
  }
  .rp-stat-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px solid var(--border);
  }
  .rp-stat-row:last-child { border-bottom: none; }
  .rp-stat-label { font-size: 12px; color: var(--text3); }
  .rp-stat-val { font-size: 14px; font-weight: 600; color: var(--text); font-family: var(--mono); }

  /* Sidebar */
  .logo { font-family: var(--mono); font-size: 18px; color: var(--accent); padding: 8px 12px 20px; letter-spacing: -0.5px; }
  .logo span { color: var(--text3); font-size: 11px; display: block; margin-top: 2px; font-family: var(--sans); }
  .nav-item { padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--text2); font-size: 13px; transition: all 0.15s; display: flex; align-items: center; gap: 8px; }
  .nav-item:hover { background: var(--surface2); color: var(--text); }
  .nav-item.active { background: rgba(124,106,255,0.15); color: var(--accent); }
  .nav-icon { width: 16px; text-align: center; font-size: 14px; }
  .nav-sep { height: 1px; background: var(--border); margin: 8px 4px; }
  .month-list { flex: 1; overflow-y: auto; }
  .month-nav { padding: 7px 12px; border-radius: 8px; cursor: pointer; color: var(--text2); font-size: 12px; display: flex; justify-content: space-between; align-items: center; transition: all 0.15s; }
  .month-nav:hover { background: var(--surface2); color: var(--text); }
  .month-nav.active { background: var(--surface3); color: var(--text); }
  .month-nav .badge { font-family: var(--mono); font-size: 10px; color: var(--text3); }

  /* Pages */
  .page { display: none; }
  .page.active { display: block; }

  /* Page header */
  .page-header { margin-bottom: var(--space-6); }
  .page-title { font-size: var(--text-2xl); font-weight: var(--weight-semibold); color: var(--color-text-primary); letter-spacing: var(--tracking-tight); }
  .page-sub { font-size: var(--text-sm); color: var(--color-text-secondary); margin-top: var(--space-1); }

  /* Stat cards */
  .stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-6); }
  .stat-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-xl);
    padding: var(--space-4) var(--space-5);
    transition: all var(--transition-base);
    position: relative; overflow: hidden;
  }
  .stat-card::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 60%);
    pointer-events: none;
  }
  .stat-card:hover {
    border-color: rgba(124,106,255,0.25);
    background: rgba(124,106,255,0.06);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2), 0 0 0 1px rgba(124,106,255,0.12);
  }
  .stat-label { font-size: var(--text-xs); color: var(--color-text-tertiary); text-transform: uppercase; letter-spacing: var(--tracking-wider); margin-bottom: var(--space-2); font-weight: var(--weight-medium); }
  .stat-value { font-family: var(--mono); font-size: var(--text-3xl); font-weight: var(--weight-bold); color: var(--color-text-primary); letter-spacing: var(--tracking-tight); }
  .stat-value.green { color: var(--green); }
  .stat-value.accent { color: var(--accent); }
  .stat-value.amber { color: var(--amber); }

  /* Calendar grid */
  .calendar-section {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
  }
  .cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
  .cal-title { font-size: 15px; font-weight: 500; }
  .cal-nav { display: flex; gap: 6px; }
  .cal-btn { background: var(--color-surface-1); border: 1px solid var(--color-border-default); border-radius: var(--radius-md); color: var(--color-text-secondary); padding: var(--space-1) var(--space-3); cursor: pointer; font-size: var(--text-sm); transition: all var(--transition-base); font-family: var(--sans); }
  .cal-btn:hover { background: var(--color-surface-2); color: var(--color-text-primary); border-color: var(--color-border-strong); }
  .cal-days-header { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 6px; }
  .cal-day-name { text-align: center; font-size: 9px; color: var(--text3); padding: 4px 0; }
  .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
  .cal-day { aspect-ratio: 1; border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: var(--text-xs); transition: all var(--transition-base); position: relative; }
  .cal-day:hover { border-color: var(--border2); background: var(--surface2); }
  .cal-day.empty { cursor: default; }
  .cal-day.empty:hover { background: none; border-color: transparent; }
  .cal-day.today { border-color: var(--color-accent); box-shadow: 0 0 0 1px var(--color-accent-muted); }
  .cal-day.has-value { background: rgba(124,106,255,0.12); border-color: rgba(124,106,255,0.25); }
  .cal-day.has-value:hover { background: rgba(124,106,255,0.2); }
  .cal-day.negative { background: rgba(255,92,92,0.18); border-color: rgba(255,92,92,0.55); border-width: 2px; }
  .cal-day.negative:hover { background: rgba(255,92,92,0.28); }
  .cal-day.deducted { background: rgba(245,166,35,0.12); border-color: rgba(245,166,35,0.5); border-width: 2px; }
  .cal-day.deducted:hover { background: rgba(245,166,35,0.2); }
  .cal-day.fully-deducted { background: rgba(255,92,92,0.18); border-color: rgba(255,92,92,0.6); border-width: 2px; }
  .cal-day.fully-deducted:hover { background: rgba(255,92,92,0.28); }
  .cal-day .day-num { font-size: 12px; font-weight: 400; color: var(--text2); }
  .cal-day.has-value .day-num { color: var(--text); }
  .cal-day.negative .day-num { color: var(--red); font-weight: 500; }
  .cal-day.deducted .day-num { color: var(--amber); font-weight: 500; }
  .cal-day.fully-deducted .day-num { color: var(--red); font-weight: 500; }
  .cal-day .day-val { font-family: var(--mono); font-size: 9px; color: var(--accent); margin-top: 1px; }
  .cal-day.negative .day-val { color: var(--red); font-weight: 600; font-size: 9px; }
  .cal-day.deducted .day-val { color: var(--amber); }
  .cal-day.fully-deducted .day-val { color: var(--red); }
  .cal-day.negative::after { content: '−'; position: absolute; top: 2px; left: 4px; font-size: 10px; color: var(--red); opacity: 0.7; font-weight: 700; }
  .cal-day.deducted::after { content: '↓'; position: absolute; top: 2px; left: 4px; font-size: 9px; color: var(--amber); opacity: 0.8; font-weight: 700; }
  .cal-day.fully-deducted::after { content: '✕'; position: absolute; top: 2px; left: 4px; font-size: 9px; color: var(--red); opacity: 0.8; font-weight: 700; }
  .cal-day.selected { border-color: var(--accent) !important; box-shadow: 0 0 0 2px rgba(124,106,255,0.3); }

  /* Entry panel */
  .entry-panel { background: var(--color-surface-0); border: 1px solid var(--color-border-default); border-radius: var(--radius-xl); padding: var(--space-5); margin-bottom: var(--space-5); }
  .entry-title { font-size: 13px; font-weight: 500; margin-bottom: 16px; color: var(--text2); }
  .entry-date { font-family: var(--mono); font-size: 16px; font-weight: 500; color: var(--accent); margin-bottom: 14px; }
  .quick-vals { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
  .qval { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); font-family: var(--mono); font-size: 13px; cursor: pointer; transition: all 0.15s; }
  .qval:hover { border-color: var(--accent2); color: var(--accent); }
  .qval.active { background: rgba(124,106,255,0.2); border-color: var(--accent); color: var(--accent); }
  .qval.neg { border-color: rgba(255,92,92,0.3); color: var(--red); }
  .qval.neg:hover, .qval.neg.active { background: rgba(255,92,92,0.15); border-color: var(--red); }
  .input-row { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-bottom: 12px; }
  .inp-group { display: flex; flex-direction: column; gap: 5px; }
  .inp-label { font-size: 11px; color: var(--text3); }
  .inp { background: var(--color-surface-1); border: 1px solid var(--color-border-default); border-radius: var(--radius-lg); padding: var(--space-2) var(--space-3); color: var(--color-text-primary); font-family: var(--sans); font-size: var(--text-base); outline: none; transition: border-color var(--transition-base), box-shadow var(--transition-base); width: 100%; }
  .inp:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-focus-ring); }
  .inp::placeholder { color: var(--color-text-tertiary); }
  .inp:focus { border-color: var(--accent2); }
  .inp::placeholder { color: var(--text3); }
  .save-btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 9px 20px; font-family: var(--sans); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; width: 100%; }
  .save-btn:hover { background: var(--accent2); }
  .del-btn { background: none; border: 1px solid rgba(255,92,92,0.3); color: var(--red); border-radius: 8px; padding: 7px 14px; font-family: var(--sans); font-size: 12px; cursor: pointer; margin-top: 6px; width: 100%; transition: all 0.15s; }
  .del-btn:hover { background: rgba(255,92,92,0.1); }

  /* Monthly summary */
  .summary-section { background: var(--color-surface-0); border: 1px solid var(--color-border-default); border-radius: var(--radius-xl); padding: var(--space-5); }
  .summary-title { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-secondary); margin-bottom: var(--space-3); letter-spacing: var(--tracking-wide); text-transform: uppercase; }
  .calc-rows { display: flex; flex-direction: column; gap: 0; }
  .calc-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
  .calc-row:last-child { border-bottom: none; }
  .calc-row.total { padding-top: 12px; }
  .calc-label { font-size: 13px; color: var(--text2); }
  .calc-val { font-family: var(--mono); font-size: 14px; font-weight: 500; color: var(--text); }
  .calc-row.highlight .calc-label { color: var(--text); }
  .calc-row.highlight .calc-val { color: var(--color-success); font-size: var(--text-xl); font-weight: var(--weight-bold); }
  .calc-row.carried .calc-val { color: var(--amber); }
  .editable-val { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-family: var(--mono); font-size: 13px; color: var(--amber); outline: none; width: 90px; text-align: left; }
  .editable-val:focus { border-color: var(--amber); }

  /* History entries */
  .entries-list { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; max-height: 200px; overflow-y: auto; }
  .entry-item { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 7px; background: var(--surface2); font-size: 12px; }
  .entry-item-date { color: var(--text2); font-family: var(--mono); }
  .entry-item-val { font-family: var(--mono); color: var(--accent); }
  .entry-item-val.neg { color: var(--red); }
  .entry-item-note { color: var(--text3); flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px; }

  /* Settings page */
  .settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .setting-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
  .setting-label { font-size: 12px; color: var(--text3); margin-bottom: 8px; }
  .setting-title { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
  .setting-desc { font-size: 12px; color: var(--text2); margin-bottom: 12px; }
  .set-inp { background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; color: var(--text); font-family: var(--mono); font-size: 15px; outline: none; width: 100%; }
  .set-inp:focus { border-color: var(--accent2); }
  .set-save { background: var(--surface3); border: 1px solid var(--border2); color: var(--text2); border-radius: 8px; padding: 7px 14px; font-family: var(--sans); font-size: 12px; cursor: pointer; margin-top: 8px; }
  .set-save:hover { color: var(--text); }

  /* Reports page */
  .reports-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
  .report-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
  .report-card-title { font-size: 13px; color: var(--text2); margin-bottom: 14px; }
  .bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
  .bar-label { font-size: 11px; color: var(--text2); width: 70px; text-align: left; flex-shrink: 0; }
  .bar-track { flex: 1; background: var(--surface2); border-radius: 4px; height: 8px; overflow: hidden; }
  .bar-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.5s; }
  .bar-val { font-family: var(--mono); font-size: 10px; color: var(--text3); width: 50px; text-align: left; }

  /* Toast */
  .toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--color-surface-2); border: 1px solid var(--color-border-strong); color: var(--color-text-primary); padding: var(--space-2) var(--space-5); border-radius: var(--radius-full); font-size: var(--text-sm); font-weight: var(--weight-medium); transition: transform var(--transition-slow); z-index: var(--z-toast); box-shadow: var(--shadow-lg); }
  .toast.show { transform: translateX(-50%) translateY(0); }
  .toast.green { border-color: var(--green2); color: var(--green); }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }

  @keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
  }

  .dragging {
    opacity: 0.5;
    transform: scale(1.02);
  }

  .dashboard-box {
    cursor: grab;
  }

  .dashboard-box:active {
    cursor: grabbing;
  }

  /* ── GridStack Dashboard ── */
  .grid-stack {
    background: transparent;
  }
  .grid-stack-item-content {
    border-radius: 12px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 18px;
    inset: 4px !important; /* gap بين البوكسات */
  }
  .grid-stack-item-content.dashboard-box {
    cursor: default;
  }
  /* مقبض السحب — أيقونة في الزاوية */
  .grid-stack-item > .ui-resizable-handle {
    opacity: 0.3;
    transition: opacity 0.2s;
  }
  .grid-stack-item:hover > .ui-resizable-handle {
    opacity: 0.8;
  }
  /* override GridStack placeholder */
  .grid-stack-placeholder > .placeholder-content {
    background: rgba(124,106,255,0.12);
    border: 2px dashed var(--accent2);
    border-radius: 12px;
  }

  @keyframes pulseSoft {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
  }

  @keyframes pulseDanger {
    0% { transform: scale(1); }
    50% { transform: scale(1.06); box-shadow: 0 0 20px rgba(255,92,92,0.6); }
    100% { transform: scale(1); }
  }

  @keyframes shake {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
  }

  /* ── Chat Messenger Layout ── */
  #page-chat { padding: 0 !important; }
  #page-chat .page-header { display: none; }
  #chatConvList::-webkit-scrollbar { width: 3px; }
  #chatConvList::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
  #chatMessages::-webkit-scrollbar { width: 3px; }
  #chatMessages::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }

  .chat-conv-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: 10px; cursor: pointer;
    transition: background 0.15s; position: relative;
  }
  .chat-conv-item:hover { background: var(--surface3); }
  .chat-conv-item.active { background: rgba(124,106,255,0.15); }
  .chat-conv-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(124,106,255,0.2); display: flex;
    align-items: center; justify-content: center;
    font-size: 16px; font-weight: 600; color: var(--accent);
    font-family: var(--mono); flex-shrink: 0; position: relative;
  }
  .chat-conv-online {
    position: absolute; bottom: 1px; right: 1px;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--text3); border: 2px solid var(--surface2);
    transition: background 0.3s;
  }
  .chat-unread-badge {
    background: var(--accent); color: #fff; border-radius: 50%;
    min-width: 18px; height: 18px; font-size: 10px;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--mono); font-weight: 700; padding: 0 4px;
    margin-right: auto; flex-shrink: 0;
  }

  /* ── Message Bubbles ── */
  .msg-row { display: flex; flex-direction: column; max-width: 72%; }
  .msg-row.mine { align-self: flex-end; align-items: flex-end; }
  .msg-row.other { align-self: flex-start; align-items: flex-start; }
  .msg-bubble {
    padding: 9px 14px; border-radius: 18px; font-size: 13px;
    line-height: 1.5; word-break: break-word; position: relative;
  }
  .msg-row.mine .msg-bubble {
    background: var(--accent); color: #fff;
    border-radius: 18px 18px 4px 18px;
  }
  .msg-row.other .msg-bubble {
    background: var(--surface3); color: var(--text);
    border-radius: 18px 18px 18px 4px;
  }
  .msg-row.system .msg-bubble {
    background: rgba(124,106,255,0.1); color: var(--text3);
    font-size: 11px; border-radius: 8px; text-align: center;
    align-self: center; max-width: 100%;
  }
  .msg-meta {
    font-size: 9px; color: var(--text3); margin-top: 3px;
    display: flex; align-items: center; gap: 4px;
    padding: 0 4px;
  }
  .msg-seen { color: var(--accent); }

  /* ── Read Receipts Status Icons ── */
  .msg-status {
    font-size: 11px;
    margin-right: 3px;
    transition: color 0.35s ease, transform 0.25s ease;
    display: inline-flex; align-items: center;
  }
  /* ✔ إرسال — رمادي خافت */
  .msg-status.s-sending   { color: rgba(255,255,255,0.28); }
  /* ✔✔ استلام — أبيض متوسط */
  .msg-status.s-delivered { color: rgba(255,255,255,0.55); font-weight: 400; }
  /* ✔✔ قراءة — أزرق واتساب + scale خفيف */
  .msg-status.s-seen {
    color: #4fc3f7;
    font-weight: 700;
    transform: scale(1.1);
    animation: seenPop 0.35s ease forwards;
  }
  @keyframes seenPop {
    0%   { transform: scale(0.8);  opacity: 0.5; color: rgba(255,255,255,0.55); }
    60%  { transform: scale(1.2);  opacity: 1;   color: #7dd9f7; }
    100% { transform: scale(1.1);  opacity: 1;   color: #4fc3f7; }
  }

  /* ── Chat Advanced Enhancements ── */
  @keyframes msgFadeIn {
    from { opacity:0; transform:translateY(6px); }
    to   { opacity:1; transform:translateY(0); }
  }
  @keyframes seenAnim { 0%{opacity:0.3} 100%{opacity:1} }
  @keyframes typingBounce {
    0%,80%,100%{transform:scale(0.6);opacity:0.4}
    40%{transform:scale(1);opacity:1}
  }
  .msg-row { animation: msgFadeIn 0.18s ease forwards; }
  .msg-seen { animation: seenAnim 0.35s ease; }

  .typing-dots { display:inline-flex;gap:3px;align-items:center; }
  .typing-dots span { width:6px;height:6px;border-radius:50%;background:var(--accent);display:inline-block;animation:typingBounce 1.2s infinite; }
  .typing-dots span:nth-child(2){animation-delay:0.2s}
  .typing-dots span:nth-child(3){animation-delay:0.4s}

  .chat-date-sep { position:sticky;top:4px;z-index:2;display:flex;justify-content:center;pointer-events:none;margin:8px 0; }
  .chat-date-sep span { font-size:11px;color:var(--text3);background:var(--surface2);border:1px solid var(--border);padding:3px 12px;border-radius:12px; }

  #chatNewMsgBtn { position:absolute;bottom:80px;left:50%;transform:translateX(-50%);background:var(--accent);color:#fff;border:none;border-radius:20px;padding:6px 16px;font-size:12px;cursor:pointer;z-index:5;box-shadow:0 2px 12px rgba(124,106,255,0.4);font-family:var(--sans);display:none; }

  .quick-reply-btn { background:var(--surface2);border:1px solid var(--border2);color:var(--text2);border-radius:16px;padding:5px 12px;font-size:12px;cursor:pointer;font-family:var(--sans);transition:all 0.15s;white-space:nowrap; }
  .quick-reply-btn:hover,.quick-reply-btn:active { background:rgba(124,106,255,0.15);border-color:var(--accent2);color:var(--accent); }

  .msg-highlight { background:rgba(245,166,35,0.35);border-radius:3px; }
  #swipeHint { position:absolute;top:50%;left:0;transform:translateY(-50%);width:4px;height:60px;background:var(--accent);border-radius:0 4px 4px 0;opacity:0;transition:opacity 0.2s;pointer-events:none;z-index:10; }
  #chatSendBtn { transition:transform 0.1s; }
  #chatSendBtn:active { transform:scale(0.9); }

  /* ── Mobile Chat — WhatsApp/Messenger Style ── */
  @media (max-width: 768px) {
    /* الشات يغطي الشاشة كاملاً */
    #page-chat { margin: 0 !important; padding: 0 !important; position: fixed; inset: 0; z-index: 100; background: var(--bg); }
    #chatLayout {
      height: 100%; border-radius: 0; border: none;
      position: relative; overflow: hidden;
    }

    /* Sidebar: قائمة المحادثات — شاشة كاملة */
    #chatSidebar {
      width: 100% !important; min-width: 100% !important;
      border-left: none; height: 100%;
      position: absolute; inset: 0; z-index: 2;
      transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
      transform: translateX(0);
    }
    #chatSidebar.sidebar-hidden {
      transform: translateX(-100%);
      pointer-events: none;
    }

    /* Chat Window: ينزلق من اليمين */
    #chatWindow {
      position: absolute; inset: 0; z-index: 3;
      display: flex !important; flex-direction: column;
      background: var(--bg);
      transform: translateX(100%);
      transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
      pointer-events: none;
    }
    #chatWindow.mobile-open {
      transform: translateX(0) !important;
      pointer-events: all;
    }

    /* Header الشات */
    #chatWinHeader {
      padding: 10px 12px;
      padding-top: max(10px, env(safe-area-inset-top));
      min-height: 56px; flex-shrink: 0;
    }

    /* الرسائل */
    #chatMessages {
      padding: 10px 12px;
      flex: 1; min-height: 0;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      scroll-behavior: smooth;
      overscroll-behavior: contain;
    }

    /* Input area ثابت في الأسفل */
    #chatInputArea {
      padding: 8px 10px;
      padding-bottom: max(8px, env(safe-area-inset-bottom));
      flex-shrink: 0; position: relative; z-index: 1;
    }
    #chatInputArea textarea {
      font-size: 16px !important; /* يمنع zoom على iOS */
    }

    /* أزرار أكبر للمس */
    #chatInputArea button { min-width: 40px; min-height: 40px; }
    /* أزرار أكبر لتجربة لمس أفضل */
    .nav-item, .mob-nav-item, .cal-btn, .qval, .save-btn, .del-btn { min-height: 42px; }
    #chatBackBtn { min-width: 40px; min-height: 40px; display: flex !important; align-items: center; justify-content: center; }

    /* Emoji picker */
    #emojiPicker { max-height: 160px; }

    /* بطاقات المحادثة */
    .chat-conv-item { padding: 12px 14px; border-radius: 0; }
    .chat-conv-item:active { background: var(--surface3); }
    .chat-conv-avatar { width: 46px; height: 46px; font-size: 18px; }
    .chat-unread-badge { min-width: 20px; height: 20px; font-size: 11px; }

    /* رسائل أوسع على الموبايل */
    .msg-row { max-width: 85%; }
    .msg-bubble { font-size: 14px; padding: 10px 14px; }
    .msg-meta { font-size: 10px; }

    /* Back btn */
    #chatBackBtn { display: flex !important; }

    /* إخفاء شريط التنقل عند فتح الشات */
    body.chat-fullscreen #mobileNav { display: none !important; }
    body.chat-fullscreen .main { padding-bottom: 0 !important; }
  }

  @media (max-width: 1100px) {
    .app { grid-template-columns: 280px 1fr; }
    #rightPanel { display: none; }
  }
  @media (max-width: 768px) {
    #appHeader { padding: 0 12px; }
    #headerNav { display: none; }
    .app { grid-template-columns: 1fr; padding-top: 56px; }
    .sidebar { display: none; }
    #rightPanel { display: none; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .main { padding: 12px 14px 80px; border: none; }
    .reports-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
  }

  /* ── Welcome Box — عرض اسم الموظف ── */
  #userWelcomeBox {
    display: none;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 16px;
    background: rgba(124,106,255,0.1);
    border: 1px solid rgba(124,106,255,0.28);
    padding: 11px 16px;
    border-radius: 12px;
    text-align: center;
    font-weight: 500;
    line-height: 1.5;
  }
  #userWelcomeName {
    color: var(--accent);
    font-weight: 700;
  }
  @media (max-width: 768px) {
    #userWelcomeBox {
      font-size: 13px;
      padding: 9px 12px;
      margin-bottom: 10px;
      border-radius: 10px;
    }
  }

  /* iOS: منع zoom عند التركيز على الـ inputs */
  input, textarea, select {
    font-size: max(16px, 1em);
  }
  @media (max-width: 768px) {
    input.set-inp, input.login-pass-inp, input.inp,
    textarea, select.set-inp {
      font-size: 16px !important;
    }
  }

  /* Mobile bottom nav */
  #mobileNav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 10px 0 max(10px, env(safe-area-inset-bottom));
    z-index: 200;
    grid-template-columns: repeat(3, 1fr);
  }
  .mob-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px; cursor: pointer; color: var(--text3); font-size: 10px;
    transition: color 0.15s;
  }
  .mob-nav-item.active { color: var(--accent); }
  .mob-nav-item .mob-icon { font-size: 20px; line-height: 1; }

  /* Mobile month drawer */
  #mobMonthBtn {
    display: none;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; padding: 7px 12px; font-size: 13px;
    color: var(--text2); cursor: pointer; font-family: var(--sans);
    margin-bottom: 14px; width: 100%; text-align: right;
  }
  #mobDrawer {
    display: none; position: fixed; inset: 0; z-index: 300;
    background: rgba(0,0,0,0.6);
  }
  #mobDrawerInner {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: var(--surface); border-radius: 20px 20px 0 0;
    padding: 20px 16px max(24px, env(safe-area-inset-bottom));
    max-height: 70vh; overflow-y: auto;
  }
  .mob-drawer-handle {
    width: 36px; height: 4px; background: var(--border2);
    border-radius: 2px; margin: 0 auto 16px;
  }
  .mob-drawer-title { font-size: 13px; color: var(--text3); margin-bottom: 10px; }

  @media (max-width: 768px) {
    #mobileNav { display: grid; }
    #mobMonthBtn { display: block; }
    /* Entry panel goes full width under calendar */
    .entry-layout { grid-template-columns: 1fr !important; }
    .login-box { width: calc(100vw - 48px); padding: 32px 24px; }
  }

  /* Login screen */
  #loginScreen {
    position: fixed; inset: 0; background: var(--bg); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
  }
  .login-box {
    background: rgba(22,22,26,0.80);
    border: 1px solid rgba(255,255,255,0.10);
    -webkit-
    box-shadow: 0 24px 64px rgba(0,0,0,0.5),
                inset 0 1px 0 rgba(255,255,255,0.07);
    border-radius: 24px; padding: 40px 36px; width: 340px; text-align: center;
    position: relative; overflow: hidden;
  }
  .login-box::before {
    content: '';
    position: absolute; top: -60px; right: -60px;
    width: 200px; height: 200px; border-radius: 50%;
    background: radial-gradient(circle, rgba(124,106,255,0.12) 0%, transparent 70%);
    pointer-events: none;
  }
  .login-logo { font-family: var(--mono); font-size: 24px; color: var(--accent); margin-bottom: 4px; }
  .login-sub { font-size: 12px; color: var(--text3); margin-bottom: 32px; }
  .login-mode-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 24px; }
  .mode-btn { padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); font-family: var(--sans); font-size: 13px; cursor: pointer; transition: all 0.15s; }
  .mode-btn:hover { border-color: var(--border2); color: var(--text); }
  .mode-btn.selected { border-color: var(--accent); background: rgba(124,106,255,0.15); color: var(--accent); }
  .login-pass-area { margin-bottom: 20px; }
  .login-pass-label { font-size: 11px; color: var(--text3); margin-bottom: 8px; text-align: right; }
  .login-pass-inp { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; color: var(--text); font-family: var(--mono); font-size: 15px; outline: none; width: 100%; letter-spacing: 3px; }
  .login-pass-inp:focus { border-color: var(--accent2); }
  .login-enter-btn { background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 12px; font-family: var(--sans); font-size: 14px; font-weight: 500; cursor: pointer; width: 100%; transition: all 0.15s; }
  .login-enter-btn:hover { background: var(--accent2); }
  .login-err { font-size: 12px; color: var(--red); margin-top: 10px; min-height: 18px; }
  .login-view-btn { background: none; border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-family: var(--sans); font-size: 13px; color: var(--text2); cursor: pointer; width: 100%; margin-top: 8px; transition: all 0.15s; }
  .login-view-btn:hover { color: var(--text); border-color: var(--border2); }

  /* ── Presence Status ── */
  .status-dot-online    { background: #2dd48a !important; }
  .status-dot-busy      { background: #ff5c5c !important; }
  .status-dot-away      { background: #f5a623 !important; }
  .status-dot-invisible { background: #555    !important; }
  .status-dot-offline   { background: #555    !important; }

  .status-item {
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    transition: background 0.12s;
  }
  .status-item:hover { background: var(--surface3); }

  #presenceCard { max-width: 500px; margin-top: 16px; }
  #statusSelect {
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; font-family: var(--sans); font-size: 13px;
    outline: none; width: 100%; cursor: pointer; margin-bottom: 8px;
  }
  #statusSelect:focus { border-color: var(--accent2); }
  #statusTextInp {
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 12px; font-family: var(--sans); font-size: 13px;
    outline: none; width: 100%;
  }
  #statusTextInp:focus { border-color: var(--accent2); }
  #statusTextInp::placeholder { color: var(--text3); }
  #roBar {
    display: none; background: rgba(245,166,35,0.1); border-bottom: 1px solid rgba(245,166,35,0.2);
    padding: 7px 20px; font-size: 12px; color: var(--amber); text-align: center;
    position: sticky; top: 0; z-index: 100;
  }
  #roBar span { cursor: pointer; text-decoration: underline; margin-right: 12px; }
  .admin-badge { display:none; font-size:10px; background: rgba(124,106,255,0.2); color: var(--accent); border-radius: 4px; padding: 2px 7px; font-family: var(--mono); vertical-align: middle; margin-right: 6px; }

  /* ── Mobile Logout Button ── */
  #mobileLogoutBtn {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 10000;
    background: rgba(255,92,92,0.15);
    border: 1px solid rgba(255,92,92,0.4);
    color: var(--red);
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-family: var(--sans);
    cursor: pointer;
    display: none; /* مخفي افتراضياً */
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
  }
  #mobileLogoutBtn:active {
    background: rgba(255,92,92,0.3);
    transform: scale(0.9);
    transition: transform 0.1s, background 0.1s;
  }
  #mobileLogoutBtn {
    transition: background 0.2s, transform 0.15s;
  }
  /* يظهر فقط على الموبايل */
  @media (max-width: 768px) {
    #mobileLogoutBtn { display: none; } /* يتحكم فيه JS */
  }
  @media (min-width: 769px) {
    #mobileLogoutBtn { display: none !important; }
  }
.reward-box { width:60px; height:60px; background:#1e1e24; border:1px solid rgba(255,255,255,0.1); border-radius:10px; display:flex; align-items:center; justify-content:center; cursor:pointer; font-size:22px; }
.reward-box:hover { border-color:#7c6aff; }

/* ══ REWARD BOXES ══ */
#reward-section {
  animation: none;
}
#reward-boxes {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 8px 0;
  min-height: 110px;
}

/* ══ PENALTY BANNER ══ */
#penaltyBanner {
  animation: penaltyPulse 3s ease-in-out infinite;
}
@keyframes penaltyPulse {
  0%,100% { box-shadow: 0 4px 32px rgba(255,0,0,0.25); }
  50%      { box-shadow: 0 4px 48px rgba(255,0,0,0.45); }
}
/* عند ظهور البانر: ارفع المحتوى لتجنب التداخل */
body.penalized #app {
  padding-top: 120px;
}
body.penalized #roBar {
  top: 120px;
}


/* ══════════════════════════════════════════════
   S2 — Settings v2 Design System
   ══════════════════════════════════════════════ */

/* Section Labels */
.s2-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
  padding-right: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.s2-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Grid layouts */
.s2-grid {
  display: grid;
  gap: 14px;
  margin-bottom: 0;
}
.s2-grid-2 { grid-template-columns: 1fr 1fr; }
.s2-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* Card */
.s2-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: border-color 0.2s;
}
.s2-card:hover {
  border-color: var(--border2);
}
.s2-card-full {
  grid-column: 1 / -1;
}
.s2-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  font-weight: 700;
}
.s2-card-body {
  flex: 1;
  min-width: 0;
}
.s2-card-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.s2-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.s2-card-desc {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 12px;
  line-height: 1.6;
}

/* Inputs */
.s2-inp {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
  margin-bottom: 8px;
}
.s2-inp:focus {
  border-color: var(--accent2);
  background: var(--surface3);
}
.s2-inp-sm {
  width: 70px;
  text-align: center;
}
.s2-inp-label {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 4px;
  font-weight: 500;
}

/* Buttons */
.s2-btn {
  background: var(--surface3);
  border: 1px solid var(--border2);
  color: var(--text2);
  border-radius: 8px;
  padding: 8px 16px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 0;
}
.s2-btn:hover { color: var(--text); border-color: var(--border2); background: var(--surface2); }
.s2-btn-accent { background: rgba(124,106,255,0.15); color: var(--accent); border-color: var(--accent2); }
.s2-btn-accent:hover { background: rgba(124,106,255,0.25); }
.s2-btn-green { background: rgba(45,212,138,0.12); color: var(--green); border-color: rgba(45,212,138,0.35); }
.s2-btn-green:hover { background: rgba(45,212,138,0.22); }
.s2-btn-warning { background: rgba(245,166,35,0.12); color: var(--amber); border-color: rgba(245,166,35,0.35); }
.s2-btn-warning:hover { background: rgba(245,166,35,0.22); }
.s2-btn-danger { background: rgba(255,92,92,0.1); color: var(--red); border-color: rgba(255,92,92,0.3); }
.s2-btn-danger:hover { background: rgba(255,92,92,0.2); }

/* Form grid */
.s2-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

/* Permissions row */
.s2-perms-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.s2-perm-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  padding: 6px 12px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: all 0.15s;
}
.s2-perm-check:hover { border-color: var(--border2); color: var(--text); }
.s2-perm-check input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }

/* Cycle rows */
.s2-cycle-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Firebase stats mini cards */
.s2-stat-mini {
  background: var(--surface2);
  border-radius: 8px;
  padding: 8px 10px;
}
.s2-stat-mini-label {
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 4px;
}
.s2-stat-mini-val {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

/* Radio labels */
.s2-radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  padding: 6px 0;
}
.s2-radio-label input { accent-color: var(--accent); cursor: pointer; }

/* Admin settings grid — hidden for employees */
#adminSettingsGrid { display: block; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .s2-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .s2-grid-2, .s2-grid-3 { grid-template-columns: 1fr; }
  .s2-form-grid { grid-template-columns: 1fr; }
  .s2-card { padding: 14px; gap: 10px; }
}

/* ══════════════════════════════
   CHAT UPGRADE — 16 FEATURES
   ══════════════════════════════ */

/* فلاتر المحادثات */
.cf-tab {
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  border-radius: 14px;
  padding: 3px 9px;
  font-size: 10px;
  cursor: pointer;
  font-family: var(--sans);
  transition: all 0.15s;
  white-space: nowrap;
}
.cf-tab.active, .cf-tab:hover {
  background: rgba(124,106,255,0.15);
  border-color: var(--accent2);
  color: var(--accent);
}

/* Context Menu */
.ctx-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
  font-family: var(--sans);
  white-space: nowrap;
}
.ctx-item:hover { background: var(--surface3); }
.ctx-item.ctx-danger { color: var(--red); }

/* Reaction picker */
.react-opt {
  font-size: 22px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 8px;
  transition: transform 0.1s;
  line-height: 1;
}
.react-opt:hover { transform: scale(1.3); }

/* رسالة بها ردّ */
.msg-reply-ref {
  background: rgba(255,255,255,0.06);
  border-right: 3px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--text3);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.msg-row.mine .msg-reply-ref {
  border-right: none;
  border-left: 3px solid rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.6);
}

/* التفاعلات على الرسالة */
.msg-reactions {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 3px;
}
.msg-reaction-badge {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1px 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.msg-reaction-badge:hover { background: rgba(124,106,255,0.15); }
.msg-reaction-badge.mine { background: rgba(124,106,255,0.15); border-color: var(--accent2); }

/* صورة داخل الرسالة */
.msg-img {
  max-width: 240px;
  max-height: 200px;
  border-radius: 10px;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
  border: 1px solid var(--border);
}

/* ملف داخل الرسالة */
.msg-file {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  min-width: 160px;
  max-width: 240px;
}
.msg-file-icon { font-size: 22px; flex-shrink: 0; }
.msg-file-name { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file-size { font-size: 10px; color: var(--text3); }

/* رسالة صوتية */
.msg-voice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 7px 12px;
  min-width: 180px;
  max-width: 260px;
}
.voice-play-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.voice-waveform {
  flex: 1;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
}
.voice-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--accent2);
  opacity: 0.7;
  transition: height 0.1s;
}
.voice-dur { font-size: 10px; color: var(--text3); font-family: var(--mono); flex-shrink: 0; }

/* رسالة Poll */
.msg-poll {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  min-width: 220px;
  max-width: 280px;
}
.poll-question { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 10px; }
.poll-option {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 5px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text2);
  position: relative;
  overflow: hidden;
  transition: border-color 0.15s;
}
.poll-option:hover { border-color: var(--accent2); }
.poll-option.voted { border-color: var(--accent2); color: var(--accent); }
.poll-bar {
  position: absolute;
  top: 0; right: 0;
  height: 100%;
  background: rgba(124,106,255,0.12);
  border-radius: 8px;
  transition: width 0.4s;
}
.poll-pct { font-size: 10px; color: var(--text3); margin-right: 6px; }

/* رسالة معدّلة */
.msg-edited {
  font-size: 9px;
  color: var(--text3);
  margin-right: 4px;
  opacity: 0.7;
}

/* ⭐ نجمة على الرسالة */
.msg-star {
  font-size: 10px;
  opacity: 0.5;
  cursor: pointer;
  margin-right: 3px;
}
.msg-star.active { opacity: 1; }

/* رسالة ذاتية الحذف */
.msg-ephemeral .msg-bubble {
  border: 1px dashed rgba(255,92,92,0.4) !important;
}
.msg-ephemeral-timer {
  font-size: 9px;
  color: var(--red);
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
}

/* @mention highlight */
.mention-tag {
  color: var(--accent);
  font-weight: 500;
  background: rgba(124,106,255,0.12);
  border-radius: 4px;
  padding: 0 3px;
}

/* @mention autocomplete dropdown */
#mentionDropdown {
  position: absolute;
  bottom: 100%;
  right: 0;
  left: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  z-index: 999;
  max-height: 150px;
  overflow-y: auto;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
  display: none;
}
.mention-item {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.1s;
}
.mention-item:hover { background: rgba(124,106,255,0.15); }

/* Voice waveform bars animation */
.vwave {
  width: 3px;
  border-radius: 2px;
  background: var(--red);
  animation: vwaveAnim 0.6s ease-in-out infinite alternate;
}
.vwave:nth-child(1){height:6px;animation-delay:0s}
.vwave:nth-child(2){height:14px;animation-delay:0.1s}
.vwave:nth-child(3){height:10px;animation-delay:0.2s}
.vwave:nth-child(4){height:18px;animation-delay:0.15s}
.vwave:nth-child(5){height:8px;animation-delay:0.25s}
.vwave:nth-child(6){height:12px;animation-delay:0.05s}
@keyframes vwaveAnim { from{transform:scaleY(0.4)} to{transform:scaleY(1)} }

/* غرفة مجموعة — badge */
.group-badge {
  font-size: 9px;
  background: rgba(45,212,138,0.15);
  color: #2dd48a;
  border: 1px solid rgba(45,212,138,0.3);
  border-radius: 5px;
  padding: 1px 5px;
}

/* كتم الغرفة */
.muted-icon {
  font-size: 11px;
  opacity: 0.5;
}

/* رسائل مثبّتة — item */
.pinned-item {
  background: var(--surface3);
  border: 1px solid rgba(245,166,35,0.2);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.pinned-item:hover { background: rgba(245,166,35,0.06); }

/* Poll option input */
.poll-opt-inp {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--sans);
  outline: none;
}

/* Starred panel item */
.starred-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.starred-item-meta { font-size: 10px; color: var(--text3); margin-bottom: 4px; }
.starred-item-text { font-size: 13px; color: var(--text); }

/* group member checkbox */
.gm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text2);
}
.gm-row:hover { background: var(--surface3); }
.gm-row input[type=checkbox] { accent-color: var(--accent); }

/* Image lightbox */
#imgLightbox { display: none !important; }
#imgLightbox.open { display: flex !important; }

/* Mobile overrides */
@media (max-width: 768px) {
  .cf-tab { font-size: 9px; padding: 3px 7px; }
  .msg-img { max-width: 180px; }
  .msg-voice { min-width: 150px; }
}

/* Modal flex fix — display:none by default, flex when opened via JS */
#editMsgModal[style*="display: flex"],
#createGroupModal[style*="display: flex"],
#pollModal[style*="display: flex"],
#starredPanel[style*="display: block"] {
  align-items: center;
  justify-content: center;
}
#reactPicker[style*="display: flex"] {
  display: flex !important;
}
#replyPreviewBar[style*="display: flex"] {
  display: flex !important;
}

  /* ── Theme Cards ── */
  .theme-card { transition: border-color 0.2s, transform 0.15s; }
  .theme-card:hover { transform: translateY(-2px); }
  .theme-card.active { border-color: var(--accent) !important; box-shadow: 0 0 0 2px rgba(124,106,255,0.2); }

  /* ── Profile Page ── */
  #page-profile { padding: 24px; }
  #page-help    { padding: 24px; }
