:root {
  --navy: #333333;
  --navy-2: #4a4a4a;
  --teal: #F1B526;
  --teal-d: #9a6f00;
  --bg: #f5f5f3;
  --card: #ffffff;
  --text: #262626;
  --muted: #6f6f6f;
  --line: #e6e4df;
  --green: #22a06b;
  --green-bg: #e3f6ec;
  --orange: #e07b17;
  --orange-bg: #fff1e2;
  --red: #d64545;
  --red-bg: #fde8e8;
  --blue: #2f6fd1;
  --blue-bg: #e6efff;
  --grey-bg: #f0efec;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .07);
  --nav-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  background: #e6e5e1;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  box-shadow: 0 0 30px rgba(0,0,0,.08);
}

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: linear-gradient(170deg, var(--navy) 0%, var(--navy-2) 42%, var(--bg) 42.2%);
  padding: 32px 20px 24px;
}
.login .brand { color: #fff; text-align: center; margin: 18px 0 26px; }
.login .brand img { width: 190px; height: auto; display: block; margin: 0 auto; }
.login .brand::after { content: ""; display: block; width: 56px; height: 4px; background: var(--teal); border-radius: 2px; margin: 14px auto 0; }
.login .brand h1 { font-size: 22px; margin: 12px 0 2px; }
.login .brand p { margin: 0; opacity: .8; font-size: 14px; }
.login-card { background: var(--card); border-radius: 20px; padding: 20px; box-shadow: 0 10px 30px rgba(20,40,70,.15); }
.seg { display: flex; background: var(--grey-bg); border-radius: 12px; padding: 4px; margin-bottom: 18px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.active { background: #fff; color: var(--navy); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #3d3d3d; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; outline: none;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; background: var(--navy); color: #fff; width: 100%;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.teal { background: var(--teal); color: #262626; }
.btn.light { background: var(--grey-bg); color: var(--navy); }
.btn.danger { background: var(--red-bg); color: var(--red); }
.btn.sm { width: auto; padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.note { background: var(--blue-bg); color: var(--blue); border-radius: 10px; padding: 9px 12px; font-size: 13px; margin-bottom: 12px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: auto; padding-top: 20px; }

/* ---------- App frame ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 18px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar .greet { font-size: 12.5px; opacity: .8; }
.topbar .name { font-size: 18px; font-weight: 700; }
.topbar .shift { font-size: 12.5px; opacity: .85; margin-top: 2px; }
.bell { position: relative; background: rgba(255,255,255,.12); border: 0; color: #fff; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: 0 0 auto; }
.bell .badge { position: absolute; top: -4px; left: -4px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; min-width: 19px; height: 19px; border-radius: 10px; display: grid; place-items: center; padding: 0 5px; }
main.page { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }

.bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 30;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
.bottomnav button svg { width: 22px; height: 22px; }
.bottomnav button.active { color: var(--navy); }
.bottomnav button.active svg { stroke: var(--teal); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.section-title { font-size: 15px; font-weight: 700; margin: 18px 2px 10px; display: flex; justify-content: space-between; align-items: center; }

/* ---------- Attendance tab ---------- */
.clock { text-align: center; margin-bottom: 12px; }
.clock .time { font-size: 30px; font-weight: 700; color: var(--navy); letter-spacing: .5px; }
.clock .date { color: var(--muted); font-size: 13px; }
.minimap { height: 210px; border-radius: 14px; overflow: hidden; background: #ecebe7; position: relative; z-index: 1; }
.minimap.tall { height: 180px; }
.geo-chip { display: flex; align-items: center; gap: 8px; border-radius: 12px; padding: 10px 12px; margin-top: 12px; font-size: 14px; font-weight: 600; }
.geo-chip.in { background: var(--green-bg); color: var(--green); }
.geo-chip.out { background: var(--red-bg); color: var(--red); }
.geo-chip.wait { background: var(--grey-bg); color: var(--muted); }
.geo-chip .sub { font-weight: 400; font-size: 12px; opacity: .85; }
.geo-chip .dist { margin-inline-start: auto; font-size: 13px; }

.punch-wrap { display: flex; justify-content: center; padding: 22px 0 10px; }
.punch-btn {
  width: 184px; height: 184px; border-radius: 50%; border: 0;
  background: radial-gradient(circle at 35% 30%, #ffd463, #e0a312);
  color: #262626; font-size: 21px; font-weight: 700;
  box-shadow: 0 0 0 14px rgba(241,181,38,.18), 0 0 0 28px rgba(241,181,38,.08), 0 12px 30px rgba(170,120,0,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform .12s;
}
.punch-btn small { font-size: 13px; font-weight: 500; opacity: .9; }
.punch-btn:active { transform: scale(.96); }
.punch-btn.out { background: radial-gradient(circle at 35% 30%, #5c5c5c, var(--navy)); color: #fff; box-shadow: 0 0 0 14px rgba(51,51,51,.13), 0 0 0 28px rgba(51,51,51,.06), 0 12px 30px rgba(0,0,0,.35); }
.punch-btn:disabled { filter: grayscale(.7); opacity: .6; }
.punch-btn .spinner { width: 34px; height: 34px; border-width: 4px; }

.checks { list-style: none; padding: 0; margin: 10px 0 0; }
.checks li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 4px 0; }
.dot-ok, .dot-bad, .dot-warn { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; flex: 0 0 auto; }
.dot-ok { background: var(--green); }
.dot-bad { background: var(--red); }
.dot-warn { background: var(--orange); }

.today-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.today-grid .v { font-size: 16px; font-weight: 700; color: var(--navy); }
.today-grid .k { font-size: 12px; color: var(--muted); }

.banner { border-radius: 14px; padding: 14px; margin-bottom: 14px; font-weight: 600; display: flex; gap: 10px; align-items: flex-start; }
.banner.info { background: var(--blue-bg); color: var(--blue); }
.banner.warn { background: var(--orange-bg); color: var(--orange); }
.banner.err { background: var(--red-bg); color: var(--red); }
.banner .t { font-weight: 400; font-size: 13.5px; }

/* confirmation */
.confirm { text-align: center; padding-top: 8px; }
.confirm .tick { width: 84px; height: 84px; border-radius: 50%; background: var(--green-bg); color: var(--green); display: grid; place-items: center; margin: 6px auto 12px; }
.confirm .tick svg { width: 44px; height: 44px; }
.confirm h2 { margin: 0; font-size: 21px; }
.confirm .msg { color: var(--muted); margin: 4px 0 16px; font-size: 14px; }
.kv { text-align: start; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv div:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv b { font-weight: 700; }
.selfie-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 12px; }

/* ---------- History ---------- */
.month-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-bar h2 { margin: 0; font-size: 18px; }
.icon-btn { width: 38px; height: 38px; border: 0; background: #fff; border-radius: 11px; box-shadow: var(--shadow); display: grid; place-items: center; color: var(--navy); }
.icon-btn:disabled { opacity: .4; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.tile { background: #fff; border-radius: 14px; padding: 12px 8px; text-align: center; box-shadow: var(--shadow); }
.tile .v { font-size: 22px; font-weight: 700; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile.g .v { color: var(--green); }
.tile.o .v { color: var(--orange); }
.tile.b .v { color: var(--teal-d); }
.tile.r .v { color: var(--red); }
.day { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 14px; padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow); border: 0; width: 100%; text-align: start; }
.day .dnum { width: 46px; text-align: center; flex: 0 0 auto; }
.day .dnum b { display: block; font-size: 20px; color: var(--navy); line-height: 1.1; }
.day .dnum span { font-size: 11.5px; color: var(--muted); }
.day .info { flex: 1; min-width: 0; }
.day .info .t { font-weight: 600; font-size: 14px; }
.day .info .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badges { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex: 0 0 auto; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.b-green { background: var(--green-bg); color: var(--green); }
.b-orange { background: var(--orange-bg); color: var(--orange); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-grey { background: var(--grey-bg); color: var(--muted); }
.b-purple { background: #f0e8ff; color: #7442c8; }

/* ---------- Leaves ---------- */
.bal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.bal { background: #fff; border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.bal .n { font-size: 13px; color: var(--muted); }
.bal .v { font-size: 22px; font-weight: 700; color: var(--navy); }
.bal .v small { font-size: 12px; color: var(--muted); font-weight: 500; }
.bal .bar { height: 6px; background: var(--grey-bg); border-radius: 4px; margin-top: 6px; overflow: hidden; }
.bal .bar i { display: block; height: 100%; background: var(--teal); border-radius: 4px; }
.req { background: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.req .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.req .top b { font-size: 14.5px; }
.req .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.req .actions { margin-top: 8px; }

/* ---------- Account ---------- */
.profile { display: flex; align-items: center; gap: 14px; }
.avatar { width: 58px; height: 58px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 22px; font-weight: 700; display: grid; place-items: center; flex: 0 0 auto; }
.profile h2 { margin: 0; font-size: 18px; }

/* ---------- Sheet / modal ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15,25,40,.45); z-index: 50; }
.sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; z-index: 60;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: #d3d1cb; margin: 0 auto 10px; }
.sheet .sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet .sheet-head h3 { margin: 0; font-size: 17px; }
.notif { background: #fff; border-radius: 12px; padding: 11px 13px; margin-bottom: 8px; box-shadow: var(--shadow); border-inline-start: 4px solid transparent; }
.notif.unread { border-inline-start-color: var(--teal); }
.notif b { font-size: 14px; }
.notif p { margin: 3px 0 2px; font-size: 13.5px; color: #3d3d3d; }
.notif time { font-size: 11.5px; color: var(--muted); }
.camera video, .camera img { width: 100%; border-radius: 14px; background: #000; max-height: 50vh; object-fit: cover; }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 14px; }

/* ---------- Toasts & spinner ---------- */
.toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); width: calc(100% - 32px); max-width: 448px; z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--text); color: #fff; padding: 11px 14px; border-radius: 12px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: up2 .2s ease-out; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes up2 { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
.spinner.dark { border-color: rgba(51,51,51,.2); border-top-color: var(--navy); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; justify-content: center; padding: 40px; }

/* leaflet tweaks */
.leaflet-container { font-family: inherit; }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47,111,209,.25); }
.site-pin { width: 26px; height: 26px; border-radius: 7px; background: var(--navy); color: #fff; display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); }

/* ---------- install as an app ---------- */
.install-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin: 14px 0; border-top: 3px solid var(--teal); }
.login .install-card { margin: 16px 0 0; }
.install-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.install-head img { width: 46px; height: 46px; border-radius: 11px; flex: 0 0 auto; }
.install-head b { display: block; font-size: 15px; }
.install-head span { display: block; font-size: 12.5px; color: var(--muted); }
.install-steps { margin: 0; padding-inline-start: 20px; font-size: 13.5px; color: #3d3d3d; line-height: 1.9; }
.ios-share { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1.5px solid #2f6fd1; color: #2f6fd1; border-radius: 6px; font-size: 13px; vertical-align: -5px; }

/* ---------- managers / head office: dashboard shortcut ---------- */
.top-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.dash-btn { width: auto; padding: 0 12px; gap: 6px; display: flex; align-items: center; background: var(--teal); color: #262626; font-weight: 700; font-size: 13px; }
.dash-btn svg { stroke: #262626; }

/* ---------- "Location required" full-screen page ---------- */
.geo-gate { min-height: 100vh; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: calc(40px + env(safe-area-inset-top)) 22px calc(28px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--navy) 0, var(--navy) 210px, var(--bg) 210px); }
.gate-icon { width: 92px; height: 92px; border-radius: 50%; background: var(--teal); color: #262626; display: grid; place-items: center;
  box-shadow: 0 0 0 10px rgba(241,181,38,.18), 0 10px 30px rgba(0,0,0,.25); margin-bottom: 18px; }
.geo-gate h1 { color: #fff; font-size: 21px; margin: 0 0 30px; }
.gate-lead { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin: 0 0 14px; font-size: 14.5px; color: #3d3d3d; line-height: 1.8; width: 100%; }
.gate-warn { background: var(--red-bg); color: var(--red); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 12px; width: 100%; line-height: 1.7; }
.gate-btn { width: 100%; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; font-size: 16px; }
.gate-btn .spinner { border-color: rgba(0,0,0,.2); border-top-color: #262626; }
.gate-steps { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; width: 100%; text-align: right; margin-top: 4px; }
.gate-steps-title { font-weight: 700; margin-bottom: 8px; font-size: 14px; }
.gate-steps ol { margin: 0; padding-inline-start: 20px; font-size: 13.5px; line-height: 1.9; color: #3d3d3d; }
.gate-steps li + li { margin-top: 6px; }
.gate-foot { margin-top: auto; padding-top: 22px; display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.gate-foot .link { background: none; border: 0; color: var(--teal-d); font-weight: 700; text-decoration: underline; padding: 4px; }

/* self sign-up */
.reg-slot { margin-top: 14px; }
.reg-btn { width: 100%; }
.field select { width: 100%; }
.reg-done { text-align: center; }
.reg-done h3 { margin: 6px 0; }
.reg-done .note { text-align: right; }
.reg-ico { width: 56px; height: 56px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center;
  background: var(--gold, #F1B526); color: #262626; font-size: 28px; font-weight: 700; }

/* site change requests */
.scr-item { border-top: 1px solid #eee; padding: 10px 0 4px; margin-top: 10px; }
.scr-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.scr-steps { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; margin: 6px 0; }
.btn.sm { padding: 6px 12px; font-size: 13px; width: auto; }
.hidden { display: none !important; }

/* account links + delete */
.acc-links { text-align: center; margin-top: 14px; font-size: 13px; color: var(--muted); }
.acc-links a { color: var(--navy); }
.link-danger { background: none; border: 0; padding: 0; color: var(--red); font: inherit; text-decoration: underline; cursor: pointer; }
