/* بوابة الموظف — نسخة الويب للموبايل (آيفون وأي موبايل)
   نفس ألوان تطبيق الأندرويد: أزرق #1B6EC2، كحلي #0E1B3D، كهرماني #F2A541 */

:root {
    --navy: #0E1B3D;
    --navy-2: #172a57;
    --blue: #1B6EC2;
    --blue-ink: #155ba3;
    --amber: #F2A541;
    --bg: #EEF2F7;
    --surface: #FFFFFF;
    --ink: #16202E;
    --muted: #5B6577;
    --line: #DCE2EB;
    --soft: #E4ECF7;
    --green: #1F8A5B;
    --red: #C93C3C;
    --orange: #B4570B;
    --gray: #6A6F7A;
    --on-blue: #FFFFFF;
    --radius: 14px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --tabbar-h: 58px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --navy: #0A1430;
        --navy-2: #13224a;
        --blue: #6FA9F0;
        --blue-ink: #8DBBF4;
        --bg: #0B1220;
        --surface: #141C2F;
        --ink: #E4E8EF;
        --muted: #9AA4B5;
        --line: #26324A;
        --soft: #1C2943;
        --green: #4CC08A;
        --red: #F07C7C;
        --orange: #F0A35B;
        --gray: #9AA0AA;
        --on-blue: #06182F;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "IBM Plex Sans Arabic", -apple-system, "SF Arabic", "Segoe UI", Tahoma, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.num, time, .time { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

#view {
    min-height: 100dvh;
    padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
}
body.no-tabs #view { padding-bottom: calc(var(--safe-bottom) + 24px); }

/* ---------- الشريط اللي فوق ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 6px;
    padding: calc(var(--safe-top) + 8px) 12px 8px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; text-align: center; }
.topbar .slot { min-width: 64px; display: flex; }
.topbar .slot.end { justify-content: flex-end; }
.icon-btn {
    border: 0; background: none; padding: 8px; border-radius: 10px; cursor: pointer;
    color: var(--blue); font-weight: 500; display: inline-flex; align-items: center; gap: 4px;
}
.icon-btn:active { background: var(--soft); }
.icon-btn svg { width: 22px; height: 22px; }
[dir="ltr"] .flip { transform: scaleX(-1); }

.page { padding: 4px 16px 0; max-width: 640px; margin: 0 auto; }
.page-title { font-size: 28px; font-weight: 700; margin: 6px 4px 12px; letter-spacing: -0.01em; }

/* ---------- الهيدر الكحلي (الرئيسية والحضور) ---------- */
.hero {
    background: var(--navy);
    background-image: radial-gradient(120% 90% at 85% 0%, var(--navy-2) 0%, var(--navy) 60%);
    color: #fff;
    padding: calc(var(--safe-top) + 14px) 20px 26px;
    border-radius: 0 0 28px 28px;
}
.hero-top { display: flex; align-items: center; gap: 10px; }
.hero-top .who { flex: 1; min-width: 0; }
.hero-top .hello { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-top .company { font-size: 13px; opacity: .7; }
.bell {
    position: relative; border: 0; background: rgba(255,255,255,.1); color: #fff;
    width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
}
.bell svg { width: 22px; height: 22px; }
.bell .dot {
    position: absolute; top: 2px; inset-inline-end: 0; min-width: 19px; height: 19px; padding: 0 5px;
    border-radius: 10px; background: var(--amber); color: #2b1700; font-size: 11px; font-weight: 700;
    display: grid; place-items: center; line-height: 1;
}
.clock { margin-top: 22px; text-align: center; }
.clock .now { font-size: 64px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; direction: ltr; }
.clock .now small { font-size: 22px; font-weight: 500; opacity: .6; margin-inline-start: 4px; }
.clock .date { margin-top: 8px; font-size: 14px; opacity: .75; }
.stamps { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
.stamp {
    flex: 1; max-width: 150px; text-align: center; padding: 10px 8px; border-radius: 14px;
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
}
.stamp .k { font-size: 12px; opacity: .7; }
.stamp .v { font-size: 22px; font-weight: 600; direction: ltr; }
.stamp.done { border-color: color-mix(in srgb, var(--amber) 70%, transparent); }
.stamp.done .v { color: var(--amber); }
.punch-note { text-align: center; font-size: 13px; margin-top: 12px; opacity: .8; }

/* زرار البصمة: الحاجة الوحيدة اللي بتلفت النظر في الصفحة */
.punch {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; margin-top: 18px; height: 60px; border: 0; border-radius: 30px; cursor: pointer;
    background: var(--amber); color: #2b1700; font-size: 18px; font-weight: 700;
    box-shadow: 0 10px 28px -10px rgba(242,165,65,.75);
    transition: transform .12s ease;
}
.punch:active { transform: scale(.98); }
.punch.out { background: #fff; color: var(--navy); box-shadow: 0 10px 28px -12px rgba(255,255,255,.5); }
.punch[disabled] { opacity: .65; cursor: default; }
.punch svg { width: 24px; height: 24px; }
.hero .chip-status { display: inline-block; margin-top: 10px; }

/* ---------- القوايم المجمّعة (زي إعدادات الآيفون) ---------- */
.section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 6px 8px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--muted); }
.section-head a, .section-head button { font-size: 14px; }
.group { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.row {
    display: flex; align-items: center; gap: 12px; padding: 13px 16px; position: relative;
    text-decoration: none; color: inherit; background: none; border: 0; width: 100%; text-align: start;
}
.row + .row::before {
    content: ""; position: absolute; top: 0; inset-inline-start: 16px; inset-inline-end: 0; height: 1px; background: var(--line);
}
a.row, button.row { cursor: pointer; }
a.row:active, button.row:active { background: var(--soft); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { font-size: 13px; color: var(--muted); }
.row .end { text-align: end; flex-shrink: 0; }
.row .chev { color: var(--muted); width: 16px; height: 16px; flex-shrink: 0; }
[dir="ltr"] .row .chev { transform: scaleX(-1); }
.row .ico {
    width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0;
    background: var(--soft); color: var(--blue);
}
.row .ico svg { width: 19px; height: 19px; }
.row .count {
    min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--amber); color: #2b1700;
    font-size: 13px; font-weight: 700; display: grid; place-items: center;
}
.big-num { font-size: 22px; font-weight: 700; line-height: 1.1; }

.meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 13px; color: var(--muted); }
.line { font-size: 14px; margin-top: 4px; }
.warn-text { color: var(--red); }
.accent-text { color: var(--blue); }

/* ---------- عناصر (طلب، زيارة) ---------- */
.item { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }
.item + .item { margin-top: 10px; }
.item-head { display: flex; align-items: flex-start; gap: 10px; }
.item-head .main { flex: 1; min-width: 0; }
.item-head .title { font-weight: 600; font-size: 16px; }
.item.live { box-shadow: inset 4px 0 0 var(--amber); }
[dir="rtl"] .item.live { box-shadow: inset -4px 0 0 var(--amber); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.chip {
    display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
    white-space: nowrap; background: color-mix(in srgb, var(--c, var(--gray)) 14%, transparent); color: var(--c, var(--gray));
}
.c-green { --c: var(--green); } .c-red { --c: var(--red); } .c-orange { --c: var(--orange); }
.c-blue { --c: var(--blue); } .c-gray { --c: var(--gray); }
.hero .chip { background: rgba(255,255,255,.12); color: #fff; }

.notice {
    border-radius: 12px; padding: 12px 14px; font-size: 14px; background: var(--soft); color: var(--ink);
}
.notice.warn { background: color-mix(in srgb, var(--orange) 13%, var(--surface)); }
.notice.err { background: color-mix(in srgb, var(--red) 12%, var(--surface)); }
.notice.ok { background: color-mix(in srgb, var(--green) 12%, var(--surface)); }
.notice b { display: block; margin-bottom: 2px; }
.notice ul { margin: 4px 0 0; padding-inline-start: 18px; }

/* ---------- الأزرار ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
    border-radius: 12px; border: 0; cursor: pointer; font-weight: 600; text-decoration: none;
    background: var(--blue); color: var(--on-blue);
}
.btn:active { filter: brightness(.94); }
.btn svg { width: 20px; height: 20px; flex-shrink: 0; }
.btn.block { width: 100%; min-height: 50px; font-size: 17px; }
.btn.soft { background: var(--soft); color: var(--blue); }
.btn.ghost { background: none; color: var(--blue); padding: 0 10px; }
.btn.danger { background: none; color: var(--red); padding: 0 10px; }
.btn.danger-fill { background: var(--red); color: #fff; }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .5; cursor: default; }
.spinner {
    width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent;
    animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- النماذج ---------- */
.form { background: var(--surface); border-radius: var(--radius); padding: 4px 16px; }
.field { padding: 10px 0; }
.field + .field { border-top: 1px solid var(--line); }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field label .opt { opacity: .75; }
.field input, .field select, .field textarea {
    width: 100%; border: 0; background: none; padding: 4px 0; font-size: 17px; outline: none; min-height: 32px;
    -webkit-appearance: none; appearance: none;
}
.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8799' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E");
    background-position: left 0 center; background-size: 18px 18px; background-repeat: no-repeat;
    padding-inline-end: 24px;
}
[dir="ltr"] .field select { background-position: right 0 center; }
.field textarea { resize: none; min-height: 64px; }
.field input[type="date"] { min-height: 34px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; min-width: 0; border-top: 0 !important; }
.field-row + .field, .field + .field-row { border-top: 1px solid var(--line); }
.form + .form, .form + .notice, .notice + .form { margin-top: 14px; }
.pw { display: flex; align-items: center; }
.pw button { border: 0; background: none; color: var(--blue); font-size: 14px; cursor: pointer; padding: 4px; white-space: nowrap; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
.field:focus-within label { color: var(--blue); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.segmented {
    display: flex; background: var(--soft); border-radius: 11px; padding: 3px; gap: 3px; margin: 4px 0 14px;
}
.segmented button {
    flex: 1; border: 0; background: none; padding: 7px 4px; border-radius: 9px; font-size: 14px; font-weight: 600;
    color: var(--muted); cursor: pointer;
}
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.search {
    display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 12px; padding: 0 12px; flex: 1;
}
.search svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.search input { border: 0; background: none; outline: none; padding: 11px 0; width: 100%; font-size: 16px; }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 18px 4px 10px; }
.month-nav .label { font-weight: 600; }

.empty { text-align: center; color: var(--muted); padding: 34px 16px; font-size: 15px; }
.empty .btn { margin-top: 12px; }
.loading { display: grid; place-items: center; padding: 50px 0; color: var(--blue); }
.loading .spinner { width: 28px; height: 28px; border-width: 3px; }
.error-box { text-align: center; padding: 34px 16px; }
.error-box p { color: var(--muted); margin: 0 0 12px; }

/* ---------- قسيمة المرتب ---------- */
.slip-net { text-align: center; padding: 22px 16px; background: var(--surface); border-radius: var(--radius); }
.slip-net .k { color: var(--muted); font-size: 14px; }
.slip-net .v { font-size: 36px; font-weight: 700; direction: ltr; }
.slip-net .t { font-weight: 600; margin-bottom: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--surface); border-radius: 12px; text-align: center; padding: 10px 6px; }
.stat .v { font-size: 20px; font-weight: 700; }
.stat .k { font-size: 12px; color: var(--muted); }
.money { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }

/* ---------- البار اللي تحت ---------- */
#tabbar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    display: flex; padding-bottom: var(--safe-bottom);
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
    border-top: 1px solid var(--line);
}
#tabbar a {
    flex: 1; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500; position: relative;
}
#tabbar a svg { width: 24px; height: 24px; }
#tabbar a.on { color: var(--blue); }
#tabbar a .badge {
    position: absolute; top: 6px; inset-inline-start: calc(50% + 4px); min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center;
}

/* ---------- الرسايل والشيت ---------- */
#toast {
    position: fixed; left: 12px; right: 12px; top: calc(var(--safe-top) + 10px); z-index: 60;
    display: flex; flex-direction: column; gap: 8px; pointer-events: none; align-items: center;
}
.toast {
    max-width: 520px; width: 100%; background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 16px;
    font-size: 15px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.35); pointer-events: auto;
    animation: drop .22s ease-out; white-space: pre-line;
}
.toast.err { background: var(--red); color: #fff; }
.toast.ok { background: var(--green); color: #fff; }
.toast.warn { background: var(--orange); color: #fff; }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }

#sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-back { position: absolute; inset: 0; background: rgba(5,10,25,.45); animation: fade .2s ease-out; }
.sheet-card {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow: auto;
    background: var(--bg); border-radius: 20px 20px 0 0; padding: 10px 16px calc(var(--safe-bottom) + 16px);
    animation: rise .25s cubic-bezier(.2,.8,.2,1);
}
.sheet-card::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet-card h3 { margin: 0 0 6px; font-size: 18px; }
.sheet-card p { margin: 0 0 12px; color: var(--muted); }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet-actions .btn { flex: 1; min-height: 48px; }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- الدخول ---------- */
.login {
    min-height: 100dvh; display: flex; flex-direction: column;
    padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 20px);
    background: var(--navy);
    background-image: radial-gradient(120% 60% at 85% 0%, var(--navy-2) 0%, var(--navy) 65%);
}
.login .brand { color: #fff; margin: 9vh 4px 28px; }
.login .mark {
    width: 64px; height: 64px; border-radius: 18px; background: var(--blue); display: grid; place-items: center; margin-bottom: 18px;
}
.login .mark svg { width: 46px; height: 46px; }
.login h1 { margin: 0; font-size: 30px; font-weight: 700; }
.login .brand p { margin: 4px 0 0; opacity: .7; }
.login .form { padding: 4px 16px; }
.login .btn.block { margin-top: 16px; background: var(--amber); color: #2b1700; }
.login .foot { margin-top: auto; padding-top: 24px; display: flex; justify-content: center; }
.login .foot button { color: #fff; opacity: .8; }

.install {
    display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border-radius: var(--radius);
    padding: 14px 16px; margin-top: 16px; border: 1px solid color-mix(in srgb, var(--blue) 30%, transparent);
}
.install .main { flex: 1; font-size: 14px; }
.install b { display: block; font-size: 15px; margin-bottom: 2px; }
.install .share { display: inline-block; vertical-align: -3px; width: 17px; height: 17px; color: var(--blue); }
.install .x { border: 0; background: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 4px; line-height: 1; }

.steps { margin: 6px 0 0; padding-inline-start: 20px; font-size: 15px; }
.steps li { margin: 6px 0; }

.profile-head { text-align: center; padding: 10px 0 4px; }
.avatar {
    width: 74px; height: 74px; border-radius: 50%; margin: 0 auto 10px; background: var(--navy); color: #fff;
    display: grid; place-items: center; font-size: 28px; font-weight: 700;
}
.profile-head .name { font-size: 20px; font-weight: 700; }
.profile-head .job { color: var(--muted); }

.att { cursor: pointer; }
.att .times { direction: ltr; font-variant-numeric: tabular-nums; font-weight: 600; }

.notif.unread .title::before {
    content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--blue);
    margin-inline-end: 8px; vertical-align: 2px;
}
.notif .body { white-space: pre-line; font-size: 14px; margin-top: 4px; }
.attach { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; margin-top: 8px; margin-inline-end: 12px; }

.pick-list { max-height: 46dvh; overflow: auto; margin-top: 10px; }

@media (min-width: 700px) {
    .hero { border-radius: 0 0 32px 32px; }
    .hero > * { max-width: 600px; margin-inline: auto; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
    #tabbar, .topbar, #toast { display: none !important; }
    body { background: #fff; }
}

/* ===== تذاكر الموارد البشرية ===== */
.tk-thread { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.tk-msg { display: flex; }
.tk-msg.me { justify-content: flex-start; }
.tk-msg.them { justify-content: flex-end; }
.tk-bubble { max-width: 88%; background: var(--surface); border-radius: 16px; padding: 10px 12px; }
.tk-msg.them .tk-bubble { background: color-mix(in srgb, var(--blue) 12%, var(--surface)); }
.tk-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.tk-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.tk-evt { text-align: center; font-size: 12px; color: var(--muted); }
.tk-files { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.tk-file { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--blue); text-decoration: none; }
.tk-file svg { width: 16px; height: 16px; flex: none; }
.tk-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-file small { color: var(--muted); flex: none; }
.tk-stars { display: flex; gap: 6px; margin: 8px 0; }
.tk-stars button { background: none; border: 0; padding: 0; color: var(--line, #ccc); }
.tk-stars button svg { width: 32px; height: 32px; }
.tk-stars button.on { color: #f5a524; }
.tk-stars button.on svg { fill: currentColor; }
.tk-faq summary { cursor: pointer; }
