:root {
    --ink: #122026;
    --muted: #5c6f75;
    --line: #dce5e3;
    --bg: #eef3f1;
    --card: #ffffff;
    --brand: #0c6b63;
    --brand-dark: #084741;
    --brand-2: #149184;
    --brand-soft: #e4f4f1;
    --accent: #e8b931;
    --present: #0d7a4f;
    --present-bg: #e6f6ee;
    --late: #c2410c;
    --late-bg: #fff1e6;
    --absent: #c4281c;
    --absent-bg: #fdecea;
    --leave: #1d4ed8;
    --leave-bg: #e8eefe;
    --ot: #6d28d9;
    --ot-bg: #f1e9fe;
    --shadow: 0 10px 30px rgba(8, 71, 65, 0.08);
    --radius: 18px;
    --radius-sm: 12px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --nav-h: calc(64px + env(safe-area-inset-bottom, 0px));
    --sidebar-w: 232px;
  }

  * { box-sizing: border-box; }
  html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 "SF Pro Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  button, input, select, textarea { font: inherit; }
  button { cursor: pointer; }
  a { color: var(--brand); }

  .app { min-height: 100dvh; }
  .boot, .center-msg {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
  }

  /* ——— Auth ——— */
  .auth {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
    background:
      radial-gradient(1200px 500px at 50% -10%, #149184 0%, #084741 55%, #072e2b 100%);
  }
  .auth-card {
    width: 100%;
    max-width: 420px;
    padding: 28px 24px 24px;
    background: var(--card);
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  }
  .brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: var(--brand-dark);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 0.04em;
    margin-bottom: 14px;
  }
  h1, h2, h3 { margin: 0 0 6px; letter-spacing: -0.02em; }
  .auth h1 { font-size: 1.45rem; }
  .lede { color: var(--muted); margin: 0 0 20px; font-size: 0.95rem; }

  label { display: block; font-size: 0.8rem; font-weight: 650; margin: 0 0 6px; color: var(--ink); }
  .field { margin-bottom: 14px; }
  input[type="text"], input[type="email"], input[type="password"], input[type="date"],
  input[type="time"], input[type="number"], input[type="tel"], input[type="file"],
  select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 12px;
    background: #fff;
    color: var(--ink);
  }
  textarea { min-height: 120px; resize: vertical; }
  input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--brand-2);
    outline-offset: 1px;
    border-color: var(--brand);
  }

  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 700;
    background: var(--brand);
    color: #fff;
    transition: transform .08s ease, opacity .15s ease;
  }
  .btn:active { transform: scale(0.98); }
  .btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
  .btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
  .btn-ghost { background: transparent; color: var(--brand); }
  .btn-danger { background: var(--absent); color: #fff; }
  .btn-ok { background: var(--present); color: #fff; }
  .btn-block { width: 100%; }
  .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
  .btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.86rem; }

  .alert { border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; font-size: 0.92rem; }
  .alert-error { background: var(--absent-bg); color: var(--absent); }
  .alert-ok { background: var(--present-bg); color: var(--present); }
  .alert-warn { background: var(--late-bg); color: var(--late); }
  .notice {
    max-height: 40vh; overflow: auto; white-space: pre-wrap;
    background: var(--bg); border: 1px solid var(--line);
    border-radius: 12px; padding: 12px; font-size: 0.86rem; margin-bottom: 14px;
  }
  .check { display: flex; align-items: flex-start; gap: 8px; font-size: 0.92rem; margin-bottom: 14px; }
  .check input { margin-top: 3px; }

  /* ——— Staff phone shell ——— */
  .shell { display: flex; flex-direction: column; min-height: 100dvh; }
  .topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: calc(12px + var(--safe-top)) 16px 12px;
    background: var(--brand-dark); color: #fff;
  }
  .topbar h1 { font-size: 1rem; margin: 0; }
  .topbar .sub { font-size: 0.75rem; opacity: 0.8; }
  .topbar .who { text-align: right; font-size: 0.78rem; opacity: 0.92; }
  .topbar .who strong { display: block; font-size: 0.9rem; }
  .content {
    flex: 1;
    padding: 16px 16px var(--nav-h);
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
  }

  .clock-hero { text-align: center; padding: 10px 8px 4px; }
  .clock-time {
    font-variant-numeric: tabular-nums;
    font-size: clamp(3rem, 14vw, 4.2rem);
    font-weight: 760;
    letter-spacing: -0.04em;
    line-height: 1;
    color: var(--brand-dark);
  }
  .clock-date { color: var(--muted); margin-top: 8px; font-weight: 600; }
  .shift-chip, .status-pill, .chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border-radius: 999px;
    font-size: 0.8rem; font-weight: 700;
  }
  .shift-chip { margin-top: 12px; background: var(--brand-soft); color: var(--brand-dark); }
  .status-pill { margin-top: 12px; background: var(--brand-soft); color: var(--brand-dark); }
  .status-pill.in, .chip.present, .chip.ok { background: var(--present-bg); color: var(--present); }
  .status-pill.late, .chip.late, .chip.warn, .chip.soon, .chip.upcoming { background: var(--late-bg); color: var(--late); }
  .status-pill.out { background: var(--leave-bg); color: var(--leave); }
  .chip.absent, .chip.bad, .chip.expired, .chip.critical { background: var(--absent-bg); color: var(--absent); }
  .chip.onleave, .chip.pending { background: var(--leave-bg); color: var(--leave); }
  .chip.ot, .chip.approved { background: var(--ot-bg); color: var(--ot); }

  .clock-cta { margin: 20px 0 8px; }
  .btn-clock {
    width: 100%;
    min-height: 72px;
    border-radius: 20px;
    font-size: 1.35rem;
    letter-spacing: 0.02em;
    box-shadow: 0 12px 24px rgba(12, 107, 99, 0.28);
  }
  .btn-clock.out {
    background: var(--leave);
    box-shadow: 0 12px 24px rgba(29, 78, 216, 0.25);
  }
  .flags { margin: 8px 0 0; font-weight: 700; }
  .flags.late { color: var(--late); }
  .flags.ok { color: var(--present); }

  .panel, .card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 14px;
  }
  .gps { font-size: 0.85rem; color: var(--muted); margin: 0 0 8px; }
  .gps.ok { color: var(--present); }
  .gps.bad { color: var(--absent); }
  .selfie-box { display: flex; align-items: center; gap: 12px; margin: 8px 0 0; }
  .selfie-box img, .selfie-box .ph {
    width: 68px; height: 68px; border-radius: 14px; object-fit: cover;
    background: var(--bg); border: 1px dashed var(--line);
    display: grid; place-items: center; color: var(--muted); font-size: 0.72rem; text-align: center;
  }
  .punch-list, .meta-list { list-style: none; margin: 0; padding: 0; }
  .punch-list li, .meta-row {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.95rem;
  }
  .muted { color: var(--muted); }
  .small { font-size: 0.85rem; }

  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px 8px calc(6px + var(--safe-bottom));
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
  .nav button {
    background: none; border: 0; color: var(--muted);
    min-height: 52px; border-radius: 12px;
    font-size: 0.7rem; font-weight: 750;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  }
  .nav button .ico { font-size: 1.15rem; line-height: 1; }
  .nav button.active { color: var(--brand-dark); background: var(--brand-soft); }

  .balances { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
  .bal {
    background: var(--card); border: 1px solid var(--line); border-radius: 14px;
    padding: 12px 8px; text-align: center; box-shadow: var(--shadow);
  }
  .bal .n { font-size: 1.4rem; font-weight: 800; color: var(--brand-dark); line-height: 1; }
  .bal .t { font-size: 0.72rem; color: var(--muted); font-weight: 700; margin-top: 4px; }

  .cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
  .cal .hd { text-align: center; font-size: 0.7rem; font-weight: 700; color: var(--muted); padding: 4px 0; }
  .cal .day {
    aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center;
    font-size: 0.82rem; background: #fff; border: 1px solid transparent;
  }
  .cal .day.rest { color: var(--muted); background: #f3f5f5; }
  .cal .day.holiday { background: var(--late-bg); color: var(--late); font-weight: 700; }
  .cal .day.leave { background: var(--leave-bg); color: var(--leave); font-weight: 700; }
  .cal .day.today { border-color: var(--brand); font-weight: 800; }

  table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
  th, td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
  th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
  .table-wrap { overflow-x: auto; }
  .toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
  .stack { display: grid; gap: 10px; }
  .hidden { display: none !important; }

  /* ——— Desktop dashboard ——— */
  @media (min-width: 960px) {
    body.desk { background: #e8eeec; }
    body.desk .shell { flex-direction: row; min-height: 100dvh; }
    body.desk .sidebar {
      display: flex;
      flex-direction: column;
      width: var(--sidebar-w);
      background: var(--brand-dark);
      color: #fff;
      padding: 22px 14px;
      position: sticky; top: 0; height: 100dvh;
    }
    body.desk .sidebar .logo { font-weight: 800; letter-spacing: -0.02em; padding: 0 10px 18px; }
    body.desk .sidebar button {
      background: transparent; border: 0; color: rgba(255,255,255,0.78);
      text-align: left; padding: 10px 12px; border-radius: 10px; font-weight: 650;
    }
    body.desk .sidebar button.active, body.desk .sidebar button:hover {
      background: rgba(255,255,255,0.12); color: #fff;
    }
    body.desk .sidebar .side-user { margin-top: auto; padding: 14px 10px 0; font-size: 0.8rem; opacity: 0.9; }
    body.desk .topbar, body.desk .nav { display: none; }
    body.desk .content {
      max-width: none;
      padding: 28px 32px;
    }
  }
  .sidebar { display: none; }

  .stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
  @media (min-width: 960px) {
    .stats { grid-template-columns: repeat(4, 1fr); }
  }
  .stat { padding: 16px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); }
  .stat .n { font-size: 2rem; font-weight: 800; line-height: 1; }
  .stat .t { color: var(--muted); font-size: 0.82rem; font-weight: 700; margin-top: 4px; }
  .stat.present .n { color: var(--present); }
  .stat.late .n { color: var(--late); }
  .stat.absent .n { color: var(--absent); }
  .stat.onleave .n { color: var(--leave); }

  .grid-2 { display: grid; gap: 14px; }
  @media (min-width: 960px) { .grid-2 { grid-template-columns: 1.2fr 1fr; } }

  .approvals .row {
    display: flex; justify-content: space-between; gap: 10px; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--line);
  }
  .org-wrap { overflow: auto; background: #fff; border-radius: 16px; padding: 12px; }
  .google-visualization-orgchart-node, .org-node {
    background: var(--brand-soft) !important;
    border: 1px solid var(--brand) !important;
    border-radius: 10px !important;
    color: var(--brand-dark) !important;
    font-family: inherit !important;
  }

  .me-head { display: flex; gap: 14px; align-items: center; }
  .avatar {
    width: 56px; height: 56px; border-radius: 16px;
    background: var(--brand-dark); color: #fff;
    display: grid; place-items: center; font-weight: 800; font-size: 1.1rem;
  }
