/* Emaarat Attendance — one stylesheet for staff, kiosk and office screens.
   Layout: phone-first single column; office screens widen to a two-column work area on desktop. */
:root {
  --bg: #ECEFEE; --surface: #FFFFFF; --sunk: #F5F7F6; --ink: #1B2220; --muted: #5D6965; --line: #D4DAD8;
  --accent: #1F4E79; --accent-ink: #FFFFFF; --hi: #E8B10A; --hi-ink: #1B2220;
  --ok: #2E7A4D; --ok-bg: #E3F1E8; --warn: #A86A12; --warn-bg: #FBF0DC; --bad: #B43A3A; --bad-bg: #F8E3E3;
  --off: #3E6A8F; --off-bg: #E2ECF5;
  --f-display: "Familjen Grotesk", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Noto Sans Devanagari", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111514; --surface: #1A201F; --sunk: #151A19; --ink: #E6ECEA; --muted: #93A19D; --line: #2B3432;
    --accent: #7DB0E2; --accent-ink: #0F1A24; --hi: #F0C23A; --hi-ink: #16130A;
    --ok: #6CC491; --ok-bg: #1B3226; --warn: #E3AE57; --warn-bg: #352816; --bad: #EE8A8A; --bad-bg: #3A1F1F;
    --off: #8DB8E0; --off-bg: #1C2A38;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.45;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
h1 { font-family: var(--f-display); font-size: 24px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-family: var(--f-display); font-size: 18px; font-weight: 600; }
h3 { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.wrap { max-width: 560px; margin: 0 auto; padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); padding-block: 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.wrap.wide { max-width: 1100px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 10px 16px; border-radius: 10px; font-weight: 600; min-height: 44px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.sm { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 6px 0; min-height: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.wa { color: #1F8A55; border-color: #1F8A55; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.off { background: var(--off-bg); color: var(--off); }
.pill.info { background: var(--sunk); color: var(--muted); border: 1px solid var(--line); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; min-height: 44px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 460px) { .grid2 { grid-template-columns: 1fr; } }
.err { color: var(--bad); font-size: 14px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: 15px; z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 8px 28px rgba(0,0,0,.22); }

/* ---------- staff ---------- */
.langs { display: flex; gap: 4px; }
.langs button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 9px; font-size: 13px; color: var(--muted); }
.langs button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.status { display: flex; flex-direction: column; gap: 4px; }
.status .big { font-family: var(--f-display); font-size: 22px; font-weight: 700; }
.punch { width: 100%; border: 0; border-radius: 22px; padding: 30px 16px; font-family: var(--f-display); font-size: 32px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--hi); color: var(--hi-ink); box-shadow: 0 6px 0 rgba(0,0,0,.12); }
.punch.out { background: var(--accent); color: var(--accent-ink); }
.punch:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.punch small { font-family: var(--f-body); font-size: 14px; font-weight: 500; opacity: .85; }
.asks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.asks button { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 6px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 14px; min-width: 0; }
.asks svg { width: 26px; height: 26px; color: var(--accent); }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.log li { display: flex; justify-content: space-between; gap: 10px; }
.days { display: flex; flex-direction: column; }
.days .d { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.days .d:first-child { border-top: 0; }

/* full-screen sheet for camera / forms */
.sheet { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); gap: 14px; overflow-y: auto; }
.cam { position: relative; width: 100%; max-width: 420px; margin: 0 auto; aspect-ratio: 3 / 4; border-radius: 20px; overflow: hidden; background: #000; }
.cam video, .cam img { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.cam img { transform: none; }
.cam .oval { position: absolute; inset: 12% 18% 18%; border: 3px dashed rgba(255,255,255,.75); border-radius: 50%; pointer-events: none; }
.cam .count { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--f-display); font-size: 96px; color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.5); }
.big-msg { font-family: var(--f-display); font-size: 26px; font-weight: 700; text-align: center; }
.tick { width: 96px; height: 96px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 0 auto; font-size: 56px; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .punch:active { transform: none; } }

/* ---------- kiosk ---------- */
.kiosk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.kiosk-grid button { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 16px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; min-width: 0; }
.kiosk-grid button span { overflow-wrap: anywhere; text-align: center; }
.avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); border: 2px solid var(--line); font-family: var(--f-display); font-weight: 700; font-size: 24px; color: var(--accent); flex: none; }
.avatar.in { border-color: var(--ok); }
.kiosk-clock { font-family: var(--f-mono); font-size: 40px; }

/* ---------- office ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; }
.tabs button { border: 1px solid transparent; background: none; padding: 8px 14px; border-radius: 10px; font-weight: 600; color: var(--muted); white-space: nowrap; min-height: 40px; }
.tabs button[aria-current="page"] { background: var(--surface); border-color: var(--line); color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 640px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tile { background: var(--sunk); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; }
.tile b { display: block; font-family: var(--f-mono); font-size: 24px; font-weight: 500; }
.tile span { font-size: 12.5px; color: var(--muted); }
.tile.ok b { color: var(--ok); } .tile.warn b { color: var(--warn); } .tile.bad b { color: var(--bad); }
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); min-width: 0; }
.item:first-child { border-top: 0; }
.item .main { flex: 1; min-width: 0; }
.item .name { font-weight: 600; }
.item .sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.item .end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.item.click { cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; }
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.selfies { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.selfie { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.selfie img { width: 100%; aspect-ratio: 3/4; object-fit: cover; background: var(--sunk); display: block; }
.selfie .cap { padding: 8px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.drawer { border: 1px solid var(--accent); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--surface); }
.linkbox { font-family: var(--f-mono); font-size: 13px; background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-wrap: anywhere; user-select: all; }
.center { text-align: center; }
