/* تصميم لوحة الإدارة ولوحة المالك والصفحة الرئيسية */
@font-face { font-family: Plex; src: url(fonts/plex-ar-400.woff2) format('woff2'); font-weight: 400; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: Plex; src: url(fonts/plex-ar-600.woff2) format('woff2'); font-weight: 600; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: Plex; src: url(fonts/plex-ar-700.woff2) format('woff2'); font-weight: 700; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: Plex; src: url(fonts/plex-lat-400.woff2) format('woff2'); font-weight: 400; unicode-range: U+0000-00FF; font-display: swap; }
@font-face { font-family: Plex; src: url(fonts/plex-lat-600.woff2) format('woff2'); font-weight: 600; unicode-range: U+0000-00FF; font-display: swap; }
@font-face { font-family: Plex; src: url(fonts/plex-lat-700.woff2) format('woff2'); font-weight: 700; unicode-range: U+0000-00FF; font-display: swap; }

:root {
  --primary: #1f6feb;
  --bg: #f4f6fb; --card: #ffffff; --soft: #f7f8fc; --text: #0f1729; --muted: #667085; --line: #e7eaf2; --line-2: #eef0f6;
  --ink: #0c1427; --ink-2: #16203a; --ink-text: #c9d1e4;
  --green: #12a150; --red: #e5484d; --amber: #d98a00; --violet: #7c4ddb;
  --radius: 16px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --ring: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; margin: 0; font-family: Plex, "Segoe UI", Tahoma, sans-serif; background: var(--bg); color: var(--text); direction: rtl; font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* الشريط العلوي */
header { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px;
  background: rgba(255, 255, 255, .85); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--line); }
header h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
header a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; padding: 7px 12px; border-radius: 10px; transition: background .2s, color .2s; }
header a:hover { background: var(--soft); color: var(--text); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { height: 34px; width: 34px; object-fit: contain; border-radius: 10px; }
.brand h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #7c4ddb)); box-shadow: 0 6px 16px -6px var(--primary); }
.brand-mark svg { width: 20px; height: 20px; }

main { max-width: 1320px; margin: 24px auto; padding: 0 20px; }

/* بطاقات */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card h3 { font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.hello { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.hello h2 { margin: 0; font-size: 20px; }

/* النماذج */
label { display: block; font-size: 13px; font-weight: 600; color: #344054; margin: 14px 0 6px; }
input, select, textarea { width: 100%; padding: 10px 12px; font-size: 15px; border: 1px solid #d0d5dd; border-radius: 10px; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); box-shadow: none; }
input[type=file] { padding: 8px; background: var(--soft); }
button { font-family: inherit; font-size: 15px; font-weight: 600; padding: 10px 18px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; background: var(--primary); color: #fff;
  transition: transform .1s, filter .15s, background .15s, box-shadow .15s; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .5; cursor: default; }
.btn-file { display: inline-flex; align-items: center; font-size: 15px; font-weight: 600; padding: 10px 18px; border-radius: 10px; cursor: pointer; background: var(--primary); color: #fff; }
.btn-file:hover { filter: brightness(1.06); }
button.secondary { background: #fff; color: #344054; border-color: #d0d5dd; }
button.secondary:hover { background: var(--soft); filter: none; }
.small-btn { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }
.msg { margin-top: 14px; padding: 11px 14px; border-radius: 10px; display: none; font-size: 14px; font-weight: 600; }
.msg.ok { display: block; background: #ecfdf3; color: #067647; border: 1px solid #abefc6; }
.msg.err { display: block; background: #fef3f2; color: #b42318; border: 1px solid #fecdca; }

/* الإحصائيات */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { position: relative; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow); }
.stat::before { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--c, var(--primary)); opacity: .9; }
.stat::after { content: ''; position: absolute; width: 90px; height: 90px; border-radius: 50%; left: -26px; top: -26px; background: var(--c, var(--primary)); opacity: .07; }
.stat .n { font-size: 30px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .l { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 2px; }
.stats .stat:nth-child(1) { --c: #475467; } .stats .stat:nth-child(2) { --c: var(--green); } .stats .stat:nth-child(3) { --c: var(--amber); }
.stats .stat:nth-child(4) { --c: var(--red); } .stats .stat:nth-child(5) { --c: var(--primary); } .stats .stat:nth-child(6) { --c: var(--violet); }

/* الجداول */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
th, td { text-align: right; padding: 12px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: var(--soft); position: sticky; top: 0; }
th:first-child { border-top-right-radius: 10px; } th:last-child { border-top-left-radius: 10px; }
tbody tr:hover td, tr:hover > td { background: #fafbff; }
tr:last-child td { border-bottom: 0; }

/* الشارات */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #f2f4f7; color: #344054; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.b-حاضر { background: #ecfdf3; color: #067647; }
.b-متأخر { background: #fffaeb; color: #b54708; }
.b-غائب { background: #fef3f2; color: #b42318; }
.b-إجازة { background: #eff4ff; color: #3538cd; }
.b-عطلة, .b-لم { background: #f2f4f7; color: var(--muted); }
.b-دوام { background: #f4f3ff; color: #5925dc; }
.b-offline { background: #fff6ed; color: #c4320a; font-size: 11px; white-space: nowrap; }
.b-offline::before { display: none; }
a.loc { color: var(--primary); font-size: 12px; text-decoration: none; }

.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.kv b { font-weight: 700; }
.net { font-size: 22px; color: var(--green); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.clock { text-align: center; font-size: 44px; font-weight: 700; }
.date { text-align: center; color: var(--muted); margin-bottom: 18px; }

/* النوافذ */
dialog { border: 0; border-radius: 20px; padding: 24px; width: min(660px, 94vw); box-shadow: 0 24px 60px -12px rgba(16, 24, 40, .35); }
dialog::backdrop { background: rgba(12, 20, 39, .45); backdrop-filter: blur(3px); }
dialog h3 { font-size: 18px; }

/* أشرطة التنبيه */
.subbar { background: #fef3f2; color: #b42318; padding: 12px 16px; text-align: center; font-weight: 600; border-bottom: 1px solid #fecdca; }
.warnbar { background: #fffaeb; color: #93370d; padding: 10px 16px; text-align: center; font-size: 14px; border-bottom: 1px solid #fedf89; }
.warnbar a { font-weight: 700; }
.support-note { text-align: center; margin-top: 10px; }

/* ---------- تخطيط اللوحة: قائمة جانبية + محتوى ---------- */
#app.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 24px; align-items: start; }
#app.shell > section, #app.shell > .page-head { grid-column: 2; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: #fff; color: #344054; border-color: var(--line); }
.tabs button.active { background: var(--primary); color: #fff; }
#app.shell > .tabs { grid-column: 1; grid-row: 1 / span 30; position: sticky; top: 84px; flex-direction: column; flex-wrap: nowrap; gap: 2px; margin: 0;
  background: var(--ink); border-radius: 20px; padding: 14px 10px; box-shadow: 0 20px 40px -20px rgba(12, 20, 39, .6); max-height: calc(100vh - 108px); overflow: auto; }
#app.shell > .tabs::before { content: attr(data-title); display: block; color: #8b95ad; font-size: 11.5px; font-weight: 700; letter-spacing: .3px; padding: 4px 12px 10px; }
#app.shell > .tabs button { display: flex; align-items: center; gap: 11px; width: 100%; text-align: right; background: transparent; color: var(--ink-text); border: 0; box-shadow: none;
  padding: 10px 12px; font-size: 14.5px; font-weight: 600; border-radius: 12px; }
#app.shell > .tabs button:hover { background: rgba(255, 255, 255, .06); color: #fff; filter: none; }
#app.shell > .tabs button.active { background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #7c4ddb)); color: #fff; box-shadow: 0 8px 20px -10px var(--primary); }
.tabs .ic { width: 19px; height: 19px; flex: 0 0 auto; opacity: .9; }
.tabs .cnt { margin-inline-start: auto !important; }
.tabs .sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 8px 10px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 2px 0 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 24px; letter-spacing: -.4px; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
@media (max-width: 900px) {
  #app.shell { display: block; }
  #app.shell > .tabs { position: sticky; top: 59px; z-index: 20; flex-direction: row; overflow-x: auto; border-radius: 14px; padding: 6px; margin: 0 -4px 16px; max-height: none; scrollbar-width: none; }
  #app.shell > .tabs::before, .tabs .sep { display: none; }
  #app.shell > .tabs button { width: auto; flex: 0 0 auto; padding: 8px 12px; font-size: 13.5px; }
  .page-head h2 { font-size: 20px; }
  header { padding: 10px 14px; }
  header a { white-space: nowrap; padding: 6px 8px; font-size: 13px; }
  header a[href="index.html"] { display: none; }
  header .brand { min-width: 0; } header h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding: 0 14px; margin-top: 16px; }
  .card { padding: 18px; } .table-wrap { margin: 0 -18px; padding: 0 18px; }
}

/* ---------- شاشة الدخول ---------- */
.auth-bg { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 30px 0; }
#loginBox.auth { width: 100%; max-width: 430px; padding: 32px; border-radius: 24px; box-shadow: 0 30px 60px -24px rgba(16, 24, 40, .25); }
.auth .auth-head { text-align: center; margin-bottom: 18px; }
.auth .auth-head .brand-mark { width: 56px; height: 56px; border-radius: 18px; margin: 0 auto 14px; }
.auth .auth-head .brand-mark svg { width: 30px; height: 30px; }
.auth .auth-head h2 { margin: 0; font-size: 22px; letter-spacing: -.3px; }
.auth .auth-head p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
body.logged-out { background: radial-gradient(1200px 600px at 85% -10%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 60%),
  radial-gradient(900px 500px at -10% 110%, rgba(124, 77, 219, .12), transparent 60%), var(--bg); }

/* طباعة */
@media print { header, .tabs, .page-head { display: none !important; } #app.shell { display: block; } .card { box-shadow: none; } }
.company-logo:not(.hidden) + .brand-mark { display: none; }
.auth { margin-top: 7vh; }

/* =====================================================================
   التصميم الفخم: أبيض وأزرق، زجاج صافٍ بلا تدرّجات داخل العناصر
   ===================================================================== */
:root {
  --primary: #1a4fd6; --bg: #f4f7fd; --card: rgba(255, 255, 255, .78); --soft: #eef3fc; --text: #0b1b45; --muted: #66728f; --line: rgba(11, 27, 69, .07); --line-2: rgba(11, 27, 69, .06);
  --ink: #ffffff; --ink-2: #f4f7fd; --ink-text: #3d4a6b; --green: #12a072; --red: #e04459; --amber: #ec9a16; --violet: #6b5cf0;
  --radius: 22px; --shadow: 0 1px 2px rgba(11, 27, 69, .04), 0 18px 40px -24px rgba(26, 79, 214, .3);
}
html { background: var(--bg); }
body, body.logged-out { background: transparent; color: var(--text); }
body::before, body::after { content: ''; position: fixed; z-index: -1; border-radius: 50%; filter: blur(110px); pointer-events: none; }
body::before { width: 520px; height: 520px; top: -220px; right: -160px; background: color-mix(in srgb, var(--primary) 20%, transparent); }
body::after { width: 460px; height: 460px; bottom: -200px; left: -160px; background: color-mix(in srgb, var(--primary) 12%, transparent); }
header { background: rgba(255, 255, 255, .7); border-bottom: 1px solid rgba(255, 255, 255, .9); box-shadow: 0 1px 0 var(--line); }
.brand-mark { background: var(--primary); box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--primary) 90%, transparent); }
.card, .stat { background: var(--card); border: 1px solid rgba(255, 255, 255, .95); box-shadow: var(--shadow), 0 0 0 1px var(--line);
  backdrop-filter: blur(22px) saturate(1.5); -webkit-backdrop-filter: blur(22px) saturate(1.5); }
.stat::before { inset: 18px auto auto 18px; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--primary)) 14%, transparent); }
.stat::after { display: none; }
.stat .n { font-size: 34px; font-weight: 600; letter-spacing: -1px; color: var(--c, var(--text)); }
.stats .stat:nth-child(1) { --c: var(--text); }
th { background: transparent; color: var(--muted); border-bottom: 1px solid var(--line); }
tbody tr:hover td, tr:hover > td { background: rgba(26, 79, 214, .035); }
input, select, textarea { background: rgba(255, 255, 255, .9); border-color: rgba(11, 27, 69, .12); border-radius: 12px; }
button { border-radius: 12px; box-shadow: 0 10px 20px -14px color-mix(in srgb, var(--primary) 90%, transparent); }
button.secondary { background: #fff; color: var(--text); border-color: rgba(11, 27, 69, .1); box-shadow: 0 1px 2px rgba(11, 27, 69, .05); }
.btn-file { border-radius: 12px; }
dialog { background: #fff; border-radius: 24px; box-shadow: 0 40px 80px -30px rgba(11, 27, 69, .45); }
dialog::backdrop { background: rgba(11, 27, 69, .35); backdrop-filter: blur(6px); }
/* القائمة الجانبية: زجاج أبيض */
.tabs button { background: #fff; color: var(--ink-text); }
#app.shell > .tabs { background: rgba(255, 255, 255, .78); border: 1px solid rgba(255, 255, 255, .95); box-shadow: var(--shadow), 0 0 0 1px var(--line);
  backdrop-filter: blur(22px) saturate(1.5); -webkit-backdrop-filter: blur(22px) saturate(1.5); border-radius: 24px; padding: 16px 12px; }
#app.shell > .tabs::before { color: var(--muted); }
#app.shell > .tabs button { color: var(--ink-text); }
#app.shell > .tabs button:hover { background: var(--soft); color: var(--text); }
#app.shell > .tabs button.active { background: var(--primary); color: #fff; box-shadow: 0 12px 24px -12px color-mix(in srgb, var(--primary) 95%, transparent); }
.tabs .sep { background: var(--line); }
.page-head h2 { font-size: 28px; letter-spacing: -.6px; }
#loginBox.auth { box-shadow: 0 40px 80px -36px rgba(26, 79, 214, .45), 0 0 0 1px var(--line); }
