/* إنجاز — نظام التصميم. RTL أولاً، هادئ، حدود خفيفة. */

:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f3f3f1;
  --hover: #efefec;
  --border: #e8e7e3;
  --border-strong: #d8d7d2;
  --text: #1c1d21;
  --text-2: #5b5d65;
  --text-3: #8b8d95;
  --accent: #3b4fd8;
  --accent-hover: #3243c4;
  --accent-soft: #edf0fd;
  --accent-text: #2f40bd;
  --danger: #d33a3a;
  --danger-soft: #fdeeee;
  --amber: #b86e00;
  --amber-soft: #fff3df;
  --green: #22894e;
  --green-soft: #e6f5ec;
  --p-high: #e0483e;
  --p-medium: #e59400;
  --p-low: #3d7fe0;
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, .06);
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 6px 20px rgba(20, 20, 30, .08);
  --shadow-lg: 0 10px 40px rgba(20, 20, 30, .18);
  --radius: 10px;
  --sidebar-w: 248px;
  --detail-w: 440px;
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171b; --surface: #1d1f24; --surface-2: #24262c; --hover: #2a2d34; --border: #2d3037; --border-strong: #3a3d45;
    --text: #ececee; --text-2: #a9abb3; --text-3: #767982; --accent: #7486ff; --accent-hover: #8797ff; --accent-soft: #252b4d; --accent-text: #9eabff;
    --danger: #f06464; --danger-soft: #3a2224; --amber: #f0a73a; --amber-soft: #3a2e1a; --green: #4cc27d; --green-soft: #1d3326;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35); --shadow-lg: 0 12px 48px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16171b; --surface: #1d1f24; --surface-2: #24262c; --hover: #2a2d34; --border: #2d3037; --border-strong: #3a3d45;
  --text: #ececee; --text-2: #a9abb3; --text-3: #767982; --accent: #7486ff; --accent-hover: #8797ff; --accent-soft: #252b4d; --accent-text: #9eabff;
  --danger: #f06464; --danger-soft: #3a2224; --amber: #f0a73a; --amber-soft: #3a2e1a; --green: #4cc27d; --green-soft: #1d3326;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35); --shadow-lg: 0 12px 48px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* ألوان المشاريع */
.c-slate { --c: #8b8d95; } .c-red { --c: #e5484d; } .c-orange { --c: #f07a2b; } .c-amber { --c: #e5a000; }
.c-green { --c: #2fa35f; } .c-teal { --c: #12a59a; } .c-blue { --c: #3d7fe0; } .c-violet { --c: #7c5ce0; } .c-pink { --c: #de4f96; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
.ic { flex-shrink: 0; display: block; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); margin: 0 0 12px; }
.no-select, .no-select * { user-select: none !important; -webkit-user-select: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scroll-y { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ── الهيكل ── */
.app { height: 100vh; height: 100dvh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.app.has-detail { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--detail-w); }
.app.loading, .app.logged-out { display: block; }
.main { min-width: 0; height: 100%; }
.detail { display: none; }
.has-detail .detail { display: block; background: var(--surface); border-inline-start: 1px solid var(--border); min-width: 0; height: 100%; overflow: hidden; }
.bottom-nav { display: none; }

.splash { height: 100%; min-height: 60vh; display: grid; place-content: center; justify-items: center; gap: 16px; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.logo.lg { width: 56px; height: 56px; border-radius: 16px; }
.splash .logo { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; transform: scale(.94); } }

/* ── الشريط الجانبي ── */
.sidebar { background: var(--surface-2); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 10px; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 8px 12px; }
.new-task { margin: 0 2px 10px; }
.new-task kbd { margin-inline-start: auto; font: 11px/1 var(--font); background: rgba(255,255,255,.18); padding: 3px 6px; border-radius: 4px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.nav-item .dot { margin: 0 5px; }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-section { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 18px 10px 6px; }
.nav-spacer { flex: 1; min-height: 16px; }

/* ── الصفحة ── */
.page { max-width: 920px; margin: 0 auto; padding: 28px 32px 120px; }
.has-detail .page { padding-inline: 24px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-sub { margin: 2px 0 0; color: var(--text-3); font-size: 13px; }
.page-actions { display: flex; gap: 6px; }
.project-head { flex-direction: column; align-items: stretch; gap: 6px; }
.ph-row { display: flex; align-items: center; gap: 10px; }
.title-input { flex: 1; min-width: 0; font-size: 24px; font-weight: 700; border: 0; background: none; padding: 2px 4px; margin: 0 -4px; border-radius: 6px; }
.title-input:hover { background: var(--hover); }
.title-input:focus { outline: none; background: var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.desc-input { width: 100%; border: 0; background: none; resize: none; color: var(--text-2); padding: 4px; margin: 0 -4px; border-radius: 6px; min-height: 30px; overflow: hidden; }
.desc-input:hover { background: var(--hover); }
.desc-input:focus { outline: none; background: var(--surface); box-shadow: 0 0 0 1px var(--border-strong); color: var(--text); }
.p-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.color-btn { width: 22px; height: 22px; border-radius: 7px; background: var(--c); flex-shrink: 0; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }

/* ── أزرار وحقول ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 9px; font-weight: 600; border: 1px solid transparent; transition: background .12s; white-space: nowrap; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: var(--border); background: var(--surface); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.danger-text { color: var(--danger); }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; display: inline-grid; place-items: center; color: var(--text-2); flex-shrink: 0; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.link-btn { color: var(--text-3); font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.link-btn:hover { color: var(--text); background: var(--hover); }
.field { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stack { display: flex; flex-direction: column; gap: 10px; max-width: 380px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--text-3)); flex-shrink: 0; }
.dot.lg { width: 10px; height: 10px; }

/* الشرائح (فلاتر سريعة) */
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.chip.ghost { border-style: dashed; }
.chip-n { font-size: 11.5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--surface-2); color: var(--text-2); display: inline-grid; place-items: center; }
.chip.active .chip-n { background: rgba(127,127,127,.28); color: inherit; }
.chip.warn:not(.active) .chip-n { background: var(--danger-soft); color: var(--danger); }

/* قوائم الاختيار بشكل حبّة */
.pill-select { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 13px; cursor: pointer; max-width: 100%; }
.pill-select:hover { border-color: var(--border-strong); color: var(--text); }
.pill-select.has-value { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.pill-select .caret { opacity: .6; }
.pill-select-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-select-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.pill-select.sm { height: 28px; font-size: 12.5px; }
.pill-select.wide { width: 100%; max-width: 320px; justify-content: space-between; height: 34px; }
.pill-select.wide.has-value { background: var(--surface); border-color: var(--border); color: var(--text); }
.pill-select.wide:not(.has-value) { color: var(--text-3); }

/* مجموعة أزرار */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 7px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button.on.s-doing { color: var(--amber); }
.seg button.on.s-done { color: var(--green); }
.seg button.on.p-high { color: var(--p-high); }
.seg button.on.p-medium { color: var(--p-medium); }
.seg button.on.p-low { color: var(--p-low); }

/* ── عرض المهام ── */
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1; min-width: 0; }
.view-toggle { flex-shrink: 0; }

.add-row { display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 46px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 18px; transition: border-color .12s, box-shadow .12s; }
.add-row:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.add-plus { color: var(--accent); display: grid; }
.add-input { flex: 1; min-width: 0; border: 0; background: none; height: 100%; font-size: 15px; }
.add-input:focus { outline: none; }
.add-input::placeholder { color: var(--text-3); }

.group { margin-bottom: 18px; }
.group-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); padding: 4px 4px 8px; width: 100%; text-align: start; }
.group-head .count { color: var(--text-3); font-weight: 500; }
.g-overdue .group-head > span:first-child { color: var(--danger); }
.group-head.collapsible { border-radius: 6px; }
.group-head.collapsible:hover { color: var(--text); }
.group-head .caret { transition: transform .15s; transform: rotate(90deg); }
.group-head.open .caret { transform: none; }
.rows { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

/* سطر المهمة */
.task-row { display: flex; align-items: flex-start; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s, opacity .3s; position: relative; }
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--hover); }
.task-row.selected { background: var(--accent-soft); }
.task-row:focus-visible { outline-offset: -2px; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 500; overflow-wrap: anywhere; }
.is-done .task-title, .is-done .card-title { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 3px; font-size: 12.5px; color: var(--text-3); }
.task-meta:empty { display: none; }
.meta { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.meta.due.overdue { color: var(--danger); font-weight: 500; }
.meta.due.today { color: var(--green); font-weight: 500; }
.meta.due.soon { color: var(--amber); }
.task-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding-top: 1px; }
.organize { display: flex; }
.prio-flag { display: grid; }
.prio-flag.p-high { color: var(--p-high); } .prio-flag.p-medium { color: var(--p-medium); } .prio-flag.p-low { color: var(--p-low); }

.status-pill { font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.status-pill.s-doing { background: var(--amber-soft); color: var(--amber); }
.status-pill.s-done { background: var(--green-soft); color: var(--green); }
.status-pill.ps-active { background: var(--accent-soft); color: var(--accent-text); }
.status-pill.ps-paused { background: var(--amber-soft); color: var(--amber); }
.status-pill.ps-done { background: var(--green-soft); color: var(--green); }

/* دائرة الإنجاز: لونها حسب الأولوية */
.check { --ring: var(--text-3); width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; border: 1.8px solid var(--ring); display: grid; place-items: center; color: transparent; flex-shrink: 0; transition: background .15s, color .15s; position: relative; }
.check::before { content: ''; position: absolute; inset: -10px; }
.check.prio-high { --ring: var(--p-high); background: color-mix(in srgb, var(--p-high) 8%, transparent); }
.check.prio-medium { --ring: var(--p-medium); background: color-mix(in srgb, var(--p-medium) 8%, transparent); }
.check.prio-low { --ring: var(--p-low); background: color-mix(in srgb, var(--p-low) 8%, transparent); }
.check:hover { color: var(--ring); }
.check.doing { background: conic-gradient(var(--ring) 0 50%, transparent 50% 100%); }
.check.doing:hover { color: #fff; }
.check.done, .completing .check { background: var(--ring); color: #fff; }
.check.prio-none.done, .completing .check.prio-none { --ring: var(--green); }
.check.sm { width: 17px; height: 17px; }
.completing { opacity: .45; }
.completing .task-title { text-decoration: line-through; }

/* ── اللوحة (كانبان) ── */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: start; }
.board-col { background: var(--surface-2); border-radius: 12px; padding: 8px; min-height: 140px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-weight: 600; font-size: 13px; }
.col-head .count { color: var(--text-3); font-weight: 500; }
.col-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); }
.col-dot.s-doing { background: var(--p-medium); }
.col-dot.s-done { background: var(--green); }
.col-list { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.col-empty { border: 1.5px dashed var(--border-strong); border-radius: 10px; color: var(--text-3); font-size: 12.5px; text-align: center; padding: 18px 8px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow-sm); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.card:hover { border-color: var(--border-strong); }
.card.selected { border-color: var(--accent); }
.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-title { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.card .task-meta { margin-top: 6px; }
.drag-source { opacity: .3; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; box-shadow: var(--shadow-lg); cursor: grabbing; will-change: transform; margin: 0; }
.drop-placeholder { border: 2px dashed var(--accent); border-radius: 10px; background: var(--accent-soft); opacity: .7; }
.board.dragging { cursor: grabbing; }

/* ── تفاصيل المهمة ── */
.detail-inner { display: flex; flex-direction: column; height: 100%; }
.detail-inner.drop-hover { box-shadow: inset 0 0 0 2px var(--accent); }
.d-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); min-height: 52px; }
.d-crumbs { flex: 1; min-width: 0; }
.crumb { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); padding: 4px 8px; border-radius: 6px; max-width: 100%; }
.crumb:hover { background: var(--hover); color: var(--text); }
.d-body { flex: 1; padding: 18px 22px 40px; }
.d-title-row { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.d-check { padding-top: 6px; }
.d-title { flex: 1; min-width: 0; font-size: 20px; font-weight: 600; line-height: 1.45; border: 0; background: none; resize: none; padding: 2px 6px; margin: 0 -6px; border-radius: 6px; overflow: hidden; }
.d-title:hover { background: var(--hover); }
.d-title:focus { outline: none; background: var(--surface-2); }
.d-props { display: flex; flex-direction: column; gap: 4px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.prop { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.prop-label { display: flex; align-items: center; gap: 8px; width: 92px; flex-shrink: 0; color: var(--text-3); font-size: 13px; }
.prop-value { flex: 1; min-width: 0; }
.date-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip.sm.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.date-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); font-size: 13px; color: var(--text-2); cursor: pointer; overflow: hidden; }
.date-pick.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.date-input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; font-size: 16px; }
.date-input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.d-section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.d-section:last-of-type { border-bottom: 0; }
.d-section h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.d-section h4 .count { color: var(--text-3); font-weight: 500; }
.d-desc { width: 100%; min-height: 80px; border: 1px solid transparent; background: var(--surface-2); border-radius: 9px; padding: 10px 12px; resize: none; line-height: 1.7; overflow: hidden; }
.d-desc:focus { outline: none; background: var(--surface); border-color: var(--border-strong); }
.d-desc::placeholder { color: var(--text-3); }
.progress { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; margin: 0 0 10px; }
.progress i { display: block; height: 100%; background: var(--green); border-radius: 2px; transition: width .25s; }
.sub { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.sub .check { margin: 0; }
.sub.done .check { --ring: var(--green); }
.sub-title { flex: 1; min-width: 0; border: 0; background: none; padding: 5px 6px; border-radius: 6px; }
.sub-title:hover { background: var(--hover); }
.sub-title:focus { outline: none; background: var(--surface-2); }
.sub.done .sub-title { color: var(--text-3); text-decoration: line-through; }
.sub-del { opacity: 0; }
.sub:hover .sub-del, .sub:focus-within .sub-del { opacity: 1; }
.sub-add-row { display: flex; align-items: center; gap: 10px; color: var(--text-3); padding: 2px 1px; }
.sub-add { flex: 1; border: 0; background: none; padding: 7px 6px; border-radius: 6px; }
.sub-add:focus { outline: none; background: var(--surface-2); }
.file-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.file-list:empty { display: none; }
.file { display: flex; align-items: center; gap: 8px; padding: 6px; border: 1px solid var(--border); border-radius: 9px; }
.file-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.thumb, .file-icon { width: 42px; height: 42px; border-radius: 7px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); flex-shrink: 0; }
.file-info { min-width: 0; display: flex; flex-direction: column; }
.file-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; font-size: 13px; }
.file-size { font-size: 12px; color: var(--text-3); }
.uploading { font-size: 13px; color: var(--accent-text); margin-bottom: 10px; }
.d-footer { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-3); padding-top: 14px; }
.only-mobile { display: none; }

/* ── المشاريع والعملاء ── */
.p-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.p-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; transition: border-color .12s, box-shadow .12s; }
.p-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.p-card.archived { opacity: .65; }
.p-card-top { display: flex; align-items: center; gap: 10px; }
.p-name { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-mark { color: var(--text-3); }
.p-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 12.5px; color: var(--text-3); }
.p-card .progress { margin: 0; }
.swatches { display: grid; grid-template-columns: repeat(5, 28px); gap: 8px; padding: 8px; }
.swatch { width: 28px; height: 28px; border-radius: 8px; background: var(--c); }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.meta.pinned { color: var(--text-2); font-size: 13px; }

.c-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.c-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.c-row:last-child { border-bottom: 0; }
.c-row:hover { background: var(--hover); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.avatar.lg { width: 40px; height: 40px; font-size: 17px; }
.c-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.c-name { font-weight: 600; }
.c-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--text-3); }
.c-count { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

.settings { display: flex; flex-direction: column; gap: 14px; }
.card-section { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.card-section h3 { margin: 0 0 12px; font-size: 15px; }

.more-list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.more-item { display: flex; align-items: center; gap: 14px; padding: 15px 16px; border-bottom: 1px solid var(--border); font-weight: 500; }
.more-item:last-child { border-bottom: 0; }
.more-item span { flex: 1; }
.more-item .chev { color: var(--text-3); }
.more-title { font-size: 12.5px; color: var(--text-3); font-weight: 600; margin: 0; padding: 16px 16px 6px; background: var(--bg); border-bottom: 1px solid var(--border); }

/* ── الفراغ ── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 20px; color: var(--text-2); }
.empty-icon { width: 60px; height: 60px; border-radius: 18px; background: var(--surface-2); color: var(--text-3); display: grid; place-items: center; margin-bottom: 14px; }
.empty-title { font-weight: 600; font-size: 16px; color: var(--text); }
.empty-hint { margin-top: 4px; font-size: 13.5px; max-width: 340px; color: var(--text-3); }

/* ── قوائم منبثقة، تأكيد، تنبيه ── */
.menu { position: fixed; z-index: 200; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow-lg); padding: 5px; animation: pop .12s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; text-align: start; }
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.menu-item span { flex: 1; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 6px; }

.dialog-back { position: fixed; inset: 0; z-index: 300; background: rgba(10, 10, 20, .35); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px; padding: 20px; box-shadow: var(--shadow-lg); }
.dialog h3 { margin: 0 0 6px; font-size: 17px; }
.dialog p { margin: 0 0 18px; color: var(--text-2); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

#toast-root { position: fixed; bottom: 24px; left: 0; right: 0; display: flex; justify-content: center; z-index: 400; pointer-events: none; padding: 0 16px; }
.toast { display: flex; align-items: center; gap: 14px; background: #202127; color: #f2f2f4; padding: 10px 12px 10px 16px; border-radius: 11px; box-shadow: var(--shadow-lg); pointer-events: auto; opacity: 0; transform: translateY(8px); transition: opacity .18s, transform .18s; font-weight: 500; max-width: 100%; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #b8322f; }
.toast-action { color: #9fb0ff; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.toast-action:hover { background: rgba(255,255,255,.1); }

/* ── الإضافة السريعة ── */
.fab { position: fixed; z-index: 60; left: 24px; bottom: 24px; width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent); transition: transform .12s, background .12s; }
.fab:hover { background: var(--accent-hover); }
.fab:active { transform: scale(.94); }
.qa-back { position: fixed; inset: 0; z-index: 250; background: rgba(10, 10, 20, 0); transition: background .18s; display: flex; justify-content: center; align-items: flex-start; padding: 16vh 16px 16px; }
.qa-back.show { background: rgba(10, 10, 20, .32); }
.qa-sheet { width: 100%; max-width: 580px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 10px; transform: translateY(-8px); opacity: 0; transition: transform .18s, opacity .18s; }
.qa-back.show .qa-sheet { transform: none; opacity: 1; }
.qa-row { display: flex; align-items: center; gap: 8px; }
.qa-input { flex: 1; min-width: 0; height: 50px; border: 0; background: none; font-size: 18px; padding: 0 8px; }
.qa-input:focus { outline: none; }
.qa-send { width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.qa-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); margin-top: 6px; padding: 8px 8px 2px; }
.qa-status { font-size: 12.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.qa-status.ok { color: var(--green); }

/* ── الدخول ── */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.login-card h1 { margin: 8px 0 0; font-size: 26px; }
.login-card .muted { margin: 0 0 12px; }
.form-error { color: var(--danger); margin: 0; min-height: 1.4em; font-size: 13px; }

/* ── شاشات متوسطة: التفاصيل فوق المحتوى ── */
@media (max-width: 1180px) and (min-width: 768px) {
  .app.has-detail { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .has-detail .detail { position: fixed; top: 0; bottom: 0; left: 0; width: min(var(--detail-w), 100vw - var(--sidebar-w)); z-index: 70; box-shadow: var(--shadow-lg); }
}

/* ── الموبايل ── */
@media (max-width: 767px) {
  .app, .app.has-detail { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .page { padding: calc(14px + env(safe-area-inset-top)) 16px 120px; }
  .page-head { margin-bottom: 14px; }
  .page-head h1 { font-size: 26px; }
  .title-input { font-size: 22px; }

  .bottom-nav { display: flex; position: fixed; z-index: 50; bottom: 0; left: 0; right: 0; height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--border); }
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 500; color: var(--text-3); }
  .tab.active { color: var(--accent); }
  .tab-icon { position: relative; }
  .badge { position: absolute; top: -5px; left: -10px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); box-sizing: content-box; }
  .fab { left: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); }
  #toast-root { bottom: calc(146px + env(safe-area-inset-bottom)); }

  .has-detail .detail { position: fixed; inset: 0; z-index: 80; border: 0; animation: slide-in .22s ease-out; }
  @keyframes slide-in { from { transform: translateX(-24px); opacity: 0; } }
  .has-detail .bottom-nav, .has-detail .fab { display: none; }
  .d-head { padding-top: calc(8px + env(safe-area-inset-top)); }
  .d-body { padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }
  .only-mobile { display: block; }
  .only-desktop { display: none; }
  .prop { flex-direction: column; align-items: stretch; gap: 6px; padding: 6px 0; }
  .prop-label { width: auto; }
  .pill-select.wide { max-width: none; height: 40px; }
  .sub-del { opacity: 1; }

  .toolbar-row { flex-wrap: nowrap; }
  .chips { gap: 5px; margin-inline-end: -16px; padding-inline-end: 16px; }
  .chip { padding: 0 11px; font-size: 13.5px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline-start: -16px; padding-inline-start: 16px; }
  .filters::-webkit-scrollbar { display: none; }
  .filters .pill-select { flex-shrink: 0; }
  .view-toggle button span { display: none; }
  .view-toggle button { padding: 0 8px; }
  .task-row { padding: 12px; }
  .task-side .status-pill.s-todo { display: none; }
  .organize .pill-select-label { display: none; }
  .organize .pill-select { padding: 0 8px; }

  .board { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px; margin: 0 -16px; padding: 0 16px 8px; scrollbar-width: none; }
  .board::-webkit-scrollbar { display: none; }
  .board-col { flex: 0 0 84%; scroll-snap-align: center; }
  .board.dragging { scroll-snap-type: none; }

  .qa-back { padding: calc(10px + env(safe-area-inset-top)) 10px 10px; }
  .qa-back.show { background: rgba(10, 10, 20, .4); }
  .p-grid { grid-template-columns: 1fr; }
  .d-title { font-size: 19px; }

  /* iOS بيكبّر الصفحة لأي حقل خطه أصغر من ١٦px */
  input, textarea, select, .add-input, .sub-title, .sub-add, .d-desc, .field { font-size: 16px; }
  .title-input { font-size: 22px; }
  .d-title { font-size: 19px; }
  .qa-input { font-size: 18px; }
}

@media (hover: none) {
  .task-row:not(.selected):hover, .c-row:hover, .nav-item:not(.active):hover { background: transparent; }
  .task-row:active, .c-row:active, .more-item:active { background: var(--hover); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 768px) { .has-detail .fab { display: none; } }
