/* ============================================================
   بصمة — نظام التصميم
   ورق دافئ · حبر · بورغندي · نحاس — خطوط البصمة هي الهوية
   ============================================================ */
:root {
  --paper: #f3eee5;
  --paper-2: #ebe3d5;
  --card: #fbf8f2;
  --card-2: #f6f1e8;
  --ink: #1b1513;
  --ink-2: #4a3f3a;
  --ink-3: #85786f;
  --hair: rgba(27, 21, 19, .08);
  --hair-2: rgba(27, 21, 19, .16);
  --brand: #8c1236;
  --brand-2: #b0284f;
  --brand-soft: rgba(140, 18, 54, .08);
  --brass: #b8892f;
  --brass-2: #d8b06a;
  --ok: #2f6f5e;
  --ok-soft: rgba(47, 111, 94, .12);
  --warn: #a87619;
  --warn-soft: rgba(168, 118, 25, .14);
  --bad: #b3261e;
  --bad-soft: rgba(179, 38, 30, .1);
  --info: #3d5a80;
  --info-soft: rgba(61, 90, 128, .12);
  --rail: #16110f;
  --rail-ink: #efe6d8;
  --rail-ink-2: rgba(239, 230, 216, .55);
  --shadow-sm: 0 1px 2px rgba(40, 20, 10, .06), 0 6px 16px -10px rgba(40, 20, 10, .18);
  --shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 2px 6px rgba(40, 20, 10, .05), 0 24px 48px -28px rgba(40, 20, 10, .35);
  --shadow-lg: 0 40px 80px -30px rgba(30, 10, 5, .45);
  --radius: 22px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --f-display: "Alexandria", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --f-body: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --rail-w: 252px;
  --gutter: clamp(16px, 3vw, 36px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
  :root:not([data-theme="light"]) {
    --paper: #110d0c; --paper-2: #181311; --card: #1c1715; --card-2: #221b18;
    --ink: #f1e9dd; --ink-2: #c9bcae; --ink-3: #8d8075;
    --hair: rgba(241, 233, 221, .07); --hair-2: rgba(241, 233, 221, .14);
    --brand: #e0577f; --brand-2: #f07a9b; --brand-soft: rgba(224, 87, 127, .12);
    --brass: #d6ad5e; --brass-2: #e9c987;
    --ok: #5fb39a; --ok-soft: rgba(95, 179, 154, .14);
    --warn: #e0a83c; --warn-soft: rgba(224, 168, 60, .14);
    --bad: #f0675d; --bad-soft: rgba(240, 103, 93, .13);
    --info: #8fb0dc; --info-soft: rgba(143, 176, 220, .13);
    --rail: #0b0807;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 24px 48px -28px rgba(0, 0, 0, .8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #110d0c; --paper-2: #181311; --card: #1c1715; --card-2: #221b18;
  --ink: #f1e9dd; --ink-2: #c9bcae; --ink-3: #8d8075;
  --hair: rgba(241, 233, 221, .07); --hair-2: rgba(241, 233, 221, .14);
  --brand: #e0577f; --brand-2: #f07a9b; --brand-soft: rgba(224, 87, 127, .12);
  --brass: #d6ad5e; --brass-2: #e9c987;
  --ok: #5fb39a; --ok-soft: rgba(95, 179, 154, .14);
  --warn: #e0a83c; --warn-soft: rgba(224, 168, 60, .14);
  --bad: #f0675d; --bad-soft: rgba(240, 103, 93, .13);
  --info: #8fb0dc; --info-soft: rgba(143, 176, 220, .13);
  --rail: #0b0807;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 24px 48px -28px rgba(0, 0, 0, .8);
}

/* ---------------------------------------------------------- أساسيات */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
  overflow-x: hidden;
}
body::before { /* حبيبات الورق */
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: .5;
  background-image: radial-gradient(rgba(120, 90, 60, .05) 1px, transparent 1px);
  background-size: 3px 3px;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 6px; }
.num, .tnum { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { min-height: 100dvh; display: grid; place-items: center; }
.boot-mark { width: 56px; height: 56px; border-radius: 16px; animation: breathe 1.6s var(--ease) infinite; }
@keyframes breathe { 50% { transform: scale(.92); opacity: .6; } }

/* ---------------------------------------------------------- الهيكل */
.shell {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100dvh;
}
.rail {
  position: sticky; top: 0;
  height: 100dvh;
  background: var(--rail);
  color: var(--rail-ink);
  display: flex; flex-direction: column;
  padding: 22px 16px 18px;
  overflow: hidden;
  isolation: isolate;
}
.rail::after { /* خطوط بصمة باهتة */
  content: "";
  position: absolute; inset: auto -120px -160px auto;
  width: 420px; height: 420px;
  background: repeating-radial-gradient(ellipse at 40% 45%, transparent 0 9px, rgba(216, 176, 106, .07) 9px 10px);
  border-radius: 50%;
  z-index: -1;
  transform: rotate(-18deg);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; text-decoration: none; color: inherit; }
.brand img { width: 40px; height: 40px; border-radius: 12px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .08); }
.brand b { font-family: var(--f-display); font-weight: 800; font-size: 1.35rem; letter-spacing: -.01em; display: block; line-height: 1.1; }
.brand small { color: var(--rail-ink-2); font-size: .72rem; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  color: var(--rail-ink-2);
  text-decoration: none;
  font-weight: 500;
  transition: background .25s var(--ease), color .25s var(--ease);
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { color: var(--rail-ink); background: rgba(255, 255, 255, .04); }
.nav a[aria-current="page"] { color: var(--rail-ink); background: rgba(255, 255, 255, .07); }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; inset-inline-start: -16px; top: 10px; bottom: 10px;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--brass-2);
}
.nav .count {
  margin-inline-start: auto;
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 11px; background: var(--brand-2); color: #fff;
  font-size: .72rem; font-weight: 700; display: grid; place-items: center;
}
.rail-foot { margin-top: auto; display: grid; gap: 10px; }
.sync-pill {
  display: flex; align-items: center; gap: 10px;
  font-size: .76rem; color: var(--rail-ink-2);
  padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .04);
}
.sync-pill i { width: 8px; height: 8px; border-radius: 50%; background: #6ac2a4; box-shadow: 0 0 0 4px rgba(106, 194, 164, .15); flex: none; }
.sync-pill.stale i { background: var(--brass-2); box-shadow: 0 0 0 4px rgba(216, 176, 106, .15); }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 14px; background: rgba(255, 255, 255, .05); }
.me-chip .av { width: 36px; height: 36px; font-size: .9rem; }
.me-chip b { display: block; font-size: .86rem; line-height: 1.2; }
.me-chip small { color: var(--rail-ink-2); font-size: .72rem; }
.me-chip .icon-btn { margin-inline-start: auto; color: var(--rail-ink-2); }
.me-chip .icon-btn:hover { color: var(--rail-ink); background: rgba(255, 255, 255, .08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px var(--gutter);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border-bottom: 1px solid var(--hair);
}
.topbar h1 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.25rem, 2.2vw, 1.7rem);
  letter-spacing: -.015em;
  line-height: 1.2;
}
.topbar .sub { color: var(--ink-3); font-size: .82rem; }
.topbar .tools { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.content { padding: 26px var(--gutter) 120px; display: grid; gap: 22px; align-content: start; }

/* ---------------------------------------------------------- الحركة بين الصفحات */
.view { animation: view-in .55s var(--ease) both; transform-origin: 50% 0; }
@keyframes view-in {
  from { opacity: 0; transform: perspective(1200px) translateY(14px) rotateX(4deg); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}
.stagger > * { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
::view-transition-old(root) { animation: .22s var(--ease) both vt-out; }
::view-transition-new(root) { animation: .45s var(--ease) both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: scale(.985); } }
@keyframes vt-in { from { opacity: 0; transform: scale(1.012); } }

/* ---------------------------------------------------------- مكونات */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card-h { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-h h2, .card-h h3 { margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 1.05rem; }
.card-h .tools { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font-size: .72rem; font-weight: 600; letter-spacing: .04em; color: var(--ink-3); }

.tilt { transform-style: preserve-3d; transition: transform .5s var(--ease), box-shadow .5s var(--ease); will-change: transform; }
.tilt.is-tilting { transition: transform .08s linear; transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0); }
.tilt .glare {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(400px circle at var(--gx, 50%) var(--gy, 50%), rgba(255, 255, 255, .22), transparent 45%);
  opacity: 0; transition: opacity .3s;
}
.tilt.is-tilting .glare { opacity: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: 13px;
  border: 1px solid var(--hair-2);
  background: var(--card);
  color: var(--ink);
  font-weight: 600; font-size: .9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .2s var(--ease), background .2s, border-color .2s, box-shadow .2s;
  text-decoration: none;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: scale(.97); }
.btn.primary {
  background: var(--ink); color: var(--paper); border-color: transparent;
  box-shadow: 0 10px 24px -12px rgba(27, 21, 19, .6);
}
.btn.primary:hover { background: var(--brand); }
.btn.brand { background: var(--brand); color: #fff; border-color: transparent; box-shadow: 0 12px 26px -14px var(--brand); }
.btn.brand:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hair); }
.btn.ok { background: var(--ok); color: #fff; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { height: 34px; padding: 0 12px; font-size: .82rem; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--paper) transparent var(--paper) transparent;
  animation: spin .8s linear infinite;
}
.btn:not(.primary):not(.brand).loading::after { border-color: var(--ink) transparent var(--ink) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 0; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--hair); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

.seg {
  display: inline-flex; padding: 4px; gap: 2px;
  background: var(--paper-2); border-radius: 14px; border: 1px solid var(--hair);
  position: relative;
}
.seg button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 10px;
  font-size: .84rem; font-weight: 600; color: var(--ink-3); cursor: pointer;
  transition: color .2s, background .25s var(--ease), box-shadow .25s;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }

.month-step { display: inline-flex; align-items: center; gap: 2px; background: var(--card); border: 1px solid var(--hair-2); border-radius: 14px; padding: 3px; }
.month-step span { min-width: 120px; text-align: center; font-family: var(--f-display); font-weight: 500; font-size: .92rem; }
.month-step .icon-btn { width: 34px; height: 34px; border-radius: 10px; }

.field { display: grid; gap: 6px; }
.field label { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--hair-2);
  background: var(--card);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
textarea.input { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--brass); box-shadow: 0 0 0 4px rgba(184, 137, 47, .16); }
.input.num { text-align: center; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .86rem; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 13px;
  font-size: .75rem; font-weight: 600; white-space: nowrap;
  background: var(--hair); color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

.av {
  width: 44px; height: 44px; flex: none;
  border-radius: 14px; overflow: hidden;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), #3a0a18);
  color: #fff; font-family: var(--f-display); font-weight: 600;
}
.av img { width: 100%; height: 100%; object-fit: cover; }
.av.lg { width: 84px; height: 84px; border-radius: 24px; font-size: 1.8rem; }

/* ---------------------------------------------------------- بطاقات الأرقام */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { padding: 18px 20px 20px; overflow: hidden; }
.kpi::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 18px; bottom: 18px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--tone, var(--brand));
}
.kpi .k-top { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: .8rem; font-weight: 600; }
.kpi .k-top svg { width: 18px; height: 18px; color: var(--tone, var(--brand)); }
.kpi .k-val {
  margin-top: 10px;
  font-family: var(--f-display); font-weight: 700;
  font-size: clamp(1.6rem, 2.6vw, 2.15rem);
  letter-spacing: -.02em; line-height: 1.1;
}
.kpi .k-val small { font-size: .5em; font-weight: 500; color: var(--ink-3); margin-inline-start: 4px; }
.kpi .k-sub { margin-top: 6px; font-size: .78rem; color: var(--ink-3); }
.kpi.hero { background: var(--ink); color: var(--paper); border-color: transparent; }
.kpi.hero .k-top, .kpi.hero .k-sub, .kpi.hero .k-val small { color: color-mix(in srgb, var(--paper) 60%, transparent); }
.kpi.hero::after {
  content: ""; position: absolute; width: 260px; height: 260px; inset: auto auto -130px -90px;
  background: repeating-radial-gradient(circle, transparent 0 8px, rgba(216, 176, 106, .14) 8px 9px);
  border-radius: 50%;
}

/* ---------------------------------------------------------- لوحة اليوم */
.day-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; }
.ring-card { display: flex; align-items: center; gap: 22px; overflow: hidden; }
.ring { width: 150px; height: 150px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; stroke-linecap: round; }
.ring .ring-track { stroke: var(--hair); }
.ring .seg-arc { transition: stroke-dasharray 1.2s var(--ease), stroke-dashoffset 1.2s var(--ease); }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .center b { font-family: var(--f-display); font-size: 2.2rem; font-weight: 700; line-height: 1; }
.ring .center small { display: block; color: var(--ink-3); font-size: .74rem; margin-top: 4px; }
.legend { display: grid; gap: 8px; flex: 1; }
.legend button {
  display: flex; align-items: center; gap: 10px;
  border: 0; background: transparent; padding: 6px 8px; border-radius: 10px; cursor: pointer; text-align: start;
}
.legend button:hover, .legend button[aria-pressed="true"] { background: var(--hair); }
.legend i { width: 10px; height: 10px; border-radius: 4px; flex: none; }
.legend span { flex: 1; font-size: .86rem; color: var(--ink-2); }
.legend b { font-family: var(--f-display); font-weight: 600; }

.board { display: grid; gap: 8px; }
.board-axis, .board-row { display: grid; grid-template-columns: minmax(170px, 230px) minmax(0, 1fr) 150px; gap: 16px; align-items: center; }
.board-axis { padding: 0 14px; color: var(--ink-3); font-size: .7rem; }
.board-axis .ticks { position: relative; height: 16px; }
.board-axis .ticks span { position: absolute; transform: translateX(50%); }
.board-row {
  padding: 10px 14px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--hair);
  transition: transform .3s var(--ease), box-shadow .3s, border-color .3s;
  cursor: pointer;
  text-decoration: none; color: inherit;
}
.board-row:hover { transform: translateX(-4px); border-color: var(--hair-2); box-shadow: var(--shadow-sm); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who b { display: block; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--ink-3); font-size: .74rem; }
.track {
  position: relative; height: 14px;
  border-radius: 7px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(100% / 12 - 1px), var(--hair) calc(100% / 12 - 1px) calc(100% / 12)),
    var(--paper-2);
}
.track .late-line { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--brass); border-radius: 1px; opacity: .7; }
.track .now-line { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--brand); border-radius: 1px; }
.track .now-line::after { content: ""; position: absolute; top: -4px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.track .bar {
  position: absolute; top: 2px; bottom: 2px; border-radius: 5px;
  background: var(--ok);
  transform-origin: right center;
  animation: grow .9s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 30ms + .1s);
}
.track .bar.late { background: var(--warn); }
.track .bar.live { background: repeating-linear-gradient(-45deg, var(--ok) 0 6px, color-mix(in srgb, var(--ok) 70%, #fff) 6px 12px); background-size: 17px 17px; animation: grow .9s var(--ease) both, march 1.2s linear infinite; }
.track .bar.live.late { background: repeating-linear-gradient(-45deg, var(--warn) 0 6px, color-mix(in srgb, var(--warn) 70%, #fff) 6px 12px); }
.track .bar.field { background: var(--info); }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes march { to { background-position: 17px 0; } }
.state { display: grid; gap: 2px; justify-items: start; }
.state small { color: var(--ink-3); font-size: .74rem; }

/* ---------------------------------------------------------- الجداول */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--hair); }
table.t { width: 100%; border-collapse: collapse; font-size: .86rem; }
.t th {
  position: sticky; top: 0;
  text-align: start; font-weight: 600; font-size: .74rem; color: var(--ink-3);
  background: var(--card-2); padding: 11px 14px; white-space: nowrap; border-bottom: 1px solid var(--hair);
}
.t td { padding: 12px 14px; border-bottom: 1px solid var(--hair); white-space: nowrap; }
.t tbody tr { transition: background .15s; }
.t tbody tr:hover { background: var(--brand-soft); }
.t tr:last-child td { border-bottom: 0; }
.t .money { font-variant-numeric: tabular-nums; }
.t .neg { color: var(--bad); }
.t .pos { color: var(--ok); }
.t tfoot td { font-weight: 700; background: var(--card-2); border-top: 1px solid var(--hair-2); }
.t .salary-input { width: 110px; height: 36px; text-align: center; border-radius: 10px; }
.t .clickable { cursor: pointer; }

/* ---------------------------------------------------------- الموظفون */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.person { display: grid; gap: 14px; text-decoration: none; color: inherit; cursor: pointer; }
.person .who b { font-size: 1rem; }
.person .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.person .stats div { background: var(--paper-2); border-radius: 12px; padding: 8px 10px; }
.person .stats b { display: block; font-family: var(--f-display); font-size: 1.15rem; font-weight: 600; }
.person .stats small { color: var(--ink-3); font-size: .7rem; }
.meter { height: 6px; border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brass), var(--brand)); transform-origin: right; animation: grow-r 1.1s var(--ease) both; }
@keyframes grow-r { from { transform: scaleX(0); } }

/* ---------------------------------------------------------- ملف الموظف */
.profile { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 18px; align-items: start; }
.profile-head { display: flex; align-items: center; gap: 18px; }
.profile-head h2 { margin: 0; font-family: var(--f-display); font-size: 1.5rem; font-weight: 700; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: .68rem; color: var(--ink-3); text-align: center; padding-bottom: 2px; }
.cal .d {
  aspect-ratio: 1 / 1.05; border-radius: 12px; padding: 6px;
  background: var(--paper-2); display: flex; flex-direction: column; justify-content: space-between;
  font-size: .7rem; position: relative; transition: transform .25s var(--ease-spring);
}
.cal .d:hover { transform: translateY(-3px) scale(1.04); z-index: 1; }
.cal .d b { font-family: var(--f-display); font-weight: 600; font-size: .9rem; }
.cal .d.ok { background: var(--ok-soft); color: var(--ok); }
.cal .d.late { background: var(--warn-soft); color: var(--warn); }
.cal .d.absent { background: var(--bad-soft); color: var(--bad); }
.cal .d.field { background: var(--info-soft); color: var(--info); }
.cal .d.off { background: transparent; border: 1px dashed var(--hair-2); color: var(--ink-3); }
.cal .d.future { opacity: .45; }
.cal .d.today { box-shadow: 0 0 0 2px var(--brass); }
.cal .d.empty { visibility: hidden; }
.lines { display: grid; gap: 0; }
.lines > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--hair-2); font-size: .9rem; }
.lines > div:last-child { border-bottom: 0; }
.lines .total { font-family: var(--f-display); font-weight: 700; font-size: 1.15rem; border-top: 2px solid var(--ink); border-bottom: 0; margin-top: 6px; padding-top: 12px; }

/* ---------------------------------------------------------- الميداني */
.req { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; }
.req + .req { margin-top: 10px; }
.req .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-3); font-size: .8rem; margin-top: 4px; }
.req .actions { display: flex; gap: 8px; }
.map-dot { display: inline-flex; align-items: center; gap: 4px; }

.start-card { display: grid; justify-items: center; text-align: center; gap: 14px; padding: 34px 22px; overflow: hidden; }
.start-btn {
  width: 168px; height: 168px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--brand-2), var(--brand) 55%, #4a0a1d);
  color: #fff; font-family: var(--f-display); font-size: 1.15rem; font-weight: 600;
  box-shadow: 0 30px 60px -20px var(--brand), inset 0 -10px 30px rgba(0, 0, 0, .25), inset 0 6px 20px rgba(255, 255, 255, .2);
  position: relative;
  transition: transform .3s var(--ease-spring);
}
.start-btn:active { transform: scale(.94); }
.start-btn::before, .start-btn::after {
  content: ""; position: absolute; inset: -14px; border-radius: 50%;
  border: 1px solid var(--brand); opacity: .4; animation: ripple 2.6s var(--ease) infinite;
}
.start-btn::after { animation-delay: 1.3s; }
@keyframes ripple { from { transform: scale(.9); opacity: .5; } to { transform: scale(1.35); opacity: 0; } }
.start-btn.done { background: radial-gradient(circle at 35% 30%, #6fc4aa, var(--ok) 55%, #163a30); box-shadow: 0 30px 60px -20px var(--ok); }
.start-btn.done::before, .start-btn.done::after { border-color: var(--ok); }

/* ---------------------------------------------------------- الدخول */
.login {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 480px);
  background: var(--rail);
}
.login-art { position: relative; overflow: hidden; }
.login-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.login-art .caption {
  position: absolute; inset-inline-start: clamp(24px, 5vw, 64px); bottom: clamp(24px, 6vh, 64px);
  color: var(--rail-ink); max-width: 520px; pointer-events: none;
}
.login-art .caption h2 { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: clamp(2rem, 4.6vw, 3.6rem); line-height: 1.05; letter-spacing: -.03em; }
.login-art .caption h2 em { font-style: normal; color: var(--brass-2); }
.login-art .caption p { margin: 14px 0 0; color: var(--rail-ink-2); font-size: 1rem; max-width: 420px; }
.login-panel {
  background: var(--paper);
  display: flex; flex-direction: column; justify-content: center;
  padding: clamp(28px, 5vw, 56px);
  border-radius: 34px 0 0 34px;
  position: relative;
  box-shadow: -30px 0 80px rgba(0, 0, 0, .35);
}
[dir="rtl"] .login-panel { border-radius: 0 34px 34px 0; box-shadow: 30px 0 80px rgba(0, 0, 0, .35); }
.login-panel .brand { color: var(--ink); padding: 0 0 36px; }
.login-panel .brand small { color: var(--ink-3); }
.login-panel h1 { margin: 0 0 6px; font-family: var(--f-display); font-weight: 700; font-size: 1.7rem; letter-spacing: -.02em; }
.login-panel form { display: grid; gap: 16px; margin-top: 26px; }
.login-panel .err { color: var(--bad); background: var(--bad-soft); padding: 10px 14px; border-radius: 12px; font-size: .86rem; }
.login-panel .foot { margin-top: 30px; color: var(--ink-3); font-size: .76rem; }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; inset-inline-end: 4px; top: 4px; }

/* ---------------------------------------------------------- نوافذ وإشعارات */
dialog.modal {
  border: 0; padding: 0; border-radius: 26px;
  width: min(560px, calc(100vw - 24px));
  background: var(--card); color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(15, 8, 6, .45); backdrop-filter: blur(6px); }
dialog.modal[open] { animation: pop .4s var(--ease-spring) both; }
@keyframes pop { from { opacity: 0; transform: perspective(900px) translateY(20px) rotateX(8deg) scale(.96); } }
.modal-b { padding: 24px; display: grid; gap: 16px; }
.modal-b h3 { margin: 0; font-family: var(--f-display); font-size: 1.2rem; }
.modal-f { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--hair); }

#toasts { position: fixed; z-index: 100; inset-inline-start: 50%; transform: translateX(50%); bottom: 24px; display: grid; gap: 8px; pointer-events: none; }
[dir="ltr"] #toasts { transform: translateX(-50%); }
.toast {
  pointer-events: auto;
  background: var(--ink); color: var(--paper);
  padding: 12px 18px; border-radius: 14px; font-size: .88rem; font-weight: 500;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px;
  animation: toast-in .45s var(--ease-spring) both;
}
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { animation: toast-out .3s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px) scale(.9); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px) scale(.95); } }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); display: grid; justify-items: center; gap: 10px; }
.empty .rings { width: 90px; height: 90px; border-radius: 50%; background: repeating-radial-gradient(circle, transparent 0 7px, var(--hair-2) 7px 8px); }
.skel { border-radius: 14px; background: linear-gradient(90deg, var(--paper-2) 0%, var(--card) 50%, var(--paper-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; font-size: .86rem; background: var(--warn-soft); color: var(--ink); }
.notice svg { width: 20px; height: 20px; color: var(--warn); flex: none; margin-top: 2px; }
.notice.info { background: var(--info-soft); }
.notice.info svg { color: var(--info); }

/* ---------------------------------------------------------- الجوال */
.tabbar { display: none; }
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
  .topbar .mobile-brand { display: flex; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; z-index: 40; inset-inline: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--rail) 92%, transparent);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-radius: 24px; padding: 6px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, .5);
  }
  .tabbar a {
    display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border-radius: 18px;
    color: var(--rail-ink-2); text-decoration: none; font-size: .66rem; font-weight: 600; position: relative;
  }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--rail-ink); background: rgba(255, 255, 255, .08); }
  .tabbar .count { position: absolute; top: 4px; inset-inline-end: calc(50% - 22px); min-width: 16px; height: 16px; border-radius: 8px; background: var(--brand-2); color: #fff; font-size: .6rem; display: grid; place-items: center; padding: 0 4px; }
  .day-hero, .profile { grid-template-columns: minmax(0, 1fr); }
  .board-axis { display: none; }
  .board-row { grid-template-columns: minmax(0, 1fr) auto; }
  .board-row .track { grid-column: 1 / -1; grid-row: 2; }
  .login { grid-template-columns: minmax(0, 1fr); grid-template-rows: 38vh auto; }
  .login-art .caption h2 { font-size: 1.9rem; }
  .login-art .caption p { display: none; }
  .login-panel, [dir="rtl"] .login-panel { border-radius: 30px 30px 0 0; margin-top: -30px; box-shadow: 0 -20px 60px rgba(0, 0, 0, .4); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .req { grid-template-columns: auto minmax(0, 1fr); }
  .req .actions { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px 14px 16px; }
  .ring-card { flex-direction: column; align-items: stretch; }
  .ring { margin: 0 auto; }
  .topbar .tools { width: 100%; margin: 0; }
  .card { padding: 16px; border-radius: 18px; }
  .month-step span { min-width: 96px; }
}
.mobile-brand { display: none; align-items: center; gap: 10px; }
.mobile-brand img { width: 32px; height: 32px; border-radius: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  .rail, .tabbar, .topbar .tools, .btn, #toasts { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
  body::before { display: none; }
}

.lines .neg { color: var(--bad); }
.lines .pos { color: var(--ok); }
.who small { display: block; }
.req .meta span { display: inline-flex; align-items: center; gap: 4px; }
.login-art::after { content: ""; position: absolute; inset: 45% 0 0 0; background: linear-gradient(to top, rgba(14, 10, 9, .92), transparent); pointer-events: none; }
.login-art .caption { z-index: 1; }
.me-chip { flex-wrap: wrap; }
.me-chip > div:nth-child(2) { flex: 1; min-width: 0; }
.me-chip > div:nth-child(2) b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-chip .chip-actions { width: 100%; display: flex; justify-content: space-between; border-top: 1px solid rgba(255, 255, 255, .06); padding-top: 6px; }
.me-chip .chip-actions .icon-btn { margin: 0; width: 34px; height: 34px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1240px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpis.k3 .k-sub { display: none; } }
.view { display: grid; gap: 22px; align-content: start; min-width: 0; }
.content > *, .view > * { min-width: 0; }
