/* لوحة تحكم شؤون الموظفين — نفس هوية التصميم المعتمد */
:root {
  --brand: #6E1423; --brand-deep: #4A0D18; --gold: #F4B400;
  --ground: #FBF7F2; --card: #FFFFFF; --line: #F0E6E2; --line-soft: #F7F0ED; --field: #E6D9D4;
  --ink: #1E1416; --ink-2: #4A3F41; --muted: #6B5E60;
  --ok-bg: #E5F4EC; --ok: #1F6B45; --warn-bg: #FFF3D1; --warn: #7A5300;
  --bad-bg: #FBEFF0; --bad: #6E1423; --info-bg: #EAF0F8; --info: #1E3A5F;
  --radius: 24px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Readex Pro', system-ui, sans-serif; background: var(--ground); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-deep); }
h1 { margin: 0; font-size: 28px; font-weight: 700; }
h2 { margin: 0; font-size: 18px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* الهيكل */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 240px; max-width: 100%; background: var(--brand-deep); color: #fff; padding: 24px 16px; display: flex; flex-direction: column; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.logo { width: 44px; height: 44px; border-radius: 14px; background: var(--gold); color: var(--brand-deep); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; overflow: hidden; flex: none; }
.logo img { width: 100%; height: 100%; object-fit: contain; }
.brand b { display: block; font-size: 15px; color: #fff; }
.brand span span { font-size: 12px; color: #E8C9CE; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { height: 44px; padding: 0 14px; border-radius: 13px; color: #F3D9DD; display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.on { background: var(--gold); color: var(--brand-deep); font-weight: 600; }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--gold); color: var(--brand-deep); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.nav a.on .badge { background: var(--brand-deep); color: var(--gold); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: #E8C9CE; padding: 0 8px; }
.side-foot button, .side-foot a { color: #fff; background: rgba(255,255,255,.08); border: 0; border-radius: 12px; height: 40px; font: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px clamp(16px, 3vw, 40px); display: flex; flex-direction: column; gap: 22px; }

/* عناصر مشتركة */
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.head .sub { font-size: 14px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; }
.card > h2 + * { margin-top: 14px; }
.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.kpis { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.kpi .v { font-size: 38px; font-weight: 700; line-height: 1; }
.kpi.hero { background: var(--brand); color: #fff; border: 0; }
.kpi.hero .muted { color: #F3D9DD; }
.bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.18); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--gold); border-radius: 4px; }

.btn { height: 44px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--field); background: #fff; color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-deep); color: #fff; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.sm { height: 36px; padding: 0 12px; border-radius: 11px; font-size: 13px; }
.btn.danger { color: var(--bad); }

.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; background: var(--line-soft); color: var(--muted); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.t th { text-align: start; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
.who { display: flex; align-items: center; gap: 10px; }
.av { width: 34px; height: 34px; border-radius: 11px; background: var(--bad-bg); color: var(--brand); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.ltr { direction: ltr; unicode-bidi: embed; }

/* النماذج */
.form { display: grid; gap: 14px 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.form .full { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
label.f small { font-weight: 400; color: var(--muted); }
.in, select.in, textarea.in { height: 46px; border-radius: 13px; border: 1px solid var(--field); background: #fff; padding: 0 14px; font: inherit; font-size: 14px; color: var(--ink); width: 100%; }
textarea.in { height: auto; padding: 12px 14px; resize: vertical; }
.in:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.check { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.err { color: var(--bad); font-size: 12.5px; }

.flash { border-radius: 16px; padding: 12px 16px; font-size: 14px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.bad { background: var(--bad-bg); color: var(--bad); }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid #EDE3DF; }
.tabs a { height: 44px; padding: 0 16px; display: flex; align-items: center; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--brand); font-weight: 600; border-color: var(--brand); }

.seg { display: inline-flex; background: #F2EAE6; border-radius: 14px; padding: 4px; gap: 4px; }
.seg a, .seg button { height: 38px; padding: 0 14px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; display: inline-flex; align-items: center; cursor: pointer; }
.seg .on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 2px 6px rgba(74,13,24,.08); }

.pager { display: flex; gap: 6px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 36px; height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--field); display: inline-flex; align-items: center; justify-content: center; background: #fff; font-size: 13px; }
.pager .on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* جدول الورديات */
.week td { padding: 4px 3px; }
.week select { height: 44px; border-radius: 12px; border: 2px solid transparent; font: inherit; font-size: 12.5px; padding: 0 6px; width: 100%; min-width: 92px; cursor: pointer; }
.week select.s-off { background: #F2EAE6; color: var(--muted); }
.week select.s-leave { background: var(--info-bg); color: var(--info); }
.week select.moved { border-color: var(--brand); }

/* البطاقة */
.idcard { width: 240px; height: 360px; border-radius: 20px; background: #fff; box-shadow: 0 18px 40px rgba(74,13,24,.18); overflow: hidden; display: flex; flex-direction: column; align-items: center; position: relative; border: 1px solid var(--line); text-align: center; }
.idcard .top { width: 100%; height: 60px; display: flex; align-items: center; justify-content: center; gap: 8px; border-bottom: 4px solid var(--brand); padding: 0 12px; }
.idcard .top .logo { width: 32px; height: 32px; border-radius: 10px; font-size: 9px; }
.idcard .top b { font-size: 11px; color: var(--brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.idcard .photo { margin-top: 14px; width: 92px; height: 112px; border-radius: 14px; background: var(--brand); color: var(--gold); display: flex; align-items: center; justify-content: center; font-size: 36px; font-weight: 700; overflow: hidden; }
.idcard .photo img { width: 100%; height: 100%; object-fit: cover; }
.idcard .nm { margin-top: 12px; font-size: 16px; font-weight: 700; padding: 0 10px; }
.idcard .en { font-size: 11.5px; color: var(--ink-2); direction: ltr; }
.idcard .jt { margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--brand); }
.idcard .br { font-size: 11px; color: var(--muted); }
.idcard .foot { position: absolute; bottom: 0; left: 0; right: 0; height: 42px; background: var(--brand); display: flex; align-items: center; justify-content: space-between; padding: 0 14px; }
.idcard .foot b { font-size: 10.5px; color: var(--gold); letter-spacing: .6px; direction: ltr; }
.idcard .foot img { width: 30px; height: 30px; background: #fff; border-radius: 5px; padding: 2px; }

/* صفحة الدخول: خلفية فاتحة بنقشة الهوية الهندسية */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background-color: var(--ground);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 100 100'%3E%3Cg fill='none' stroke='%236E1423' stroke-opacity='0.07' stroke-width='1.2'%3E%3Cpolygon points='50,4 61,39 96,50 61,61 50,96 39,61 4,50 39,39'/%3E%3Ccircle cx='50' cy='50' r='14'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 120px 120px; }
.auth .box { width: min(100%, 420px); background: #fff; border-radius: 28px; padding: 32px; display: flex; flex-direction: column; gap: 18px;
  border-top: 6px solid var(--brand); box-shadow: 0 24px 60px rgba(74,13,24,.14); }
.auth .brand b { color: var(--brand); }
.auth .brand span span { color: var(--muted); }

#map { height: 360px; border-radius: 18px; border: 1px solid var(--line); }

@media print {
  .side, .no-print { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
}

/* ===== بوابة الموظف: للجوال أولاً ===== */
body.portal { min-height: 100vh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.p-top { background: var(--brand-deep); color: #fff; padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top)); display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 5; }
.p-top .brand { padding: 0; min-width: 0; }
.p-top .brand > span:last-child { min-width: 0; }
.p-top .brand span span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-top-act { display: flex; gap: 6px; flex: none; }
.p-pill { height: 36px; padding: 0 12px; border-radius: 12px; background: rgba(255,255,255,.1); color: #fff; display: inline-flex; align-items: center; font-size: 13px; }
.p-pill:hover { color: var(--gold); }
.p-main { width: min(100%, 640px); margin: 0 auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 16px; }
.p-main h1 { font-size: 22px; }
.p-nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 24px rgba(74,13,24,.06); }
.p-nav a { flex: 1 1 0; max-width: 128px; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: 11.5px; border-radius: 14px; }
.p-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.p-nav a.on { color: var(--brand); font-weight: 600; }
.p-nav a.mid svg { width: 52px; height: 52px; padding: 13px; margin-top: -26px; border-radius: 18px; background: var(--brand); color: var(--gold); box-shadow: 0 8px 20px rgba(110,20,35,.35); border: 4px solid #fff; box-sizing: content-box; }
.p-nav a.mid.on { color: var(--brand); }

.p-hero { background: var(--brand); color: #fff; border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.p-hero .muted { color: #F3D9DD; }
.p-hero .time { font-size: 40px; font-weight: 700; line-height: 1; direction: ltr; }
.p-hero .btn.gold { background: var(--gold); border-color: var(--gold); color: var(--brand-deep); font-weight: 700; height: 52px; font-size: 16px; }
.p-hero .btn.gold:hover { background: #FFC933; color: var(--brand-deep); }
.p-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.p-stat { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 12px 6px; text-align: center; }
.p-stat b { display: block; font-size: 22px; line-height: 1.2; }
.p-stat span { font-size: 11.5px; color: var(--muted); }
.p-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.p-tiles a { background: #fff; border: 1px solid var(--line); border-radius: 18px; min-height: 84px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--ink); font-size: 12.5px; text-align: center; }
.p-tiles a:hover { border-color: var(--brand); color: var(--brand); }
.p-tiles i { font-style: normal; width: 36px; height: 36px; border-radius: 12px; background: var(--bad-bg); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700; }
.p-list { display: flex; flex-direction: column; }
.p-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line-soft); min-width: 0; }
.p-row:last-child { border-bottom: 0; }
.p-row > div { min-width: 0; }
.p-row .t { font-weight: 600; }
.p-day { display: flex; align-items: center; gap: 12px; }
.p-day .d { width: 48px; height: 52px; border-radius: 14px; background: var(--line-soft); display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; line-height: 1.15; }
.p-day .d b { font-size: 18px; }
.p-day .d span { font-size: 10.5px; color: var(--muted); }
.p-day.today .d { background: var(--brand); color: #fff; }
.p-day.today .d span { color: #F3D9DD; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-inline-end: 6px; }

/* شاشة التحضير */
.cam { position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 62vh; border-radius: var(--radius); overflow: hidden; background: #1E1416; }
.cam video, .cam img { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam .ring { position: absolute; inset: 12% 18% 20%; border: 3px dashed rgba(244,180,0,.85); border-radius: 50%; pointer-events: none; }
.cam .hint { position: absolute; bottom: 12px; left: 12px; right: 12px; text-align: center; color: #fff; font-size: 13px; background: rgba(30,20,22,.55); border-radius: 12px; padding: 8px; }
.steps { display: flex; flex-direction: column; gap: 8px; }
.step { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.step i { font-style: normal; width: 26px; height: 26px; border-radius: 9px; background: var(--line-soft); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.step.ok i { background: var(--ok-bg); color: var(--ok); }
.step.bad i { background: var(--bad-bg); color: var(--bad); }
.step.run i { background: var(--warn-bg); color: var(--warn); }
.btn.block { width: 100%; height: 54px; font-size: 16px; border-radius: 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.result { border-radius: var(--radius); padding: 22px; text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.result.ok { background: var(--ok-bg); color: var(--ok); }
.result.bad { background: var(--bad-bg); color: var(--bad); }
.result b { font-size: 34px; direction: ltr; }

.fieldset[hidden] { display: none; }
@media (min-width: 700px) { .p-main { padding-top: 26px; } .p-main h1 { font-size: 26px; } }
@media print {
  .p-top, .p-nav { display: none !important; }
  body.portal { padding: 0; }
}
