/* HR System - mobile-first, works left-to-right (English) and right-to-left (Arabic). */
:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #17201d;
  --muted: #5d6b66;
  --line: #dfe5e2;
  --brand: #0f6b5c;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ed;
  --ok: #067647;  --ok-soft: #e7f6ee;
  --warn: #9a5b00; --warn-soft: #fdf3e1;
  --bad: #b42318; --bad-soft: #fdecea;
  --info: #1d4f91; --info-soft: #e8f0fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 1px 1px rgba(16, 24, 20, .04);
  font-size: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.4rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }

/* Header and navigation */
.topbar { background: var(--brand); color: var(--brand-ink); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center;
  gap: 1rem; justify-content: space-between; }
.brand { font-weight: 700; color: var(--brand-ink); font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.top-actions { display: flex; align-items: center; gap: .5rem; font-size: .9rem; white-space: nowrap; }
.top-actions a, .top-actions button { color: var(--brand-ink); opacity: .9; }
.lang-btn { background: rgba(255,255,255,.15); border: 0; color: #fff; border-radius: 6px; padding: .25rem .6rem;
  font: inherit; cursor: pointer; }
.nav { background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.nav-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; gap: .25rem; white-space: nowrap; }
@media (min-width: 900px) { .nav-inner { flex-wrap: wrap; } }
.nav a { display: inline-block; padding: .7rem .7rem; color: var(--muted); border-bottom: 2px solid transparent;
  font-size: .92rem; }
.nav a:hover { text-decoration: none; color: var(--ink); }
.nav a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 1rem 16px 3rem; }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; justify-content: space-between;
  margin-bottom: 1rem; }

/* Cards and grid */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem;
  box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat.bad .value { color: var(--bad); } .stat.warn .value { color: var(--warn); } .stat.ok .value { color: var(--ok); }
a.stat:hover { text-decoration: none; border-color: var(--brand); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); border-radius: 8px; padding: .55rem 1rem; font: inherit;
  font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-primary:hover { background: #0b574a; }
.btn-danger { color: var(--bad); border-color: #f1c4bf; }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Forms */
.form-grid { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=month], input[type=number],
input[type=search], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; font: inherit;
  background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.helptext, .field-help { display: block; color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.errorlist { list-style: none; margin: .3rem 0 0; padding: 0; color: var(--bad); font-size: .85rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.filters > div { min-width: 140px; flex: 1 1 140px; }
.filters .btn { flex: 0 0 auto; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; background: var(--info-soft);
  color: var(--info); }
.messages li.success { background: var(--ok-soft); color: var(--ok); }
.messages li.error { background: var(--bad-soft); color: var(--bad); }
.messages li.warning { background: var(--warn-soft); color: var(--warn); }
.alert { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-bad { background: var(--bad-soft); color: var(--bad); }
.alert-warn { background: var(--warn-soft); color: var(--warn); }
.alert-info { background: var(--info-soft); color: var(--info); }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: end; }

/* Badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.badge.ok, .badge.present, .badge.approved, .badge.valid { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.late, .badge.pending_manager, .badge.pending_hr, .badge.expiring, .badge.incomplete,
.badge.not_started { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.absent, .badge.rejected, .badge.expired { background: var(--bad-soft); color: var(--bad); }
.badge.leave, .badge.rest, .badge.holiday, .badge.cancelled, .badge.no_shift, .badge.not_employed, .badge.exempt, .badge.off, .badge.not_live
{ background: #eef1f0; color: var(--muted); }

.flag { color: var(--warn); font-size: .82rem; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line);
  vertical-align: middle; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: .5rem 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between;
  gap: .5rem; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }

/* Check-in page */
.checkin-wrap { max-width: 460px; margin: 0 auto; }
.camera { position: relative; background: #0d1412; border-radius: 14px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 52vh; margin: 0 auto; }
.camera video, .camera img { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.camera img { transform: none; }
.camera .placeholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #c9d3cf; text-align: center; padding: 1rem; }
.status-line { display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; border-radius: 8px;
  background: #eef1f0; color: var(--muted); font-size: .9rem; margin: .75rem 0; }
.status-line.ok { background: var(--ok-soft); color: var(--ok); }
.status-line.bad { background: var(--bad-soft); color: var(--bad); }
.big-btn { width: 100%; padding: 1rem; font-size: 1.15rem; border-radius: 12px; }
.clock { font-size: 2.4rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }

.login-box { max-width: 380px; margin: 3rem auto; }
.pagination { display: flex; gap: .5rem; justify-content: center; margin-top: 1rem; }

@media print { .topbar, .nav, .no-print { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }

/* Payroll / letters */
.money { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; background: var(--brand-soft); }
.slip { max-width: 820px; margin: 0 auto; }
.slip-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 2px solid var(--brand); padding-bottom: .75rem; margin-bottom: 1rem; }
.slip-head .co { font-weight: 700; font-size: 1.1rem; color: var(--brand); }
.slip table td, .slip table th { padding: .4rem .5rem; }
.net-box { display: flex; justify-content: space-between; align-items: center; background: var(--brand); color: #fff; border-radius: 10px; padding: .9rem 1.1rem; margin-top: 1rem; font-size: 1.2rem; font-weight: 700; }
.letter { max-width: 760px; margin: 0 auto; background: #fff; padding: 2.5rem; border: 1px solid var(--line); border-radius: 8px; }
.letter .two { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.letter .ar { direction: rtl; text-align: right; }
.letter .en { direction: ltr; text-align: left; }
.letter h2 { text-align: center; margin: 1.5rem 0; }
.sign { margin-top: 3rem; display: flex; justify-content: space-between; }
@media (max-width: 640px) { .letter .two { grid-template-columns: 1fr; } .letter { padding: 1.2rem; } }
.warn-list { margin: .25rem 0 0; padding-inline-start: 1.1rem; color: var(--warn); font-size: .82rem; }
.step-list { counter-reset: s; list-style: none; padding: 0; }
.step-list li { counter-increment: s; padding: .4rem 0 .4rem 2rem; position: relative; }
.step-list li::before { content: counter(s); position: absolute; inset-inline-start: 0; top: .35rem; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: .8rem; }

/* Roster */
table.roster th, table.roster td { text-align: center; padding: .35rem .3rem; border: 1px solid var(--line); }
table.roster td:first-child, table.roster th:first-child { text-align: start; }
table.roster th.today { color: var(--brand); }
.rcell { min-width: 112px; font-size: .8rem; }
.rcell .rtime { font-weight: 600; font-variant-numeric: tabular-nums; margin-bottom: .25rem; }
.rcell select { font-size: .72rem; padding: .2rem; }
.rcell.morn { background: #e8f3fb; } .rcell.eve { background: #ece9f8; }
.rcell.changed { background: var(--warn-soft); } .rcell.off { background: #f1f3f2; color: var(--muted); }
.rcell.today { outline: 2px solid var(--brand); outline-offset: -2px; }
.legend { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; border: 1px solid var(--line); }
.legend.morn { background: #e8f3fb; } .legend.eve { background: #ece9f8; } .legend.changed { background: var(--warn-soft); } .legend.off { background: #f1f3f2; }
@media print { .rcell select { display: none; } }

/* Counter QR sheet */
.qr-sheet { max-width: 560px; margin: 0 auto; background: #fff; border: 2px solid var(--brand); border-radius: 18px; padding: 2rem; text-align: center; }
.qr-title { font-size: 1.6rem; font-weight: 700; color: var(--brand); }
.qr-title.ar, .qr-steps .ar { font-family: "IBM Plex Sans Arabic", sans-serif; direction: rtl; }
.qr-code svg { width: 320px; height: 320px; margin: 1.2rem auto; display: block; }
.qr-steps { list-style: none; padding: 0; margin: 0 0 1rem; }
.qr-steps li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: 1rem; }
.qr-branch { font-weight: 700; font-size: 1.15rem; margin-top: .6rem; }
.qr-url { color: var(--muted); font-size: .8rem; margin-top: .4rem; word-break: break-all; }
@media print { main { padding: 0; } .qr-sheet { border-width: 3px; margin-top: 1cm; } }

.ok-text { color: var(--ok); }
.fp-icon { font-size: 1.2em; margin-inline-end: .35rem; }

/* numbered how-to steps */
ol.steps { padding-inline-start: 1.3rem; margin: 0; }
ol.steps > li { margin: .2rem 0 .9rem; line-height: 1.55; }
ol.steps ul { margin: .4rem 0 0; }
