:root {
  --dk: #096B6F;
  --teal: #07898B;
  --teal-50: #E8F5F5;
  --teal-100: #CDEAEA;
  --mag: #DA0B7E;
  --red: #EB2E27;
  --org: #F2852A;
  --yel: #FBE82D;
  --ink: #17282A;
  --mut: #5D7173;
  --line: #DCE6E7;
  --bg: #F3F7F7;
  --white: #FFFFFF;
  --ok: #0E8A5F;
  --ok-50: #E5F5EE;
  --warn-50: #FEF1E5;
  --bad-50: #FDEBEA;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(9, 107, 111, .06), 0 6px 20px rgba(9, 107, 111, .07);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", "Noto Kufi Arabic", "Noto Sans Arabic", Tahoma, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal); }
[hidden] { display: none !important; }

.topbar {
  background: var(--dk);
  color: var(--white);
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar img { height: 34px; width: auto; display: block; }
.topbar .title { font-weight: 700; font-size: 16px; white-space: nowrap; }
.topbar .who { font-size: 13px; opacity: .9; }
.topbar button { background: rgba(255,255,255,.12); color: var(--white); border: 1px solid rgba(255,255,255,.25); }
.topbar button:hover { background: rgba(255,255,255,.2); }

.wrap { max-width: 480px; margin: 0 auto; padding: 18px 16px 40px; }
.wrap.wide { max-width: 1180px; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 4px; font-size: 18px; color: var(--dk); }
.card h3 { margin: 0 0 10px; font-size: 16px; color: var(--dk); }
.muted { color: var(--mut); font-size: 13px; }
.small { font-size: 13px; }

label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 6px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  background: var(--white);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-100); }
textarea { min-height: 84px; resize: vertical; }
input[dir=ltr] { text-align: left; }

button {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s, border-color .15s, transform .05s;
}
button:hover { border-color: var(--teal); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.primary { background: var(--teal); border-color: var(--teal); color: var(--white); }
button.primary:hover { background: var(--dk); }
button.danger { color: var(--red); }
button.danger:hover { border-color: var(--red); }
button.block { width: 100%; padding: 13px; font-size: 16px; margin-top: 16px; }
button.link { border: none; background: none; color: var(--teal); padding: 4px 6px; }

.msg { border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-size: 14px; }
.msg.error { background: var(--bad-50); color: #9B1C17; }
.msg.ok { background: var(--ok-50); color: #0B6B4A; }
.msg.info { background: var(--teal-50); color: var(--dk); }
.msg.warn { background: var(--warn-50); color: #8A4A0E; }

/* البصمة */
.clock { text-align: center; padding: 6px 0 2px; }
.clock .time { font-size: 44px; font-weight: 700; color: var(--dk); letter-spacing: 1px; font-variant-numeric: tabular-nums; direction: ltr; }
.clock .date { color: var(--mut); }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px;
}
.status-pill .dot { width: 9px; height: 9px; border-radius: 50%; }
.st-in { background: var(--ok-50); color: var(--ok); }
.st-in .dot { background: var(--ok); }
.st-out { background: #EEF2F2; color: var(--mut); }
.st-out .dot { background: #9AAAAC; }
.st-absent { background: var(--bad-50); color: #9B1C17; }
.st-absent .dot { background: var(--red); }

.net { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-top: 12px; }
.net.office { background: var(--ok-50); color: #0B6B4A; }
.net.remote { background: var(--warn-50); color: #8A4A0E; }
.net svg { flex: none; }

.punch-btn {
  width: 100%;
  border: none;
  border-radius: 18px;
  padding: 22px 16px;
  margin-top: 16px;
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
  background: var(--teal);
  box-shadow: 0 6px 18px rgba(7, 137, 139, .35);
}
.punch-btn.out { background: var(--mag); box-shadow: 0 6px 18px rgba(218, 11, 126, .3); }
.punch-btn:hover { filter: brightness(1.05); }
.punch-btn.leave { background: var(--org); box-shadow: 0 6px 18px rgba(242, 133, 42, .32); }
.punch-btn.back { background: var(--teal); }
.actions { display: grid; gap: 0; }
.actions.two { grid-template-columns: 1fr 1fr; gap: 10px; }
.actions.two .punch-btn { font-size: 18px; padding: 18px 10px; }

.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 11px 8px; }
.seg button.on { background: var(--teal-50); border-color: var(--teal); color: var(--dk); }

.st-leave { background: var(--warn-50); color: #8A4A0E; }
.st-leave .dot { background: var(--org); }
.st-vac { background: #EEF0FF; color: #3B3F9E; }
.st-vac .dot { background: #5B61D6; }
.tag.leave_out { background: var(--warn-50); color: #8A4A0E; }
.tag.leave_back { background: var(--teal-50); color: var(--dk); }
.tag.vac { background: #EEF0FF; color: #3B3F9E; }
.tag.cancelled { background: #EEF2F2; color: var(--mut); }
.tag.home { background: #EEF0FF; color: #3B3F9E; }
.tag.qr { background: var(--teal-50); color: var(--dk); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: none; }
.timeline .t { font-variant-numeric: tabular-nums; font-weight: 700; direction: ltr; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.in { background: var(--ok-50); color: var(--ok); }
.tag.out { background: #FCE7F3; color: #A10A5E; }
.tag.office { background: var(--teal-50); color: var(--dk); }
.tag.remote { background: var(--warn-50); color: #8A4A0E; }
.tag.manual { background: #EEF0FF; color: #3B3F9E; }
.tag.pending { background: #FFF8D6; color: #7A6400; }
.tag.approved { background: var(--ok-50); color: var(--ok); }
.tag.rejected { background: var(--bad-50); color: #9B1C17; }
.tag.late { background: var(--warn-50); color: #8A4A0E; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--teal-50); border-radius: 12px; padding: 10px; text-align: center; }
.stat .n { font-size: 20px; font-weight: 700; color: var(--dk); font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--mut); }

.center { text-align: center; }
.hero-logo { display: block; margin: 8px auto 4px; height: 64px; }
.footer-note { text-align: center; color: var(--mut); font-size: 12px; margin-top: 18px; }

.spinner { width: 28px; height: 28px; border: 3px solid var(--teal-100); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* لوحة المسؤول */
.tabs { display: flex; gap: 4px; overflow-x: auto; background: var(--white); border-bottom: 1px solid var(--line); padding: 0 12px; position: sticky; top: 0; z-index: 5; }
.tabs button { border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 13px 14px; color: var(--mut); white-space: nowrap; }
.tabs button.active { color: var(--dk); border-bottom-color: var(--teal); }
.tabs .badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-inline-start: 6px; border-radius: 999px; background: var(--mag); color: var(--white); font-size: 12px; line-height: 20px; text-align: center; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .f { display: flex; flex-direction: column; min-width: 140px; }
.toolbar .f label { margin: 0 0 4px; font-size: 12px; color: var(--mut); font-weight: 600; }
.toolbar input, .toolbar select { padding: 8px 10px; }
.toolbar .grow { flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.kpi .n { font-size: 26px; font-weight: 700; color: var(--dk); font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--mut); font-size: 13px; }
.kpi.accent-ok .n { color: var(--ok); }
.kpi.accent-bad .n { color: var(--red); }
.kpi.accent-warn .n { color: var(--org); }
.kpi.accent-mag .n { color: var(--mag); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--teal-50); color: var(--dk); font-weight: 700; font-size: 13px; white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFCFC; }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; }
td .ltr { direction: ltr; display: inline-block; }
td.actions { white-space: nowrap; }
td.actions button { padding: 5px 10px; font-size: 13px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 18px 0 10px; }
.section-title h3 { margin: 0; color: var(--dk); font-size: 16px; }

.modal-bg { position: fixed; inset: 0; background: rgba(23, 40, 42, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--white); border-radius: 16px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 6px; color: var(--dk); }
.modal .row-btns { display: flex; gap: 10px; justify-content: flex-start; margin-top: 18px; }

.creds { width: 100%; border-collapse: collapse; }
.creds td, .creds th { border: 1px solid var(--line); padding: 8px; }
.creds code { font-size: 15px; direction: ltr; display: inline-block; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

@media print {
  .topbar, .tabs, .toolbar, .no-print, button { display: none !important; }
  body { background: var(--white); }
  .card, .table-wrap { box-shadow: none; border: none; }
}
