/* الحثناوي - نفس نظام تصميم برنامج الكمبيوتر (آبل HIG): وضوح، احترام للمحتوى، عمق */
:root {
  --bg: #F5F5F7; --surface: #FFFFFF; --hover: #EBEBF0; --border: #E5E5EA;
  --text: #1D1D1F; --text2: #6E6E73; --text3: #8E8E93;
  --accent: #007AFF; --accent-soft: rgba(0,122,255,.12); --success: #34C759; --warning: #FF9500;
  --danger: #FF3B30; --sel-bg: #eaf2f8; --sel-text: #1b4f72;
  --board: #2d5a3d; --board2: #23492f; --chalk: rgba(255,255,255,.92);
  --glass: rgba(245,245,247,.72);
  --shadow: 0 4px 12px rgba(0,0,0,.08); --shadow-lift: 0 8px 24px rgba(0,0,0,.18);
  --radius: 8px; --ease: cubic-bezier(.22,1,.36,1);   /* OutCubic */
  --tap: 44px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Tahoma, sans-serif;
  font-size: 15px; letter-spacing: -0.01em;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C1C1E; --surface: #2C2C2E; --hover: #3A3A3C; --border: #3A3A3C;
    --text: #F5F5F7; --text2: #AEAEB2; --text3: #8E8E93; --accent: #0A84FF;
    --accent-soft: rgba(10,132,255,.22); --sel-bg: rgba(10,132,255,.22); --sel-text: #64D2FF;
    --glass: rgba(28,28,30,.72); --shadow: 0 4px 12px rgba(0,0,0,.4); --shadow-lift: 0 8px 24px rgba(0,0,0,.55);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { direction: rtl; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
input { font: inherit; }
.hidden { display: none !important; }
.caption { color: var(--text2); font-size: 12px; }
.title { font-size: 20px; font-weight: 600; margin: 0; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* أزرار */
.btn { min-height: var(--tap); padding: 0 18px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; transition: background .2s var(--ease), transform .2s var(--ease); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
.btn.plain { background: transparent; border-color: transparent; color: var(--accent); }
.btn.round { width: var(--tap); padding: 0; display: grid; place-items: center; border-radius: 50%; }
.seg { display: inline-flex; background: var(--hover); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; min-height: 32px; padding: 0 14px; border-radius: 7px; cursor: pointer; color: var(--text2); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.field { width: 100%; min-height: var(--tap); border: 1px solid var(--border); border-radius: 10px; padding: 0 14px;
  background: var(--surface); color: var(--text); outline: none; }
.field:focus { border-color: var(--accent); }

/* هيكل الصفحة: شريط فوق زجاجي + محتوى + شريط تبويب تحت (زي آيفون) */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--border); }
.topbar .title { flex: 1; }
.bell { position: relative; width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--hover);
  display: grid; place-items: center; cursor: pointer; }
.bell .badge { position: absolute; top: -4px; left: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--surface); }
main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }
.tabbar { position: fixed; bottom: 0; inset-inline: 0; z-index: 20; display: flex; justify-content: space-around;
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px); background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--border); }
.tabbar button { flex: 1; min-height: 49px; border: 0; background: transparent; color: var(--text3); font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabbar button.on { color: var(--accent); }
.tabbar svg, .icon { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* بطاقات */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  transition: box-shadow .2s var(--ease), transform .2s var(--ease); }
.list { background: var(--surface); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: var(--tap); padding: 10px 16px; border-bottom: .5px solid var(--border); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:active { background: var(--hover); }
.row .grow { flex: 1; min-width: 0; }
.row .sub { color: var(--text2); font-size: 12px; }
.chev { color: var(--text3); }
.search { margin-bottom: 12px; }
.empty { text-align: center; color: var(--text2); padding: 48px 16px; }

/* الدخول */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login .box { width: min(380px, 100%); text-align: center; display: grid; gap: 12px; }
.login img { width: 84px; height: 84px; border-radius: 20px; margin: 0 auto; box-shadow: var(--shadow); }
.err { color: var(--danger); min-height: 18px; font-size: 13px; }

/* الخطة: لوح أخضر بخطوط رفيعة */
.plan-wrap { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .plan-wrap { grid-template-columns: 340px 1fr; } }
@media (max-width: 899px) { .plan-wrap .board { order: -1; } }      /* الموبايل: التقويم أول، أوراق اليوم تحته */
.paper .more { color: var(--accent); font-size: 12px; margin-top: 6px; }
.paper ul { margin: 6px 0 0; padding-inline-start: 16px; color: var(--text2); font-size: 12px; }
.board { background: radial-gradient(120% 120% at 70% 0%, #326647 0%, var(--board) 45%, var(--board2) 100%);
  border-radius: 14px; padding: 14px; color: var(--chalk); box-shadow: inset 0 0 0 1px rgba(0,0,0,.25), var(--shadow); }
.board .month { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 8px; }
.board .month b { font-size: 18px; font-weight: 600; min-width: 150px; text-align: center; }
.board .month button { color: var(--chalk); background: transparent; border: 0; width: var(--tap); height: var(--tap); border-radius: 50%; cursor: pointer; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal .wd { text-align: center; font-size: 11px; opacity: .7; padding: 4px 0 6px; }
.cal .day { position: relative; min-height: 62px; border-top: .5px solid rgba(255,255,255,.2); border-left: .5px solid rgba(255,255,255,.2);
  padding: 4px; cursor: pointer; transition: background .2s var(--ease); }
.cal .day:nth-child(7n+7) { border-left: 0; }
.cal .day.out { background:
  linear-gradient(to top left, transparent calc(50% - .5px), rgba(255,255,255,.28) 50%, transparent calc(50% + .5px)),
  linear-gradient(to top right, transparent calc(50% - .5px), rgba(255,255,255,.28) 50%, transparent calc(50% + .5px));
  opacity: .55; cursor: default; }
.cal .n { font-size: 13px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal .today .n { border: 2px solid #fff; font-weight: 700; }
.cal .sel { background: rgba(255,255,255,.12); }
.cal .drop { background: rgba(255,255,255,.22); }
.cal .dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.cal .dots i { font-style: normal; font-size: 10px; min-width: 16px; height: 14px; padding: 0 3px; border-radius: 4px; color: #1D1D1F; display: grid; place-items: center; }

/* أوراق اليوم: بطاقات آبل */
.papers { display: grid; gap: 10px; align-content: start; }
.paper { background: var(--surface); color: var(--text); border-radius: 6px; padding: 12px 14px; box-shadow: var(--shadow);
  border-inline-start: 4px solid var(--c, var(--accent)); touch-action: pan-y; }
.paper .t { font-weight: 600; font-size: 14px; }
.paper .d { color: var(--text2); font-size: 12px; margin-top: 2px; }
.paper .a { font-weight: 600; margin-top: 6px; }
.paper.draggable { cursor: grab; }

/* لوحة كانبان */
.lanes { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto;
  scroll-snap-type: x mandatory; padding-bottom: 8px; }
.lane { background: var(--hover); border-radius: 12px; padding: 10px; scroll-snap-align: start; min-height: 240px;
  transition: background .2s var(--ease); }
.lane.drop { background: var(--accent-soft); }
.lane h3 { margin: 4px 4px 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.lane h3 .dot { width: 10px; height: 10px; border-radius: 50%; }
.lane h3 .cnt { color: var(--text3); font-weight: 400; font-size: 12px; }
.kcard { background: var(--surface); border-radius: 8px; padding: 12px; box-shadow: var(--shadow); margin-bottom: 10px;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.kcard .t { font-size: 16px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.kcard .lvl { width: 12px; height: 12px; border-radius: 50%; border: 2px solid; flex: none; }
.kcard .c { color: var(--text2); font-size: 12px; margin-top: 4px; }
.kcard .chip { font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 1px 8px; margin-inline-start: auto; font-weight: 400; }
.placeholder { opacity: .25; }
/* البطاقة المسحوبة: بترتفع (ظل أعمق + تكبير 2%) وبتلحق الإصبع بسلاسة */
.dragging { position: fixed; z-index: 100; pointer-events: none; margin: 0; box-shadow: var(--shadow-lift);
  transform-origin: center; will-change: transform; transition: none; }
.dragging.settle { transition: transform .2s var(--ease), opacity .2s var(--ease); }
body.drag-active main > * { filter: saturate(.92); }

/* التنبيهات: بطاقة عائمة زي مركز إشعارات ماك */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.18); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .2s var(--ease); }
.overlay.show { opacity: 1; }
.panel { position: fixed; z-index: 61; top: calc(env(safe-area-inset-top) + 60px); inset-inline-end: 12px; width: min(400px, calc(100% - 24px));
  max-height: 70vh; overflow: auto; background: var(--glass); backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: .5px solid var(--border); border-radius: 18px; box-shadow: 0 20px 50px rgba(0,0,0,.25); padding: 12px;
  transform: translateY(-8px) scale(.98); opacity: 0; transition: transform .2s var(--ease), opacity .2s var(--ease); }
.panel.show { transform: none; opacity: 1; }
.alert { display: flex; gap: 10px; background: var(--surface); border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.alert .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid; margin-top: 3px; flex: none; }
.alert.urgent .dot { animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(231,76,60,.5); } 100% { box-shadow: 0 0 0 10px rgba(231,76,60,0); } }

/* ورقة تفاصيل (Sheet) */
.sheet { position: fixed; z-index: 61; inset-inline: 0; bottom: 0; max-height: 88vh; overflow: auto; background: var(--bg);
  border-radius: 16px 16px 0 0; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  transform: translateY(100%); transition: transform .25s var(--ease); }
.sheet.show { transform: none; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--border); margin: 6px auto 12px; }
@media (min-width: 900px) { .sheet { inset-inline: auto 24px; width: 520px; bottom: 24px; border-radius: 16px; } }

/* المالية */
.heroes { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .heroes { grid-template-columns: repeat(3, 1fr); } }
.hero .lbl { font-size: 12px; color: var(--text2); }
.hero .val { font-size: 28px; font-weight: 700; margin: 4px 0; }
.hero .tr { font-size: 12px; }
.bars { display: flex; gap: 4px; align-items: flex-end; height: 34px; }
.bars i { flex: 1; border-radius: 3px; opacity: .35; }
.bars i:last-child { opacity: 1; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; }

.toast { position: fixed; z-index: 90; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%) translateY(20px);
  background: rgba(29,29,31,.92); color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; transition: all .2s var(--ease); font-size: 14px; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
