/* =========================================================
   لوحة مهام تمكين — تصميم هادي ومرتب على طريقة جوجل كالندر
   ========================================================= */
:root {
  --blue: #1A44B5;
  --blue-dark: #133590;
  --blue-soft: #E8EEFB;
  --orange: #F39200;
  --orange-dark: #D27E00;
  --text: #1F2430;
  --muted: #5F6675;
  --faint: #9096A3;
  --line: #E3E6EB;
  --line-soft: #EFF1F4;
  --surface: #F7F8FA;
  --hover: #F1F3F6;
  --danger: #D92D20;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }

body {
  font-family: 'Cairo', system-ui, sans-serif;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd { font-family: inherit; font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface); color: var(--muted); }

/* ---------- الأزرار ---------- */
.btn-primary, .btn-outline, .btn-ghost, .btn-danger, .btn-google {
  border-radius: 999px;
  padding: 6px 16px;
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--text); }
.btn-outline:hover { background: var(--hover); }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.22); }
.btn-ghost.dark { background: transparent; color: var(--muted); padding: 5px 10px; }
.btn-ghost.dark:hover { color: var(--blue); background: var(--hover); }
.btn-ghost.dark:disabled { opacity: .4; cursor: default; background: transparent; color: var(--muted); }
.btn-danger { background: #fff; color: var(--danger); border-color: #F3C9C5; margin-inline-start: auto; }
.btn-danger:hover { background: #FEF3F2; }
.btn-primary.sm, .btn-outline.sm, .btn-danger.sm { padding: 3px 12px; font-size: 12.5px; margin: 0; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

/* ---------- الهيدر ---------- */
.topbar {
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 24px;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; direction: ltr; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: .5px; }
.brand-sub { font-size: 7px; letter-spacing: 3.3px; opacity: .9; }
.brand-divider { width: 1px; height: 20px; background: rgba(255,255,255,.3); }
.brand-title { font-weight: 600; font-size: 14px; }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-box .btn-ghost { padding: 4px 12px; font-size: 13px; }
.user-name { opacity: .9; font-size: 13px; }
.pill { background: var(--orange); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 11px; font-weight: 700; margin-inline-start: 4px; }

/* ---------- شريط الأدوات ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px 24px 10px;
}
.month-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.month-title { min-width: 180px; padding: 2px 10px; line-height: 1.3; border: none; background: none; text-align: right; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; }
.month-title:hover { background: var(--hover); }
.month-title h1 { display: flex; align-items: center; gap: 4px; }
.month-title h1 svg { color: var(--muted); }
.month-title h1 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text); }
.month-title > span { color: var(--muted); font-size: 12px; }
#newTaskBtn { padding: 8px 18px; box-shadow: 0 1px 3px rgba(243,146,0,.35); }
#newTaskBtn:hover { box-shadow: 0 3px 10px rgba(243,146,0,.4); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters input[type=search], .filters select {
  height: 34px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--hover);
  padding: 0 14px;
}
.filters input[type=search] { width: 210px; }
.filters input:focus, .filters select:focus { outline: none; background: #fff; border-color: var(--blue); }

.color-filter { display: flex; gap: 6px; align-items: center; }
.color-filter:empty { display: none; }
.color-filter button { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); padding: 0; }
.color-filter button.active { box-shadow: 0 0 0 2px var(--text); }

.seg { display: inline-flex; background: var(--hover); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; border-radius: 999px; padding: 4px 14px; font-weight: 600; color: var(--muted); }
.seg button:hover { color: var(--text); }
.seg button.active { background: #fff; color: var(--blue); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg.small button { padding: 2px 12px; font-size: 13px; }

/* قائمة العرض زي جوجل */
.view-menu { position: relative; }
.view-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 600;
}
.view-btn:hover, .view-btn[aria-expanded="true"] { background: var(--hover); }
.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 270px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0,0,0,.06), 0 12px 32px rgba(16,30,70,.16);
  padding: 6px 0;
}
.menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  border: none;
  background: none;
  padding: 8px 18px;
  font-size: 14px;
  text-align: right;
}
.menu button:hover { background: var(--hover); }
.menu button.active { color: var(--blue); font-weight: 700; background: var(--blue-soft); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }
.menu .tick { width: 18px; height: 18px; flex: none; text-align: center; }
.menu .check.on .tick::before { content: "✓"; color: var(--blue); font-style: normal; font-weight: 800; font-size: 15px; }

/* الصف التاني: إحصائيات + الدليل + تراجع */
.stats-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 24px; padding: 0 24px 10px; }
.stats { color: var(--muted); font-size: 12.5px; display: flex; gap: 16px; }
.stats b { color: var(--text); }
.view-opts { display: flex; align-items: center; gap: 4px; }
.view-opts .btn-ghost.dark { font-size: 12.5px; }

/* دليل الألوان (سطر صغير) */
.legend-inline { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; flex-wrap: wrap; }
.legend-title { font-size: 12.5px; color: var(--muted); }
.legend-list { display: flex; flex-wrap: wrap; gap: 4px; }
.legend-empty { color: var(--faint); font-size: 12.5px; }
.legend-item { display: inline-flex; align-items: center; gap: 0; border-radius: 999px; padding: 0 2px 0 8px; }
.legend-item:hover { background: var(--hover); }
.legend-item.active { background: var(--blue-soft); }
.legend-item .chip { display: inline-flex; align-items: center; gap: 6px; border: none; background: none; padding: 2px 0; font-size: 12.5px; }
.legend-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend-item .edit { width: 22px; height: 22px; border-radius: 50%; border: none; background: transparent; color: var(--faint); display: grid; place-items: center; padding: 0; opacity: 0; }
.legend-item:hover .edit { opacity: 1; }
.legend-item .edit:hover { color: var(--blue); }
.legend-item .edit svg { width: 12px; height: 12px; }
.legend-add { width: 22px; height: 22px; border-radius: 50%; border: 1px dashed var(--faint); background: #fff; color: var(--muted); font-weight: 700; line-height: 1; padding: 0; }
.legend-add:hover { border: 1px solid var(--blue); color: var(--blue); }

/* ---------- الجدول ---------- */
.board-wrap { padding: 0 24px 24px; overflow-x: auto; }
.board {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.board thead th {
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
  padding: 10px 6px;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.board thead th.corner { background: var(--blue-dark); color: #fff; font-weight: 600; }

.board tbody th.week {
  background: var(--blue-soft);
  text-align: right;
  vertical-align: top;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
  font-weight: 400;
  position: relative;
  overflow: hidden;
}
.board tbody tr:first-child th.week, .board tbody tr:first-child td.day { border-top: none; }
.week-label { display: block; font-weight: 700; font-size: 12.5px; color: var(--blue); margin-bottom: 4px; }
.week-date { display: block; font-size: 11.5px; line-height: 1.5; color: var(--text); }
.week-date.hijri { color: var(--blue); opacity: .8; }

/* مقابض تغيير المقاس (زي الإكسيل) */
.col-resizer { position: absolute; top: 0; bottom: 0; left: -1px; width: 8px; cursor: col-resize; z-index: 3; }
.col-resizer::after { content: ""; position: absolute; top: 25%; bottom: 25%; left: 3px; width: 1px; background: rgba(255,255,255,.35); }
.col-resizer:hover::after, .col-resizer.active::after { background: var(--orange); width: 2px; top: 0; bottom: 0; }
.row-resizer { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: row-resize; z-index: 3; }
.row-resizer:hover, .row-resizer.active { background: linear-gradient(transparent 6px, var(--orange) 6px); }
body.resizing-col, body.resizing-col * { cursor: col-resize !important; user-select: none; }
body.resizing-row, body.resizing-row * { cursor: row-resize !important; user-select: none; }

.cell-inner { min-height: 100px; }
.board.view-week .cell-inner, .board.view-x4 .cell-inner { min-height: 280px; }
.board.view-day .cell-inner { min-height: 320px; }
.board tr.sized .cell-inner { height: var(--row-h); min-height: 0; overflow-y: auto; overflow-x: hidden; }
.board tr.sized .week-inner { height: calc(var(--row-h) - 8px); overflow: hidden; }

.board td.day {
  vertical-align: top;
  border-top: 1px solid var(--line-soft);
  border-inline-start: 1px solid var(--line-soft);
  padding: 4px 6px 6px;
  background: #fff;
  position: relative;
  overflow: hidden;
  transition: background .15s, opacity .15s;
}
.board td.day.colored::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--day-bar, var(--day-color)); }
.board td.day.out .day-num .g { color: var(--faint); font-weight: 500; }
.board td.day.dimmed { opacity: .3; }
.board td.day.drop-target { box-shadow: inset 0 0 0 2px var(--blue); }
.board td.day.sel { box-shadow: inset 0 0 0 2px var(--blue); }
.board td.day.sel::after { content: ""; position: absolute; inset: 0; background: rgba(26,68,181,.06); pointer-events: none; }

.day-head { display: flex; justify-content: center; margin-bottom: 4px; }
.day-num { display: flex; flex-direction: column; align-items: center; line-height: 1.3; cursor: pointer; min-width: 0; max-width: 100%; }
.day-num .g {
  font-weight: 600;
  font-size: 12.5px;
  min-width: 24px;
  height: 24px;
  line-height: 24px;
  border-radius: 999px;
  text-align: center;
  padding: 0 4px;
}
.day-num:hover .g { background: var(--hover); }
.today .day-num .g, .today .day-num:hover .g { background: var(--blue); color: #fff; }
.day-num .h { font-size: 10.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* أدوات اليوم: بتظهر بس لما تقف على اليوم */
.day-tools { position: absolute; top: 5px; inset-inline-end: 5px; display: flex; gap: 3px; opacity: 0; transition: opacity .12s; z-index: 2; }
td.day:hover .day-tools, td.day.sel .day-tools, th.hday:hover .day-tools, .day-tools:focus-within { opacity: 1; }
.day-tools button {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--hover);
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}
.day-tools button:hover { background: var(--line); color: var(--text); }
.day-tools button.add { background: var(--orange); color: #fff; font-weight: 700; }
.day-tools button.add:hover { background: var(--orange-dark); }
.day-tools svg { width: 13px; height: 13px; }

/* ليبل بداية/نهاية الشهر الهجري */
.hlabel {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.55;
  padding: 0 6px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* ---------- المهام (سطور خفيفة زي جوجل) ---------- */
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; min-height: 22px; }
.task {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--task-accent, var(--blue));
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 12.5px;
  line-height: 20px;
  cursor: grab;
  min-width: 0;
}
.task:hover { border-color: #C3CCE0; border-inline-start-color: var(--task-accent, var(--blue)); }
.task.dragging { opacity: .4; }
.task.hidden { display: none; }
.task.selected { background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }

/* دايرة "خلصت" */
.task input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 12px;
  height: 12px;
  margin: 0;
  border-radius: 50%;
  border: 2px solid var(--task-accent, var(--blue));
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.task input[type=checkbox]:checked { background: var(--task-accent, var(--blue)); }
.task input[type=checkbox]:checked::after { content: ""; width: 4px; height: 4px; border-radius: 50%; background: #fff; }
.time-badge { flex: none; font-size: 11.5px; font-weight: 600; color: var(--muted); white-space: nowrap; unicode-bidi: isolate; }
.task .title { flex: 1; min-width: 0; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task.done .title { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--text); color: var(--muted); }
.task.done .time-badge { opacity: .55; }

.placeholder { height: 3px; border-radius: 2px; background: var(--orange); list-style: none; }
.adder input { width: 100%; border: 1px solid var(--blue); border-radius: 6px; padding: 3px 7px; font-size: 12.5px; background: #fff; }
.adder input:focus { outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }

/* ---------- العرض بالساعات (زي جوجل كالندر) ---------- */
.board-wrap.hours-wrap { max-height: calc(100vh - 170px); min-height: 380px; overflow: auto; margin: 0 24px 24px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.board.mode-hours { overflow: visible; border: none; border-radius: 0; }
.board.mode-hours.view-week { min-width: 980px; }
.board.mode-hours thead th { position: sticky; top: 0; z-index: 20; padding: 8px 6px; white-space: normal; vertical-align: top; }
.board.mode-hours thead th.corner { z-index: 21; font-size: 11px; vertical-align: bottom; }
.hday { text-align: center; }
.hday-head { display: flex; justify-content: center; }
.hday-name { display: flex; flex-direction: column; align-items: center; line-height: 1.3; cursor: pointer; min-width: 0; }
.hday-name .n { font-size: 12px; font-weight: 700; color: #fff; opacity: .9; }
.hday-name .g { font-size: 21px; font-weight: 600; color: #fff; min-width: 38px; height: 38px; line-height: 38px; border-radius: 50%; }
.hday-name:hover .g { background: rgba(255,255,255,.15); }
.hday.today .hday-name .g, .hday.today .hday-name:hover .g { background: #fff; color: var(--blue); }
.hday-name .h { font-size: 10.5px; font-weight: 400; color: #fff; opacity: .8; white-space: nowrap; }
.hday .day-tools button { background: rgba(255,255,255,.18); color: #fff; }
.hday .day-tools button:hover { background: rgba(255,255,255,.3); color: #fff; }
.hday .day-tools button.add { background: var(--orange); }
.hday.colored { box-shadow: inset 0 -4px 0 var(--day-color); }
.hday.sel { box-shadow: inset 0 0 0 2px var(--blue); }
.hday .day-tools { top: 6px; }

.board th.hour {
  width: 64px;
  background: #fff;
  color: var(--faint);
  font-size: 11px;
  font-weight: 500;
  vertical-align: top;
  text-align: center;
  padding: 0;
  white-space: nowrap;
}
.board th.hour.allday-label { background: var(--blue-soft); color: var(--blue); font-weight: 700; vertical-align: middle; padding: 6px 2px; border-bottom: 1px solid var(--line); }

.board td.slot {
  border-inline-start: 1px solid var(--line-soft);
  padding: 4px 4px;
  vertical-align: top;
  position: relative;
  cursor: cell;
}
.board td.slot.allday { border-bottom: 1px solid var(--line); min-height: 36px; }
.board td.slot.allday .tasks { min-height: 22px; }
.board td.slot.drop-target { box-shadow: inset 0 0 0 2px var(--blue); }
.board td.slot.dimmed, .board td.daycol.dimmed { opacity: .3; }

/* محور الساعات + أعمدة الأيام */
.hours-axis { position: relative; }
.hours-axis .hl { position: absolute; left: 0; right: 0; padding-inline-end: 8px; text-align: left; transform: translateY(-7px); }
.hours-axis .hl:first-child { transform: none; }
.board td.daycol { padding: 0; border-inline-start: 1px solid var(--line-soft); vertical-align: top; }
.daycol-inner { position: relative; cursor: cell; }
.hline { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--line-soft); pointer-events: none; }
.hline.gap { border-top: 2px dashed var(--line); }
.daycol.today-col .daycol-inner { background: #FFFCF5; }

/* بلوك الموعد */
.task.ev {
  position: absolute;
  align-items: flex-start;
  flex-direction: column;
  gap: 0;
  padding: 2px 6px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--ev-bg, var(--blue-soft));
  border: none;
  border-inline-start: 3px solid var(--task-accent, var(--blue));
  line-height: 1.35;
  font-size: 12px;
  z-index: 1;
  box-shadow: 0 0 0 1px #fff;
}
.task.ev:hover { filter: brightness(.97); z-index: 2; }
.task.ev .ev-top { display: flex; align-items: center; gap: 5px; width: 100%; min-width: 0; }
.task.ev .title { font-weight: 600; }
.task.ev .time-badge { font-size: 11px; }
.task.ev.short { flex-direction: row; align-items: center; }
.task.ev.done { opacity: .6; }
.drop-ghost {
  position: absolute;
  left: 2px;
  right: 2px;
  height: 0;
  border-top: 2px solid var(--orange);
  pointer-events: none;
  z-index: 4;
}
.drop-ghost span { position: absolute; top: -10px; inset-inline-start: 4px; background: var(--orange); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 4px; padding: 0 5px; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #EA4335; z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; right: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #EA4335; }
.hours-empty { padding: 10px 14px; color: var(--faint); font-size: 12.5px; text-align: center; }

/* ---------- عرض السنة ---------- */
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 28px 32px; padding: 6px 4px; }
.ym-head { display: flex; flex-direction: column; margin-bottom: 8px; }
.ym-head h3 { margin: 0; font-size: 15px; font-weight: 600; cursor: pointer; }
.ym-head h3:hover { color: var(--blue); }
.ym-head span { font-size: 11px; color: var(--faint); }
.ym-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.ym-wd { font-size: 10.5px; color: var(--faint); font-weight: 600; padding-bottom: 4px; }
.ym-day { position: relative; font-size: 11.5px; line-height: 26px; border-radius: 50%; cursor: pointer; aspect-ratio: 1; max-width: 30px; margin: 0 auto; width: 100%; }
.ym-day:hover { background: var(--hover); }
.ym-day.today { background: var(--blue) !important; color: #fff; font-weight: 700; }
.ym-day.sel { box-shadow: inset 0 0 0 2px var(--blue) !important; }
.ym-day.dimmed { opacity: .3; }
.ym-day .ym-dot { position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--orange); }

/* ---------- جدول المواعيد ---------- */
.agenda { border-top: 1px solid var(--line); }
.ag-day { display: flex; gap: 20px; padding: 12px 8px; border-bottom: 1px solid var(--line-soft); align-items: flex-start; }
.ag-day.sel { box-shadow: inset 0 0 0 2px var(--blue); background: #F8FAFE; }
.ag-date { width: 170px; flex: none; display: flex; align-items: flex-start; gap: 10px; cursor: pointer; border-inline-start: 3px solid var(--ag-color, transparent); padding-inline-start: 8px; }
.ag-date .g { font-size: 22px; font-weight: 500; min-width: 36px; height: 36px; line-height: 36px; text-align: center; border-radius: 50%; }
.ag-date .info { display: flex; flex-direction: column; line-height: 1.35; padding-top: 2px; }
.ag-date .n { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.ag-date .h { font-size: 11px; color: var(--faint); }
.ag-day.today .ag-date .g { background: var(--blue); color: #fff; }
.ag-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ag-label { font-size: 12px; font-weight: 700; }
.ag-body .tasks { min-height: 0; gap: 2px; }
.ag-body .task { font-size: 13.5px; padding: 3px 6px; }
.ag-add { align-self: flex-start; border: none; background: none; color: var(--faint); font-size: 12.5px; padding: 0 6px; }
.ag-add:hover { color: var(--blue); }
.empty-view { padding: 48px; text-align: center; color: var(--faint); }

/* ---------- شريط التحديد ---------- */
body.selecting, body.selecting * { user-select: none; }
.sel-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  max-width: calc(100vw - 32px);
  background: #2B2F36;
  color: #fff;
  border-radius: 12px;
  padding: 8px 10px 8px 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.28);
}
.sel-count { font-weight: 700; font-size: 13.5px; padding-inline-end: 4px; }
.sel-group { display: flex; flex-wrap: wrap; gap: 4px; padding-inline-start: 10px; border-inline-start: 1px solid rgba(255,255,255,.2); }
.sel-bar button { border: none; background: rgba(255,255,255,.1); color: #fff; border-radius: 7px; padding: 5px 10px; font-size: 13px; font-weight: 600; }
.sel-bar button:hover { background: rgba(255,255,255,.22); }
.sel-bar button.danger { color: #FDA29B; }
.sel-bar .sel-close { background: transparent; font-size: 15px; padding: 4px 8px; }

/* ---------- النوافذ ---------- */
.modal {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(460px, calc(100vw - 32px));
  box-shadow: 0 24px 60px rgba(16,30,70,.28);
}
.modal::backdrop { background: rgba(16,30,70,.35); }
.modal form { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { margin: 0; font-size: 18px; font-weight: 600; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13.5px; }
.modal label.check { flex-direction: row; align-items: center; gap: 8px; }
.modal textarea, .modal input[type=date], .modal input[type=text], .modal input[type=time], .modal select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font-weight: 400;
  background: #fff;
}
.modal textarea { resize: vertical; }
.modal textarea:focus, .modal input:focus, .modal select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.modal input[type=date] { width: 100%; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.modal-hint { margin: -4px 0 0; font-size: 12.5px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 600; font-size: 13.5px; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-hint { font-size: 12px; color: var(--faint); }
.field-hint b { color: var(--muted); font-weight: 600; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.time-range { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.time-range span { font-size: 13px; color: var(--muted); }
.time-range input { flex: 1; min-width: 110px; }
.check-group { display: flex; gap: 18px; }
.hijri-pick { display: grid; grid-template-columns: 70px 1fr 100px; gap: 6px; }
.date-equiv { font-size: 12.5px; color: var(--blue); font-weight: 600; min-height: 1.4em; }
.date-equiv.bad { color: var(--danger); }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input { width: 44px; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 1px; background: #fff; flex: none; }
.color-row .hlabel { font-size: 11px; padding: 1px 8px; margin: 0; }

.legend-colors { display: flex; align-items: center; gap: 10px; }
.legend-colors .swatches { flex: 1; }
.legend-colors input[type=color] { width: 44px; height: 34px; border: 1px solid var(--line); border-radius: 6px; padding: 1px; background: #fff; flex: none; }

/* ---------- اختيار اللون ---------- */
.color-pop {
  position: absolute;
  z-index: 95;
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  width: 230px;
  box-shadow: 0 4px 6px rgba(0,0,0,.06), 0 12px 32px rgba(16,30,70,.18);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.color-pop-title { font-weight: 600; font-size: 13px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.swatches button { aspect-ratio: 1; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); padding: 0; }
.swatches button.active { box-shadow: 0 0 0 2px var(--text); }
.custom-color { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.custom-color input { width: 44px; height: 28px; border: 1px solid var(--line); border-radius: 6px; padding: 1px; background: #fff; }
.pop-legend { display: flex; flex-direction: column; gap: 2px; }
.pop-legend:empty { display: none; }
.pop-legend button { display: flex; align-items: center; gap: 8px; border: 1px solid transparent; background: none; border-radius: 6px; padding: 4px 6px; font-size: 13px; text-align: right; }
.pop-legend button:hover { background: var(--hover); }
.pop-legend button.active { border-color: var(--text); }
.pop-legend .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }

/* ---------- تنبيه ---------- */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: #2B2F36;
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.toast button { border: none; background: none; color: #FFB547; font-weight: 800; padding: 2px 4px; }
.toast button:hover { text-decoration: underline; }

/* ---------- صفحة الدخول ---------- */
.auth-page { min-height: 100vh; background: var(--blue); display: grid; place-items: center; padding: 16px; }
.auth-card { background: #fff; border-radius: 16px; padding: 32px 28px; width: min(400px, 100%); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; background: var(--blue); color: #fff; border-radius: 12px; padding: 16px; margin-bottom: 22px; }
.auth-brand .brand-name { font-size: 20px; }
.auth-brand .brand-sub { font-size: 9px; letter-spacing: 4px; }
.auth-card h1 { margin: 0 0 4px; font-size: 20px; color: var(--blue); text-align: center; }
.auth-hint { margin: 0 0 12px; text-align: center; color: var(--muted); font-size: 14px; }
.auth-error { background: #FEF3F2; color: var(--danger); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 12px 0; }
.auth-notice { background: var(--blue-soft); color: var(--blue); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 12px 0; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.auth-form input { height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; }
.auth-form input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.auth-form .btn-primary { height: 44px; font-size: 16px; border-radius: 8px; }
.btn-google { width: 100%; height: 44px; margin-top: 14px; background: #fff; border-color: var(--line); color: var(--text); border-radius: 8px; }
.btn-google:hover { background: var(--hover); }
.auth-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 16px 0 0; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- صفحة المستخدمين ---------- */
.users-page { max-width: 1100px; margin: 0 auto; padding: 24px; }
.users-hint { color: var(--muted); margin: 0 0 14px; }
.users-table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.users-table th { background: var(--surface); color: var(--muted); text-align: right; padding: 10px 14px; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid var(--line); }
.users-table td { padding: 10px 14px; border-top: 1px solid var(--line-soft); font-size: 13.5px; vertical-align: middle; }
.users-table tr:first-child td { border-top: none; }
.users-table td.email { text-align: right; color: var(--muted); }
.users-table tr.st-pending td { background: #FFFAF0; }
.users-table tr.st-rejected td { opacity: .6; }
.users-table .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; background: var(--hover); color: var(--muted); margin-inline-start: 4px; }
.badge.admin { background: var(--blue-soft); color: var(--blue); }
.st-pending .badge.st { background: #FDE7C2; color: #8A5300; }
.st-active .badge.st { background: #DCF5E3; color: #157038; }
.st-rejected .badge.st { background: #FDE2E0; color: var(--danger); }
form.inline { display: inline; margin: 0; }

/* ---------- موبايل ---------- */
@media (max-width: 720px) {
  .topbar { padding: 6px 14px; }
  .brand-divider, .brand-title, .user-name { display: none; }
  .toolbar { padding: 12px 14px 8px; }
  .filters, .filters input[type=search] { width: 100%; }
  .stats-row { padding: 0 14px 8px; }
  .board-wrap { padding: 0 14px 20px; }
  .board-wrap.hours-wrap { margin: 0 14px 20px; }
  .ag-day { flex-direction: column; gap: 8px; }
  .ag-date { width: auto; }
  .row-2 { grid-template-columns: 1fr; }
}

/* صف "طوال اليوم" ثابت تحت أسماء الأيام في العرض بالساعات */
.board.mode-hours .sticky-allday { position: sticky; z-index: 4; background-color: #fff; }
.board.mode-hours th.sticky-allday { background: var(--blue-soft); z-index: 15; }

/* ---------- المهمة الممدودة على كذا يوم (شريط زي جوجل) ---------- */
.board td.day, .board td.slot.allday { overflow: visible; }
.span-space { flex: none; }
.task.span-bar {
  position: absolute;
  inset-inline-start: 3px;
  height: 21px;
  z-index: 3;
  background: var(--ev-bg, #DCE5FA);
  border: none;
  border-inline-start: 4px solid var(--task-accent, var(--blue));
  border-radius: 6px;
  font-weight: 600;
  padding: 0 8px;
  box-shadow: 0 1px 2px rgba(16, 30, 70, .12);
}
.task.span-bar:hover { filter: brightness(.97); }
.task.span-bar.cont-start { border-start-start-radius: 0; border-end-start-radius: 0; border-inline-start: none; padding-inline-start: 10px; }
.task.span-bar.cont-end { border-start-end-radius: 0; border-end-end-radius: 0; }
.task.span-bar .title { flex: 0 1 auto; }
.span-range { flex: 1; min-width: 0; font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task.span-bar.selected { box-shadow: 0 0 0 2px var(--blue); }
.span-day { flex: none; font-size: 11px; font-weight: 700; color: var(--blue); background: var(--blue-soft); border-radius: 999px; padding: 0 8px; }

/* شريط التحديد: زرار المهمة على الأيام */
.sel-bar button.accent { background: var(--orange); }
.sel-bar button.accent:hover { background: var(--orange-dark); }

/* نافذة الإضافة: "من" و"لحد" */
.date-pair { display: flex; align-items: center; gap: 8px; }
.date-pair .pair-label { width: 28px; flex: none; font-size: 13px; color: var(--muted); }
.date-pair input[type=date], .date-pair .hijri-pick { flex: 1; }
.hijri-pick.empty select { color: var(--faint); }

/* المهمة اللي خلصت: خط عليها وبتفضل مكانها */
.task.done { opacity: .85; }
.task.ev.done .title, .task.span-bar.done .title { text-decoration: line-through; text-decoration-thickness: 2px; }

/* شريط ألوان اليوم في العرض بالساعات لما يكون أكتر من لون */
.hday { position: sticky; }
.hday-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; }

/* ---------- اختيار شهر / يوم / كذا شهر ---------- */
.date-pick {
  position: absolute;
  z-index: 96;
  width: 330px;
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 4px 6px rgba(0,0,0,.06), 0 16px 40px rgba(16,30,70,.2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dp-year { display: flex; align-items: center; gap: 2px; }
.dp-year b { min-width: 74px; text-align: center; font-size: 15px; }
.dp-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dp-months button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 4px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dp-months button:hover { border-color: var(--blue); color: var(--blue); }
.dp-months button.now { color: var(--orange-dark); }
.dp-months button.sel { background: var(--blue); border-color: var(--blue); color: #fff; }
.dp-months button.anchor:not(.sel) { box-shadow: inset 0 0 0 2px var(--blue); }
.dp-hint { margin: 0; font-size: 11.5px; color: var(--faint); text-align: center; }
.dp-days-title { font-size: 13px; font-weight: 700; color: var(--blue); border-top: 1px solid var(--line-soft); padding-top: 10px; }
.dp-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.dp-wd { font-size: 11px; color: var(--faint); font-weight: 700; }
.dp-day { border: none; background: none; border-radius: 8px; padding: 3px 0; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.dp-day b { font-size: 13px; }
.dp-day small { font-size: 9.5px; color: var(--faint); }
.dp-day:hover { box-shadow: inset 0 0 0 1px var(--blue); }
.dp-day.today b { color: #fff; background: var(--blue); border-radius: 50%; width: 22px; line-height: 22px; }

/* ---------- قاعدة التلوين التلقائي في الدليل ---------- */
.rule-box { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border-radius: 10px; padding: 12px; }
.rule-label { font-size: 13px; font-weight: 600; margin-top: 4px; }
.rule-label small { font-weight: 400; color: var(--faint); }
.weekday-pick { display: flex; flex-wrap: wrap; gap: 5px; }
.weekday-pick button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12.5px; }
.weekday-pick button.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.rule-row { display: flex; gap: 8px; align-items: center; }
.rule-row input { flex: 1; }
.rule-box input[type=text] { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; }
#lRuleHint { color: var(--blue); font-weight: 600; }
#lRuleHint.bad { color: var(--danger); }
.auto-mark { font-size: 10px; font-weight: 700; color: var(--blue); background: var(--blue-soft); border-radius: 999px; padding: 0 6px; }

/* تقويم صغير في نافذة اللون */
#legendDialog { width: min(520px, calc(100vw - 32px)); }
#legendDialog form { max-height: calc(100vh - 40px); overflow-y: auto; }
.mini-cal { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.mc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.mc-head b { font-size: 12.5px; text-align: center; }
.mc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.mc-wd { font-size: 11px; color: var(--faint); font-weight: 700; }
.mc-day { border: none; background: none; border-radius: 8px; padding: 3px 0; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.mc-day b { font-size: 13px; }
.mc-day small { font-size: 9.5px; opacity: .7; }
.mc-day:hover { box-shadow: inset 0 0 0 1px var(--blue); }
.mc-day.on { font-weight: 800; }
.mc-day.today:not(.on) b { color: var(--blue); text-decoration: underline; }
.legend-colors .swatches { grid-template-columns: repeat(auto-fill, 28px); gap: 8px; }

/* التقويم الصغير: اختيار الشهر من العنوان */
.mc-title { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; border: none; background: none; border-radius: 8px; padding: 6px; font-weight: 700; font-size: 13px; color: var(--blue); margin-bottom: 4px; }
.mc-title:hover { background: var(--hover); }
.mc-months { display: flex; flex-direction: column; gap: 8px; background: var(--surface); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.mc-months .btn-primary.sm { align-self: center; padding: 4px 22px; }
.mc-month + .mc-month { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.mc-month-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.mc-month-title b { font-size: 12.5px; color: var(--blue); }
.mc-month-title span { font-size: 11px; color: var(--faint); }

/* ---------- رأس اليوم: سطر واحد (الميلادي في طرف والهجري في الطرف التاني) ---------- */
.board td.day .day-head { display: block; margin-bottom: 4px; }
.board td.day .day-num {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  max-width: none;
}
.board td.day .day-num .g {
  font-size: 13.5px;
  font-weight: 700;
  min-width: 24px;
  height: 24px;
  line-height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  white-space: nowrap;
  flex: none;
}
.board td.day .day-num .h {
  font-size: 11px;
  color: var(--faint);
  line-height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  min-width: 0;
}
.board td.day .day-num .mark { font-weight: 700; }
.board td.day .day-num .h.mark { font-size: 10.5px; }
.board td.day.today .day-num .g:not(.mark) { background: var(--blue); color: #fff; }
.board td.day.today .day-num .g.mark { box-shadow: 0 0 0 2px var(--blue); }
.board td.day.out .day-num .g:not(.mark) { color: var(--faint); font-weight: 500; }
.board td.day .day-num:hover .g:not(.mark) { background: var(--hover); }
.board td.day.today .day-num:hover .g:not(.mark) { background: var(--blue); }

/* أزرار اليوم (+ والألوان): تحت في الركن وقت ما تقف على اليوم، من غير ما تغطي الأرقام */
.board td.day .day-tools { top: auto; bottom: 5px; inset-inline-end: 5px; }
/* لو الليبلين طوال في نفس اليوم: كل واحد ياخد مساحته من غير ما يخرج برا الخانة */
.board td.day .day-num .g { flex: 0 1 auto; min-width: 24px; overflow: hidden; text-overflow: ellipsis; }
/* لو الخانة ضيقة: الليبل ينزل سطر بدل ما يتقص */
.board td.day .day-num { flex-wrap: wrap; row-gap: 3px; }
.board td.day .day-num .g, .board td.day .day-num .h { flex: 0 0 auto; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
/* حرف م (ميلادي) و هـ (هجري) جنب الرقم */
.cal-tag { font-size: .72em; font-weight: 600; opacity: .7; margin-inline-start: 2px; }
.mark .cal-tag { opacity: .9; }
.hday-name .g .cal-tag { font-size: 11px; }
/* الليبل الطويل في خانة ضيقة: يكمل على سطرين جوه نفس الشارة بدل ما يتقص */
.board td.day .day-num .mark { white-space: normal; text-overflow: clip; height: auto; line-height: 1.45; padding: 2px 8px; border-radius: 10px; }
/* الشارة دايمًا سطر واحد — الاختصار بيحصل من الكود (fitDayBadges) */
.board td.day .day-num { flex-wrap: nowrap; }
.board td.day .day-num .mark { white-space: nowrap; overflow: hidden; height: 22px; line-height: 22px; padding: 0 8px; border-radius: 999px; }
.board td.day .day-num .g, .board td.day .day-num .h { flex: 0 1 auto; min-width: 0; }
.board td.day .day-num.wrap { flex-wrap: wrap; row-gap: 3px; }
/* الرقم العادي عمره ما يتضغط — الشارة الملونة بس هي اللي بتختصر */
.board td.day .day-num > span:not(.mark) { flex: none; overflow: visible; }

/* ---------- المهمة اللي خلصت: بتفضل مكانها، عليها خط + علامة "خلصت" ---------- */
.task.done { opacity: 1; background: #F6F8F7; }
.task.done .title { color: var(--muted); }
.task.done::after {
  content: "✓ خلصت";
  flex: none;
  font-size: 10px;
  font-weight: 700;
  color: #157038;
  background: #DCF5E3;
  border-radius: 999px;
  padding: 0 6px;
  line-height: 16px;
}
.task.ev.done::after { position: absolute; top: 3px; inset-inline-end: 4px; }
.task.ev.done { opacity: .75; }

/* ---------- ليبل بداية/نهاية الشهر: أصغر ---------- */
.board td.day .day-num .mark { height: 18px; line-height: 18px; font-size: 10px; padding: 0 6px; font-weight: 700; }
.board td.day .day-num .mark .cal-tag { font-size: 9px; }
/* "خلصت" = الدايرة بتبقى خضرا وجواها ✓ (بدل شارة تاخد مكان من اسم المهمة) */
.task.done::after { content: none; }
.task.done input[type=checkbox] { width: 14px; height: 14px; border-color: #1E9E50; background: #1E9E50; }
.task.done input[type=checkbox]::after { content: "✓"; width: auto; height: auto; border-radius: 0; background: none; color: #fff; font-size: 10px; font-weight: 800; line-height: 1; }
.task.done .title { text-decoration-color: #1E9E50; }

/* =========================================================
   الموبايل
   ========================================================= */
.only-mobile { display: none !important; }

/* الشهر على الموبايل: جدول صغير */
.board.mobile-month { table-layout: fixed; width: 100%; border-radius: 12px; }
.board.mobile-month thead th { font-size: 11px; padding: 8px 0; }
.board.mobile-month td.mday {
  position: relative;
  height: 56px;
  padding: 4px 0 6px;
  text-align: center;
  vertical-align: top;
  border-top: 1px solid var(--line-soft);
  border-inline-start: 1px solid var(--line-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.board.mobile-month td.mday::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--day-bar, transparent); }
.mday .g { display: block; margin: 0 auto; width: 26px; height: 26px; line-height: 26px; border-radius: 50%; font-weight: 700; font-size: 13.5px; }
.mday .h { display: block; font-size: 9.5px; color: var(--faint); line-height: 1.2; }
.mday .dots { display: flex; justify-content: center; gap: 2px; margin-top: 2px; }
.mday .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--orange); }
.mday.out .g { color: var(--faint); font-weight: 500; }
.mday.today .g { background: var(--blue); color: #fff; }
.mday.picked { box-shadow: inset 0 0 0 2px var(--blue); }
.mday.sel { box-shadow: inset 0 0 0 2px var(--orange); }
.mday.dimmed { opacity: .35; }

/* مهام اليوم تحت الجدول / كروت الأسبوع */
.m-panel { margin-top: 12px; }
.m-list { display: flex; flex-direction: column; gap: 10px; }
.m-day {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px 10px;
  overflow: hidden;
}
.m-day::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--day-bar, transparent); }
.m-day.today { border-color: var(--blue); }
.m-day.sel { box-shadow: 0 0 0 2px var(--blue); }
.m-day.dimmed { opacity: .4; }
.m-day-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.m-date { display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 0; }
.m-date b { font-size: 15px; color: var(--blue); }
.m-date > span { font-size: 12px; color: var(--muted); }
.m-date .hlabel { align-self: flex-start; font-size: 10px; }
.m-colors { font-size: 12px !important; font-weight: 700; }
.m-day .day-tools { position: static; opacity: 1; }
.m-day .day-tools button { width: 34px; height: 34px; font-size: 18px; }
.m-day .day-tools svg { width: 16px; height: 16px; }
.m-day .tasks { gap: 6px; }
.m-day .task { font-size: 14px; line-height: 24px; padding: 6px 10px; }
.m-day .task input[type=checkbox] { width: 18px; height: 18px; }
.m-empty { margin: 4px 0 0; color: var(--faint); font-size: 13px; }

/* زرار الإضافة العايم */
.fab {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 80;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  border: none;
  background: var(--orange);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  box-shadow: 0 8px 22px rgba(243,146,0,.45);
}
.fab:active { transform: scale(.96); }

@media (hover: none) {
  .day-tools { opacity: 1; }
  .legend-item .edit { opacity: 1; }
}

@media (max-width: 760px) {
  .only-mobile { display: inline-flex !important; }
  body { font-size: 14px; }

  /* الهيدر */
  .topbar { padding: 6px 12px; }
  .brand-divider, .brand-title, .user-name { display: none; }
  .user-box { gap: 6px; }
  .user-box .btn-ghost { padding: 4px 10px; font-size: 12px; }

  /* شريط الأدوات */
  .toolbar { padding: 10px 12px 6px; gap: 8px; }
  .month-nav { width: 100%; gap: 6px; }
  .month-title { order: -1; flex: 1 1 100%; min-width: 0; padding: 2px 4px; }
  .month-title h1 { font-size: 18px; }
  .view-btn { height: 34px; padding: 0 10px; }
  #newTaskBtn { display: none; }
  #todayBtn { padding: 6px 12px; }
  #modeSeg { flex: 1 1 100%; justify-content: center; }
  #modeSeg button { flex: 1; }

  /* الفلاتر مستخبية لحد ما تدوس "فلتر" */
  .filters { display: none; width: 100%; }
  body.show-filters .filters { display: flex; }
  .filters input[type=search] { width: 100%; }
  .filters select { flex: 1; }

  /* الإحصائيات + الدليل */
  .stats-row { padding: 0 12px 8px; gap: 6px; }
  .stats { gap: 12px; font-size: 12px; }
  .legend-inline { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; }
  .legend-list { flex-wrap: nowrap; }
  .legend-item { flex: none; }
  .view-opts { width: 100%; justify-content: space-between; }
  #resetSizes { display: none; }

  /* الجدول */
  .board-wrap { padding: 0 8px 96px; }
  .board-wrap.hours-wrap { margin: 0 8px 96px; max-height: calc(100vh - 150px); }
  .board.mode-hours.view-week, .board.mode-hours.view-x4 { min-width: 720px; }
  .year-grid { grid-template-columns: repeat(2, 1fr); gap: 18px 12px; }
  .ym-day { line-height: 22px; font-size: 11px; }

  /* النوافذ */
  .modal form { padding: 18px 16px; }
  .modal-actions .btn-primary, .modal-actions .btn-outline { flex: 1; }
  .date-pick { width: calc(100vw - 16px); left: 8px !important; }
  .dp-months button { font-size: 12px; padding: 8px 2px; }
  .sel-bar { bottom: 86px; padding: 6px 8px; gap: 6px; }
  .sel-bar button { padding: 5px 8px; font-size: 12px; }
  .sel-group { padding-inline-start: 6px; }
  .toast { top: auto; bottom: 90px; max-width: calc(100vw - 24px); }
  .menu { right: 0; min-width: 240px; }
}
@media (max-width: 760px) {
  .view-opts { width: auto; margin-inline-start: auto; }
  .stats-row { flex-wrap: wrap; }
  .legend-inline { order: 3; }
  .users-page { padding: 14px 10px; overflow-x: auto; }
  .users-table { min-width: 640px; }
}

/* أزرار "كذا شهر" و"تحديد" للموبايل */
.multi-toggle { display: none; border: 1px dashed var(--blue); background: #fff; color: var(--blue); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; }
.multi-toggle.on { background: var(--blue); color: #fff; border-style: solid; }
#selModeBtn.on { background: var(--blue); color: #fff; border-color: var(--blue); }
@media (max-width: 760px), (hover: none) {
  .multi-toggle { display: block; align-self: center; }
  .dp-hint { display: none; }
}
@media (max-width: 760px) {
  .sel-bar { left: 8px; right: 8px; transform: none; max-width: none; justify-content: space-between; }
  .sel-group { flex: 1 1 100%; border-inline-start: none; padding-inline-start: 0; }
  .sel-group button { flex: 1 1 auto; }
}
@media (max-width: 760px) {
  .sel-count { order: 0; flex: 1; }
  .sel-bar .sel-close { order: 1; }
  .sel-group { order: 2; }
}
