:root {
  --primary: #f9741e;
  --primary-dark: #ea580c;
  --gradient: linear-gradient(135deg, #ff9248 0%, #f4511e 55%, #e53935 100%);
  --teal: #14b8a6;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #ca8a04;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top, 0) 16px 14px;
  padding-top: calc(env(safe-area-inset-top, 0) + 14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.topbar h1 { margin: 0; font-size: 1.25rem; font-weight: 700; }

.user-box { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; flex-shrink: 0; }
.icon-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--primary);
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  flex-shrink: 0;
}
.icon-btn .count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--primary);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--primary);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.95rem;
  font-family: inherit;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0;
}
.avatar-circle .avatar-img { width: 100%; height: 100%; object-fit: cover; }

#avatar-preview, #emp-photo-preview, #signup-photo-preview {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--primary);
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 auto;
}
.settings-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-avatar.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--primary);
  font-size: 1.3rem;
  font-weight: 700;
}

body.no-nav .bottom-nav { display: none; }
body.no-nav .app { padding-bottom: 16px; }

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 20px 4px;
}
.login-card { width: 100%; max-width: 360px; }
.login-card .logo { display: block; width: 96px; height: 96px; object-fit: contain; margin: 0 auto 6px; }
.login-card h2 { text-align: center; margin: 0 0 20px; font-size: 1.15rem; }
.login-hint { text-align: center; font-size: 0.75rem; color: var(--muted); margin-top: 14px; }

.payslip-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.payslip-row:last-child { border-bottom: none; }
.payslip-row.total { font-weight: 700; font-size: 1.15rem; color: var(--primary); padding-top: 14px; }
.payslip-header { text-align: center; margin-bottom: 12px; }
.payslip-header .month { font-size: 1.1rem; font-weight: 700; }
.payslip-header .sub { font-size: 0.8rem; color: var(--muted); }

.segmented {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 12px;
  gap: 4px;
}
.seg-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  border-radius: 9px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  font-family: inherit;
}
.seg-btn.active { background: var(--primary); color: white; }

.selfie-row { display: flex; gap: 10px; margin-top: 12px; }
.selfie-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.photo-modal-img {
  width: 100%;
  border-radius: 12px;
  display: block;
}

.app {
  padding: 16px;
  padding-bottom: 90px;
  max-width: 720px;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 10px 4px calc(env(safe-area-inset-bottom, 0) + 10px);
  z-index: 20;
}
.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
}
.nav-btn .icon { font-size: 1.35rem; }
.nav-btn .label { display: none; }
.nav-btn.active { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(249,116,30,0.35); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  border: 1px solid var(--border);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}
.stat-card .value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 20px 0 10px;
  color: var(--text);
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.list-item:last-child { border-bottom: none; }
.list-item .name { font-weight: 600; }
.list-item .sub { font-size: 0.8rem; color: var(--muted); }
.list-item.stacked {
  flex-direction: column;
  align-items: stretch;
}
.list-item.stacked .action-row { margin-top: 4px; flex-wrap: wrap; }
.list-item.stacked .action-row .btn { flex: 1 1 30%; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge.active { background: #dcfce7; color: var(--success); }
.badge.inactive { background: #f1f5f9; color: var(--muted); }
.badge.pending { background: #fef3c7; color: var(--warning); }
.badge.approved { background: #dcfce7; color: var(--success); }
.badge.rejected { background: #fee2e2; color: var(--danger); }
.badge.verbal { background: #fef3c7; color: var(--warning); }
.badge.written { background: #ffedd5; color: #c2410c; }
.badge.final { background: #fee2e2; color: var(--danger); }

.online-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 0 3px #dcfce7;
}

.more-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.more-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
}
.more-tile .icon { font-size: 1.8rem; }

.recognition-card { padding: 14px 16px; }
.recognition-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.recognition-head > div:nth-child(2) { flex: 1; }
.recognition-icon { font-size: 1.6rem; }
.recognition-msg {
  margin-top: 10px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  width: 100%;
}
.btn:active { background: var(--primary-dark); }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.small { width: auto; padding: 7px 12px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.4; }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(env(safe-area-inset-bottom, 0) + 74px);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.6rem;
  box-shadow: 0 4px 12px rgba(37,99,235,0.4);
  z-index: 15;
}

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 1rem;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
}
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
  font-size: 0.9rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  display: flex;
  align-items: flex-end;
  z-index: 30;
}
.modal-sheet {
  background: var(--card);
  width: 100%;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px calc(env(safe-area-inset-bottom, 0) + 20px);
  max-height: 88vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 { margin: 0; font-size: 1.1rem; }
.close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--muted);
  padding: 4px 8px;
}

.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0) + 14px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.85rem;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }

.action-row { display: flex; gap: 8px; margin-top: 8px; }
.shortcuts-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.shortcuts-row .btn.small { flex: 1 1 calc(50% - 4px); white-space: nowrap; }

/* ---------- Dashboard hero ---------- */
.hero {
  background: var(--card);
  color: var(--text);
  margin: -16px -16px 0;
  padding: 6px 20px 28px;
  border-radius: 0 0 26px 26px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}
.hero-greeting {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 10px 0 16px;
  color: var(--text);
}
.status-card {
  background: #fff7ed;
  color: #1e293b;
  border: 1px solid #ffd9ae;
  border-radius: 18px;
  padding: 18px 20px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(249,116,30,0.12);
  position: relative;
}
.status-card .label { font-size: 0.82rem; color: #9a6a3d; margin-bottom: 6px; }
.status-card .value { font-size: 1.55rem; font-weight: 800; letter-spacing: 0.5px; color: var(--primary-dark); }
.status-card .sub-row {
  display: flex;
  justify-content: space-around;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #ffe4c2;
}
.status-card .sub-row .t { font-size: 1.05rem; font-weight: 700; color: #1e293b; }
.status-card .sub-row .l { font-size: 0.68rem; color: #a1795690; margin-top: 2px; }
.hero-dots { display: flex; justify-content: center; gap: 5px; margin-top: 0; padding-top: 12px; }
.hero-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.hero-dots span.active { background: var(--primary); width: 16px; border-radius: 4px; }

/* ---------- Chip row ---------- */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 6px;
  margin: 16px 0 2px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

/* ---------- Icon grid ---------- */
.icon-grid-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(2, auto);
  gap: 16px 14px;
  overflow-x: auto;
  padding: 8px 2px 14px;
  margin-bottom: 4px;
  scrollbar-width: none;
}
.icon-grid-scroll::-webkit-scrollbar { display: none; }
.icon-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 66px;
  background: none;
  border: none;
  font-family: inherit;
}
.icon-tile .circle {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 10px rgba(249,116,30,0.32);
}
.icon-tile .circle.teal { background: var(--teal); box-shadow: 0 4px 10px rgba(20,184,166,0.32); }
.icon-tile .circle .tile-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.icon-tile .label {
  font-size: 0.68rem;
  color: var(--text);
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

/* ---------- Section header / carousel ---------- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 0 10px;
}
.section-header h3 { margin: 0; font-size: 0.95rem; font-weight: 700; }
.link-btn {
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 700;
  background: none;
  border: none;
  font-family: inherit;
}
.mini-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.mini-list-item:last-child { border-bottom: none; }
.mini-list-item .emoji { font-size: 1.3rem; }
.mini-list-item .txt { font-size: 0.85rem; }
.mini-list-item .txt .n { font-weight: 600; }
.mini-list-item .txt .m { color: var(--muted); font-size: 0.78rem; margin-top: 1px; }

.notif-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 13px 2px;
  font-family: inherit;
  text-align: left;
  color: var(--text);
}
.notif-item:last-child { border-bottom: none; }
.notif-item .emoji { font-size: 1.25rem; flex-shrink: 0; }
.notif-item .txt { flex: 1; font-size: 0.86rem; font-weight: 600; }
.notif-item .chev { color: var(--muted); font-size: 1.1rem; }

.leave-balance-bar {
  margin-top: 10px;
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}
.leave-balance-bar .fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
}

/* ---------- Reports ---------- */
.report-nav-list .list-item { cursor: pointer; }
.report-table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.8rem;
  white-space: nowrap;
}
.data-table th, .data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}
.data-table td.tal, .data-table th.tal { text-align: left; }
.data-table thead th {
  background: var(--bg);
  color: var(--text);
  font-weight: 700;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tr.totals-row td { font-weight: 700; background: var(--bg); }

@media print {
  .topbar, .bottom-nav, .fab, #modal-root, .no-print, .toast { display: none !important; }
  body, .app { padding: 0 !important; margin: 0 !important; max-width: 100% !important; background: #fff !important; }
  .report-table-wrap { border: none; overflow: visible; }
  .data-table { font-size: 10px; }
  .data-table th, .data-table td { padding: 4px 6px; }
  @page { size: landscape; margin: 10mm; }

  /* Printing a payslip modal: show just the modal content, full-page, no backdrop/chrome. */
  body:has(.payslip-print-area) #modal-root {
    display: block !important;
    position: static !important;
  }
  body:has(.payslip-print-area) .modal-overlay {
    position: static !important;
    background: none !important;
    padding: 0 !important;
    display: block !important;
  }
  body:has(.payslip-print-area) .modal-sheet {
    box-shadow: none !important;
    max-height: none !important;
    max-width: 100% !important;
    border-radius: 0 !important;
  }
  body:has(.payslip-print-area) .modal-header {
    display: none !important;
  }
  .print-company { display: none; font-weight: 800; font-size: 1.1rem; color: var(--primary-dark); margin-bottom: 4px; }
  body:has(.payslip-print-area) .print-company { display: block; }
}

