/* RPM HR — a punch-clock for CAMADA RPM TECH.
   Brand cubes: green #109245, sky #08BDEF, blue #1A5FB4. Red #E0262E is reserved for "late". */
:root {
  --paper: #ffffff;
  --paper-2: #f3f5f7;
  --ink: #1b1e24;
  --steel: #5b6370;
  --line: #e2e6ea;
  --green: #109245;
  --green-wash: #e7f5ec;
  --sky: #08bdef;
  --sky-wash: #e5f7fd;
  --blue: #1a5fb4;
  --blue-ink: #154f97;
  --red: #e0262e;
  --red-wash: #fdeced;
  --amber: #b26b00;
  --focus: #08bdef;
  --r-s: 6px;
  --r-m: 12px;
  --font: 'Archivo', 'Kantumruy Pro', system-ui, sans-serif;
  --font-km: 'Kantumruy Pro', 'Archivo', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --paper: #15181d;
  --paper-2: #1e2229;
  --ink: #eef1f4;
  --steel: #9aa3af;
  --line: #2c323b;
  --green: #2bb866;
  --green-wash: #14301f;
  --sky: #3ccdf5;
  --sky-wash: #10303b;
  --blue: #4a8ae0;
  --blue-ink: #8ab6f0;
  --red: #ff5259;
  --red-wash: #3a1719;
  --amber: #e0a040;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font: 400 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
:lang(km) body, .km { font-family: var(--font-km); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue-ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Header: the logo sits on white with the three-cube rule under it ---------- */
.top { position: sticky; top: 0; z-index: 10; background: var(--paper); }
.top-in { display: flex; align-items: center; gap: 12px; padding: 10px 16px 8px; }
.logo-chip { background: #fff; border-radius: var(--r-s); padding: 3px 6px; display: flex; }
:root:not([data-theme='dark']) .logo-chip { padding: 0; }
.logo-chip img { height: 26px; display: block; }
.who { margin-left: auto; text-align: right; font-size: 12px; color: var(--steel); line-height: 1.25; }
.who { display: flex; align-items: center; gap: 10px; }
.who-n { display: block; }
.who b { display: block; color: var(--ink); font-weight: 600; font-size: 13px; }
.cubes { display: flex; height: 3px; }
.cubes i { flex: 1; } .cubes i:nth-child(1) { background: var(--green); } .cubes i:nth-child(2) { background: var(--sky); } .cubes i:nth-child(3) { background: var(--blue); }
.lang { border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 5px 11px; font: 600 13px var(--font-km); cursor: pointer; min-height: 32px; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

/* ---------- Type ---------- */
h1 { font-size: 22px; line-height: 1.2; font-weight: 700; margin: 4px 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 700; margin: 26px 0 8px; }
h2:first-child { margin-top: 4px; }
.sub { color: var(--steel); font-size: 13px; }
.muted { color: var(--steel); }
.small { font-size: 13px; }
.clock { font-stretch: 75%; font-weight: 800; letter-spacing: -0.02em; line-height: 0.95; }

/* ---------- The punch card (home) ---------- */
.punch { border: 1px solid var(--line); border-radius: var(--r-m); padding: 18px 18px 16px; position: relative; overflow: hidden; }
.punch::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--line); }
.punch.is-in::before { background: var(--green); }
.punch.is-late::before { background: var(--red); }
.punch.is-out::before { background: var(--blue); }
.punch .date { color: var(--steel); font-size: 13px; }
.punch .big { font-size: 64px; margin: 6px 0 4px; }
.punch .state { font-weight: 600; font-size: 15px; }
.punch .state .late { color: var(--red); }
.punch .place { color: var(--steel); font-size: 13px; margin-top: 2px; }
.punch .start { position: absolute; right: 16px; top: 16px; text-align: right; font-size: 12px; color: var(--steel); }
.punch .start b { display: block; font-size: 20px; color: var(--ink); font-stretch: 75%; font-weight: 800; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--r-s);
  padding: 11px 16px; font-weight: 600; cursor: pointer; background: var(--paper-2); color: var(--ink); text-decoration: none; min-height: 44px; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.go { background: var(--green); color: #fff; }
.btn.danger { background: var(--red-wash); color: var(--red); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { display: flex; width: 100%; }
.btn.xl { min-height: 58px; font-size: 17px; border-radius: var(--r-m); }
.btn.sm { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }

/* ---------- Lists: rows with rules, not card piles ---------- */
.list { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
button.item { width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--steel); }
.item .end { text-align: right; flex-shrink: 0; }
.item .time { font-stretch: 75%; font-weight: 800; font-size: 22px; min-width: 56px; }
.item .time.late { color: var(--red); }
.item .time.none { color: var(--steel); font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--line); }
.dot.g { background: var(--green); } .dot.r { background: var(--red); } .dot.s { background: var(--sky); } .dot.b { background: var(--blue); }
.amt { font-weight: 700; }
.amt.owe { color: var(--ink); }

.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--paper-2); color: var(--steel); vertical-align: 1px; }
.tag.temp { background: var(--sky-wash); color: #0a7899; }
:root[data-theme='dark'] .tag.temp { color: var(--sky); }
.tag.sup { background: var(--green-wash); color: var(--green); }
.tag.off { background: var(--red-wash); color: var(--red); }
.tag.paid { background: var(--green-wash); color: var(--green); }

/* ---------- Stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.stat { padding: 10px 12px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .n { font-size: clamp(19px, 6.2vw, 26px); overflow-wrap: anywhere; font-stretch: 75%; font-weight: 800; line-height: 1.05; }
.stat .l { font-size: 12px; color: var(--steel); }
.stat.r .n { color: var(--red); } .stat.g .n { color: var(--green); } .stat.s .n { color: #0a8fb8; }
:root[data-theme='dark'] .stat.s .n { color: var(--sky); }

/* ---------- Forms ---------- */
label.f { display: block; margin-top: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--steel); margin-bottom: 4px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; background: var(--paper); min-height: 44px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px var(--sky-wash); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two-col label.f { margin-top: 12px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; flex-shrink: 0; accent-color: var(--blue); }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--paper); padding: 9px 6px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--steel); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed='true'] { background: var(--ink); color: var(--paper); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips button { flex-shrink: 0; border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.chips button[aria-pressed='true'] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.stepper { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: var(--r-s); overflow: hidden; width: fit-content; }
.stepper button { width: 48px; height: 48px; border: 0; background: var(--paper-2); font-size: 22px; cursor: pointer; }
.stepper output { min-width: 70px; text-align: center; font-size: 26px; font-stretch: 75%; font-weight: 800; }

/* ---------- Map picker ---------- */
.map { height: 240px; border-radius: var(--r-m); border: 1px solid var(--line); margin-top: 10px; z-index: 0; }
.place-box { border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px; margin-top: 12px; }
.place-box + .place-box { margin-top: 10px; }

/* ---------- Notices ---------- */
.note { padding: 11px 13px; border-radius: var(--r-s); background: var(--paper-2); font-size: 14px; }
.note.err { background: var(--red-wash); color: var(--red); }
.note.ok { background: var(--green-wash); color: var(--green); }
.note.info { background: var(--sky-wash); }
.empty { padding: 28px 8px; text-align: center; color: var(--steel); }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 50; max-width: 560px; margin: 0 auto;
  padding: 13px 15px; border-radius: var(--r-m); background: var(--ink); color: var(--paper); font-weight: 600;
  transform: translateY(16px); opacity: 0; transition: transform .2s ease, opacity .2s ease; pointer-events: none; }
.toast.show { transform: none; opacity: 1; }
.toast.err { background: var(--red); color: #fff; }
.toast.ok { background: var(--green); color: #fff; }

/* ---------- Sheet (modal) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--paper); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
.sheet h1 { margin-top: 0; }
.sheet-close { float: right; border: 0; background: var(--paper-2); width: 36px; height: 36px; border-radius: 50%; font-size: 18px; cursor: pointer; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }

/* ---------- Bottom tabs ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; min-width: 0; text-align: center; padding: 8px 1px 9px; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--steel); text-decoration: none; position: relative; }
.tabs a svg { display: block; margin: 0 auto 2px; width: 24px; height: 24px; }
.tabs a[aria-current='page'] { color: var(--ink); font-weight: 600; }
.tabs a[aria-current='page']::before { content: ''; position: absolute; top: -1px; left: 28%; right: 28%; height: 3px; background: var(--blue); }

.back { display: inline-flex; align-items: center; gap: 4px; color: var(--steel); text-decoration: none; font-size: 14px; margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--steel); } .kv dd { margin: 0; }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 10px; }
.month-nav b { font-size: 15px; }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: sp 0.8s linear infinite; margin: 40px auto; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Join box on a new employee's page */
.join { border: 2px solid var(--sky); background: var(--sky-wash); border-radius: var(--r-m); padding: 14px 16px 16px; margin: 4px 0 16px; }
.join h2 { margin: 0 0 4px; }
.join .sub { margin: 0 0 10px; }
.join-grid { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.join-qr { width: 148px; flex-shrink: 0; background: #fff; border-radius: 8px; padding: 6px; }
.join-qr svg { display: block; width: 100%; height: auto; }
.join-ways { flex: 1; min-width: 180px; font-size: 14px; }
.join-ways p { margin: 0 0 8px; }
.join-code { font: 800 30px/1 var(--font); font-stretch: 80%; letter-spacing: .08em; padding: 10px 12px; background: var(--paper); border: 1px dashed var(--steel);
  border-radius: 8px; text-align: center; user-select: all; }

/* Leave and advance buttons: clearly tappable, but quieter than the main check-in button */
.btn.ask { justify-content: flex-start; gap: 12px; min-height: 54px; padding: 10px 14px; border-radius: var(--r-m);
  background: var(--sky-wash); color: var(--blue-ink); border: 1.5px solid var(--sky); font-size: 15.5px; text-align: left; }
.btn.ask .ask-ic { width: 34px; height: 34px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.btn.ask .ask-t { flex: 1; }
.btn.ask .ask-go { font-size: 24px; line-height: 1; opacity: .7; }
.btn.ask:hover { border-color: var(--blue); }
