  :root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface2: #f0f1f4;
    --border: #e4e6eb;
    --border2: #d0d3da;
    --text: #1a1d23;
    --muted: #6b7280;
    --accent: #2563eb;
    --accent-dim: rgba(37,99,235,0.08);
    --accent-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-dim: rgba(220,38,38,0.08);
    --success: #16a34a;
    --success-dim: rgba(22,163,74,0.08);
    --warning: #d97706;
    --warning-dim: rgba(217,119,6,0.08);
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  }

  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

  body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
  }

  .screen {
    display: none;
    width: 100%;
    max-width: 420px;
    min-height: 100dvh;
    padding: 24px 20px 32px;
    flex-direction: column;
    animation: fadeUp 0.25s ease both;
  }
  .screen.active { display: flex; }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── Logo / header ── */
  .logo {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--accent);
  }
  .logo span { color: var(--muted); font-weight: 400; }

  .page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
  }

  .back-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: var(--shadow);
  }
  .back-btn:hover { color: var(--text); border-color: var(--border2); }

  /* ── Greeting ── */
  .greeting { margin-bottom: 28px; }
  .greeting h1 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.5px;
    color: var(--text);
  }
  .greeting p {
    color: var(--muted);
    font-size: 14px;
    margin-top: 5px;
    font-weight: 400;
  }

  /* ── Employee list ── */
  .emp-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
    flex: 1;
  }

  .emp-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: var(--shadow);
  }
  .emp-card:active { transform: scale(0.985); }
  .emp-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

  .emp-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--accent-dim);
    border: 1.5px solid rgba(37,99,235,0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 600; color: var(--accent);
    flex-shrink: 0;
  }

  .emp-info { flex: 1; min-width: 0; }
  .emp-name { font-size: 14px; font-weight: 600; color: var(--text); }
  .emp-role { font-size: 12px; color: var(--muted); margin-top: 1px; }

  .emp-status {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 9px;
    border-radius: 20px;
    flex-shrink: 0;
  }
  .emp-status.in  { background: var(--success-dim); color: var(--success); border: 1px solid rgba(22,163,74,0.2); }
  .emp-status.out { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }
  .emp-status.done { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(37,99,235,0.2); }

  /* ── PIN screen ── */
  .pin-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .pin-employee {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }

  .pin-dots {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 32px;
  }
  .pin-dot {
    width: 13px; height: 13px;
    border-radius: 50%;
    border: 2px solid var(--border2);
    transition: all 0.15s;
  }
  .pin-dot.filled {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.15);
  }
  .pin-dot.error {
    background: var(--danger);
    border-color: var(--danger);
    animation: shake 0.35s ease;
  }

  @keyframes shake {
    0%,100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
  }

  .numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .num-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 17px 10px;
    font-family: 'Inter', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
  }
  .num-btn:active { background: var(--surface2); transform: scale(0.94); box-shadow: none; }
  .num-btn.del { font-size: 15px; color: var(--muted); }
  .num-btn.empty { opacity: 0; pointer-events: none; }

  .pin-hint { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; }

  .pin-submit-btn {
    width: 100%;
    margin-top: 18px;
    padding: 15px;
    border-radius: var(--radius);
    background: var(--accent);
    color: #fff;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
    transition: all 0.15s;
    display: none;
  }
  .pin-submit-btn.visible { display: block; }
  .pin-submit-btn:active { transform: scale(0.97); }

  .loading-overlay {
    position: fixed; inset: 0;
    background: rgba(245,246,248,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    z-index: 200;
    font-size: 14px;
    color: var(--muted);
    font-weight: 500;
  }
  .loading-overlay.show { display: flex; }
  .spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* ── Dashboard ── */
  .dash-header { margin-bottom: 20px; }
  .dash-header h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
  .dash-header .date-str { font-size: 13px; color: var(--muted); margin-top: 3px; }

  .time-card {
    background: var(--accent);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
    box-shadow: 0 4px 14px rgba(37,99,235,0.25);
  }
  .time-card-label {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    font-weight: 500;
  }
  .time-card-value {
    font-size: 28px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.5px;
  }
  .time-card-value.muted { color: rgba(255,255,255,0.5); font-size: 26px; }
  .time-card-sub { font-size: 12px; color: rgba(255,255,255,0.75); margin-top: 5px; }

  .stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
  }

  .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
  }
  .stat-label {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 5px;
    font-weight: 500;
  }
  .stat-value { font-size: 20px; font-weight: 700; }
  .stat-value.green { color: var(--success); }
  .stat-value.yellow { color: var(--warning); }
  .stat-value.red { color: var(--danger); }
  .stat-value.accent { color: var(--accent); }

  /* ── CTA buttons ── */
  .cta-btn {
    width: 100%;
    padding: 16px;
    border-radius: var(--radius);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    margin-bottom: 10px;
    letter-spacing: -0.1px;
  }
  .cta-btn:active { transform: scale(0.97); }
  .cta-btn:disabled { opacity: 0.4; cursor: not-allowed; }

  .cta-btn.primary {
    background: var(--accent);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
  }
  .cta-btn.primary:hover { background: var(--accent-dark); }
  .cta-btn.danger {
    background: var(--danger);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(220,38,38,0.3);
  }
  .cta-btn.ghost {
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .cta-btn.ghost:hover { color: var(--text); border-color: var(--border2); }

  /* ── History ── */
  .history-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 12px;
    flex: 1;
    overflow-y: auto;
  }

  .history-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
  }

  .history-date { font-size: 13px; font-weight: 600; }
  .history-times { font-size: 11px; color: var(--muted); margin-top: 2px; }
  .history-salary { font-size: 13px; font-weight: 600; color: var(--success); }
  .history-salary.absent { color: var(--danger); }

  /* ── Admin screen ── */
  .admin-section { margin-bottom: 24px; }
  .section-title {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
    font-weight: 600;
  }

  .input-group { margin-bottom: 10px; }
  .input-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 5px;
    display: block;
  }
  .text-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow);
  }
  .text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
  .text-input::placeholder { color: #9ca3af; }

  .salary-prefix { position: relative; }
  .salary-prefix .prefix {
    position: absolute;
    left: 13px; top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 14px;
    pointer-events: none;
  }
  .salary-prefix .text-input { padding-left: 28px; }

  .salary-details { margin-top:10px; padding-top:10px; border-top:1px solid rgba(255,255,255,0.18); font-size:12px; line-height:1.5; opacity:0.9; text-align:left; }

  .emp-admin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 7px;
    box-shadow: var(--shadow);
  }
  .emp-admin-info { flex: 1; }
  .emp-admin-name { font-size: 14px; font-weight: 600; }
  .emp-admin-rate { font-size: 12px; color: var(--muted); margin-top: 1px; }
  .emp-admin-actions { display: flex; gap: 6px; }
  .emp-delete-btn {
    background: var(--danger-dim);
    border: 1px solid rgba(220,38,38,0.2);
    color: var(--danger);
    padding: 5px 11px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
  }
  .emp-delete-btn:hover { background: rgba(220,38,38,0.15); }

  /* Manual attendance button */
  .emp-manual-btn {
    background: var(--warning-dim);
    border: 1px solid rgba(217,119,6,0.2);
    color: var(--warning);
    padding: 5px 11px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
  }
  .emp-manual-btn:hover { background: rgba(217,119,6,0.15); }

  /* Admin link on login */
  .admin-link {
    text-align: center;
    margin-top: auto;
    padding-top: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
  }
  .admin-link:hover { color: var(--accent); }

  /* Toast */
  .toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--text);
    border-radius: 100px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    z-index: 999;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
    white-space: nowrap;
    box-shadow: var(--shadow-md);
  }
  .toast.show { transform: translateX(-50%) translateY(0); }

  .live-clock { font-size: 13px; color: var(--muted); font-weight: 500; }

  /* Section divider */
  .divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
  }

  /* Scrollbar */
  ::-webkit-scrollbar { width: 4px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

  /* Modal overlay for manual attendance */
  .modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: flex-end;
    justify-content: center;
    padding: 20px;
  }
  .modal-overlay.open { display: flex; }
  .modal-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 22px 20px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
    animation: slideUp 0.25s ease;
  }
  @keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
  }
  .modal-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
  .modal-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
  .modal-actions { display: flex; gap: 8px; margin-top: 16px; }
  .modal-actions .cta-btn { margin-bottom: 0; flex: 1; }

  /* ── Calendar day tooltip ── */
  .cal-tip {
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1d23;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
    padding: 6px 9px;
    border-radius: 7px;
    pointer-events: none;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    opacity: 0;
    transition: opacity 0.12s;
  }
  .cal-tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1a1d23;
  }
  .cal-cell { position: relative; }
  .cal-cell:hover .cal-tip { opacity: 1; }
