/* Maiimi HRIS — mobile-first, responsive to desktop. */
:root {
  --bg: #f6f1ea;
  --surface: #ffffff;
  --ink: #2f2723;
  --muted: #8a7d72;
  --line: #e7ddd1;
  --accent: #b06b4f;
  --accent-d: #97583e;
  --ok: #3f9d6d;
  --warn: #d99021;
  --late: #cf5b4e;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(80,55,40,.07);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45;
}
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.02rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* ── Login gate ─────────────────────────────────────────────── */
.login-gate {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, #b06b4f, #7c4b37); z-index: 100; padding: 24px;
}
.login-card { text-align: center; color: #fff; max-width: 340px; width: 100%; }
.login-logo { font-size: 2rem; font-weight: 800; letter-spacing: -.5px; }
.login-logo span { font-weight: 400; opacity: .85; margin-left: 4px; }
.login-tag { opacity: .85; margin: 4px 0 28px; }
#g_id_button { display: flex; justify-content: center; min-height: 44px; }
.login-status { margin-top: 18px; font-size: .85rem; color: rgba(255,255,255,.75); }

/* ── App shell ──────────────────────────────────────────────── */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; color: var(--accent); flex: 1; }
.brand span { font-weight: 400; color: var(--muted); margin-left: 3px; }
.icon-btn { background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--ink); padding: 6px; line-height: 1; }
.user-chip { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; font-size: .9rem; color: var(--ink); }
.user-chip img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }

.layout { display: flex; }
.sidebar {
  width: 230px; background: var(--surface); border-right: 1px solid var(--line);
  min-height: calc(100vh - 56px); padding: 14px 10px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 56px; align-self: flex-start;
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  text-decoration: none; color: var(--ink); font-size: .95rem; min-height: 44px;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }
.logout-btn { margin-top: 8px; background: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; color: var(--muted); }

.view { flex: 1; padding: 18px; max-width: 880px; margin: 0 auto; width: 100%; padding-bottom: 90px; }
.page { display: flex; flex-direction: column; gap: 14px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }
.section-title { margin-top: 6px; }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
.bottom-nav { display: none; }

/* ── Cards / stats ──────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.warn { background: #fdf6e8; border-color: #f0dcae; color: #8a6d2a; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { text-align: left; }
.stat-val { font-size: 1.7rem; font-weight: 800; color: var(--accent); }
.stat-label { font-size: .85rem; }

/* ── Clock card ─────────────────────────────────────────────── */
.clock-card { display: flex; flex-direction: column; gap: 14px; }
.clock-status { display: flex; align-items: center; justify-content: space-between; }
.clock-big { font-size: 2.4rem; font-weight: 800; letter-spacing: 1px; }
.clock-times { display: flex; gap: 24px; }
.clock-times > div { display: flex; flex-direction: column; }
.clock-times strong { font-size: 1.2rem; }
.done-note { text-align: center; color: var(--ok); font-weight: 600; padding: 8px; }

/* ── Lists / rows ───────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.row.col { flex-direction: column; align-items: stretch; gap: 10px; }
.row[onclick], .row { cursor: default; }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-main strong { font-size: .96rem; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chev { color: var(--muted); font-size: 1.3rem; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.loading { text-align: center; color: var(--muted); padding: 24px; }
.blocker { text-align: center; padding: 60px 20px; display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { font-size: .72rem; padding: 3px 9px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: #e4f3ea; color: var(--ok); }
.badge-warn { background: #fbf0d9; color: var(--warn); }
.badge-late { background: #fae3e0; color: var(--late); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  font: inherit; font-size: .92rem; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; min-height: 44px; font-weight: 600;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-d); }
.btn-ghost { background: var(--surface); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { background: var(--late); border-color: var(--late); color: #fff; }
.btn-sm { padding: 7px 12px; min-height: 36px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

/* ── Forms ──────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > span { font-size: .85rem; color: var(--muted); }
.inp {
  font: inherit; font-size: 16px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); width: 100%;
}
.inp-sm { width: auto; padding: 8px 10px; }
textarea.inp { resize: vertical; }
.chk { display: inline-flex; align-items: center; gap: 7px; font-size: .9rem; cursor: pointer; }
.chk input { width: 18px; height: 18px; }
.chk-row { display: flex; flex-wrap: wrap; gap: 12px; }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── KPI bars / ranking ─────────────────────────────────────── */
.kpi-item { display: flex; flex-direction: column; gap: 6px; }
.kpi-top { display: flex; justify-content: space-between; align-items: center; }
.kpi-pct { font-weight: 800; color: var(--accent); }
.bar { background: var(--bg); border-radius: 6px; height: 9px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width .3s; }
.kpi-input-row { display: flex; flex-direction: column; gap: 10px; }
.kpi-inputs { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.kpi-inputs .field { margin: 0; }

.rank-row { gap: 12px; }
.rank-row.me { border-color: var(--accent); background: #fbf1ec; }
.rank-badge { font-size: 1.2rem; font-weight: 800; width: 38px; text-align: center; }
.rank-score { font-weight: 800; font-size: 1.1rem; color: var(--accent); }

/* ── Detail / photos ────────────────────────────────────────── */
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.photo-pair { display: flex; gap: 12px; margin-top: 12px; }
.photo-slot { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.selfie { width: 100%; border-radius: 10px; border: 1px solid var(--line); aspect-ratio: 1; object-fit: cover; background: var(--bg); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(40,28,20,.45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); border-radius: 18px 18px 0 0; width: 100%; max-width: 520px; max-height: 92vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); padding-bottom: calc(14px + var(--safe-b)); }

/* ── Camera ─────────────────────────────────────────────────── */
.cam-overlay { position: fixed; inset: 0; background: #000; z-index: 80; display: flex; align-items: center; justify-content: center; }
.cam-box { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 14px; padding: 18px; }
#cam-video { width: 100%; border-radius: 14px; background: #111; transform: scaleX(-1); }
.cam-actions { display: flex; gap: 10px; justify-content: center; }
.cam-msg { color: #fff; text-align: center; font-size: .85rem; min-height: 18px; }

/* ── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--safe-b)); z-index: 90;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: .9rem;
  max-width: 90%; box-shadow: 0 6px 20px rgba(0,0,0,.25); text-align: center;
}
.toast-ok { background: var(--ok); }
.toast-warn { background: var(--warn); }
.toast-err { background: var(--late); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; min-height: 100vh; z-index: 40;
    transform: translateX(-100%); transition: transform .25s; width: 250px; padding-top: 20px;
  }
  .sidebar.open { transform: translateX(0); }
  .view { padding: 14px; padding-bottom: calc(80px + var(--safe-b)); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { border-radius: 18px; margin: auto; max-height: 88vh; }
  .modal-overlay { align-items: center; padding: 14px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--surface);
    border-top: 1px solid var(--line); padding-bottom: var(--safe-b); height: calc(60px + var(--safe-b));
  }
  .bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    text-decoration: none; color: var(--muted); font-size: .68rem; cursor: pointer;
  }
  .bn-item.active { color: var(--accent); }
  .bn-icon { font-size: 1.25rem; }
}
@media (min-width: 769px) {
  .only-desktop-hidden { display: none; }
  .backdrop { display: none !important; }
}
