/* ===== CSS Variables ===== */
:root {
  --primary: #0D3B66;
  --primary-light: #1A5C8A;
  --primary-dark: #072540;
  --gold: #C8973E;
  --gold-light: #F5E6CA;
  --gold-dark: #A67B2E;
  --success: #2D8B4E;
  --error: #DC2626;
  --white: #FFFFFF;
  --bg: #F0F4F8;
  --bg-card: #FFFFFF;
  --text: #1A1A2E;
  --text-light: #64748B;
  --border: #E2E8F0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.08), 0 4px 10px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 50px rgba(0,0,0,.1);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-heading: 'Inter', system-ui, -apple-system, sans-serif;
  --font-body: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset (targeted, not universal) ===== */
html {
  box-sizing: border-box;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; height: auto; display: block; }

/* ===== Background decoration (desktop only) ===== */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}
.bg-orb--1 {
  width: 500px; height: 500px;
  background: var(--primary);
  top: -150px; right: -150px;
  animation: orbFloat 10s ease-in-out infinite;
}
.bg-orb--2 {
  width: 350px; height: 350px;
  background: var(--gold);
  bottom: -100px; left: -100px;
  animation: orbFloat 12s ease-in-out infinite reverse;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(40px, -40px) scale(1.06); }
  66% { transform: translate(-25px, 25px) scale(0.94); }
}

/* ===== Main container ===== */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* ===== Typography ===== */
h1, h2, h3, h4 { font-family: var(--font-heading); margin: 0; line-height: 1.25; }
h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
h3 { font-size: 18px; font-weight: 600; }
p { margin: 0; }

/* ===== Card ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ===== Form elements ===== */
label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  padding: 12px 16px;
  margin: 6px 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 59, 102, 0.1);
}
input::placeholder, textarea::placeholder { color: #94A3B8; }

/* ===== Buttons ===== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.3;
  min-height: 46px;
  background: var(--primary);
  color: var(--white);
}
button:hover, .btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
button:active, .btn:active { transform: translateY(0) scale(0.98); }
button:disabled, .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
}

.btn { width: 100%; }
.btn-primary { background: var(--primary); }
.btn-gold { background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%); }
.btn-secondary { background: #64748B; color: var(--white); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: rgba(13, 59, 102, 0.04); }
.btn-sm { width: auto; padding: 8px 16px; font-size: 13px; min-height: 36px; }

/* ===== Table (admin) ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 8px 0;
}
th, td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
th { background: #F8FAFC; font-weight: 600; font-size: 13px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }
td button, td .btn { width: auto; padding: 4px 10px; font-size: 13px; min-height: 30px; }

/* ===== Error text ===== */
.err {
  color: var(--error);
  font-size: 14px;
  margin-top: 2px;
  min-height: 20px;
}
.err:not(:empty) { animation: shake 0.4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ===== Toast notification ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  background: #1E293B;
  color: var(--white);
  padding: 14px 28px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  box-shadow: var(--shadow-xl);
  transition: transform var(--transition);
  max-width: 90vw;
  text-align: center;
  pointer-events: none;
}
.toast--show { transform: translateX(-50%) translateY(0); }
.toast--error { background: var(--error); }
.toast--success { background: var(--success); }

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Hidden utility ===== */
.hidden { display: none !important; }

/* ================================================================ */
/*  LANDING PAGE                                                     */
/* ================================================================ */

.landing-logo-wrap {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  padding: 16px;
  animation: fadeInScale 0.7s ease-out;
}
.landing-logo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
  display: block;
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.landing-hero {
  text-align: center;
  margin-bottom: 28px;
}
.landing-title {
  text-align: center;
  color: var(--primary-dark);
  margin-bottom: 2px;
  animation: fadeInUp 0.6s ease-out 0.1s both;
  font-size: 30px;
}
.landing-subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2.5px;
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

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

.landing-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: fadeInUp 0.6s ease-out 0.3s both;
}

.landing-cta-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--gold-light);
  color: var(--gold);
  margin: 0 auto 16px;
  font-size: 24px;
}

.landing-features {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 20px 0 24px;
  animation: fadeInUp 0.6s ease-out 0.5s both;
}
.landing-feature {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-light);
  font-weight: 500;
}
.landing-feature-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #EFF6FF;
  color: var(--primary);
  flex-shrink: 0;
}
.landing-feature-icon svg { width: 14px; height: 14px; }

.landing-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 20px 0 8px;
  border-top: 1px solid var(--border);
  animation: fadeInUp 0.6s ease-out 0.7s both;
}
.landing-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  text-align: center;
}
.landing-step-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(13, 59, 102, 0.25);
}
.landing-step-label {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 600;
}
.landing-step-arrow {
  color: #CBD5E1;
  font-size: 22px;
  margin-bottom: 16px;
  font-weight: 300;
}

.landing-footer {
  text-align: center;
  padding: 24px 0 8px;
  color: var(--text-light);
  font-size: 12px;
  line-height: 1.8;
}
.landing-footer strong { color: var(--text); }

/* ================================================================ */
/*  APP SCREEN                                                       */
/* ================================================================ */

.app-screen {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* ===== App header ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  margin-bottom: 16px;
  gap: 12px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.app-header-logo {
  width: 44px; height: 44px;
  border-radius: 50%;
  object-fit: contain;
  border: 2px solid var(--white);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  background: var(--white);
  padding: 4px;
}
.app-header-title {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary-dark);
  font-family: var(--font-heading);
}

/* ===== Progress dots ===== */
.progress-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}
.progress-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #E2E8F0;
  transition: all var(--transition);
  position: relative;
}
.progress-dot--active {
  background: var(--primary);
  transform: scale(1.35);
  box-shadow: 0 0 0 3px rgba(13, 59, 102, 0.12);
}
.progress-dot--done {
  background: var(--success);
}

/* ===== Step cards ===== */
.step-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  animation: fadeInUp 0.35s ease-out;
}
.step-card h2 {
  text-align: center;
  color: var(--primary-dark);
  margin-bottom: 4px;
}
.step-card .step-desc {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ===== Camera ===== */
.camera-preview {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #0F172A;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  position: relative;
}
.camera-preview video,
.camera-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-actions {
  display: flex;
  gap: 10px;
}
.camera-actions button { flex: 1; }

/* ===== Month selector ===== */
.month-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 20px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.month-selector::-webkit-scrollbar { display: none; }
.month-pill {
  padding: 9px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.month-pill:hover { border-color: var(--primary-light); color: var(--primary); }
.month-pill--active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
  box-shadow: 0 2px 10px rgba(13, 59, 102, 0.3);
}

/* ===== Payslip image ===== */
.payslip-wrapper {
  background: #F8FAFC;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 4px 0 16px;
  border: 1px solid var(--border);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.payslip-img {
  width: 100%;
  display: block;
  cursor: pointer;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.payslip-img--loading { opacity: 0; transform: scale(0.96); }
.payslip-img--loaded { opacity: 1; transform: scale(1); }

/* Skeleton loader */
.skeleton {
  width: 100%;
  aspect-ratio: 3/4;
  background: linear-gradient(110deg, #F1F5F9 30%, #E2E8F0 50%, #F1F5F9 70%);
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: var(--radius);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== Feedback section ===== */
.feedback-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: none;
  border: 1.5px dashed #CBD5E1;
  border-radius: var(--radius);
  color: var(--text-light);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.feedback-toggle:hover { border-color: var(--primary); color: var(--primary); background: #F8FAFC; }
.feedback-box { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== Zoom overlay ===== */
.zoom-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.zoom-overlay img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

/* ===== Section divider ===== */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--text-light);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ================================================================ */
/*  RESPONSIVE                                                       */
/* ================================================================ */

/* Desktop: centered card with breathing room */
@media (min-width: 768px) {
  body { padding: 32px; }
  .landing-logo-wrap { width: 150px; height: 150px; }
  .landing-title { font-size: 34px; }
  .landing-card, .step-card { padding: 36px 32px; }
}

/* Tablet / Phablet */
@media (max-width: 767px) {
  body { padding: 12px; }
  .app-container { max-width: 100%; }
  .landing-logo-wrap { width: 110px; height: 110px; padding: 12px; }
  .landing-title { font-size: 26px; }
  .landing-subtitle { font-size: 12px; letter-spacing: 1.5px; }
  .landing-card { padding: 24px 20px; border-radius: var(--radius-xl); }
  .landing-hero { margin-bottom: 20px; }
  .step-card { padding: 24px 20px; border-radius: var(--radius-lg); }
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  .app-header { padding: 10px 14px; gap: 8px; margin-bottom: 12px; }
  .app-header-logo { width: 38px; height: 38px; padding: 3px; }
  .app-header-title { font-size: 14px; }
  input, textarea, select { padding: 11px 14px; font-size: 16px; }
  button, .btn { padding: 11px 20px; font-size: 15px; min-height: 44px; }
  .bg-orb { display: none; }
  .landing-cta-icon { width: 40px; height: 40px; font-size: 20px; margin-bottom: 12px; }
  .landing-support { padding: 16px 0 !important; }
  .landing-footer { padding: 16px 0 8px; }
  #support-box { padding: 12px 0; }
  .camera-preview { aspect-ratio: 3/4; }
  .month-pill { padding: 7px 16px; font-size: 13px; }
}

/* Small phones */
@media (max-width: 380px) {
  body { padding: 0; background: #fff; }
  .landing-logo-wrap { width: 96px; height: 96px; padding: 10px; margin-bottom: 16px; }
  .landing-title { font-size: 24px; }
  .landing-subtitle { font-size: 11px; letter-spacing: 1px; }
  .landing-card { padding: 20px 16px; border-radius: var(--radius-lg); box-shadow: none; border: none; }
  .landing-hero { margin-bottom: 16px; }
  .step-card { padding: 20px 16px; border-radius: var(--radius); box-shadow: none; border: none; }
  .app-container { max-width: 100%; }
  .app-header { padding: 8px 12px; border-radius: 0; box-shadow: none; border: none; border-bottom: 1px solid var(--border); margin-bottom: 0; }
  h1 { font-size: 22px; }
  h2 { font-size: 19px; }
  input, textarea, select { padding: 10px 14px; margin: 4px 0 8px; }
  button, .btn { padding: 11px 16px; font-size: 14px; min-height: 44px; border-radius: 10px; }
  .payslip-wrapper { border-radius: 0; margin: 0 -16px; border-left: none; border-right: none; }
  .feedback-toggle { font-size: 12px; padding: 10px; }
  .landing-cta-icon { width: 36px; height: 36px; font-size: 18px; }
  .camera-actions { flex-direction: column; }
}
