@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-deeper: #1e1b4b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; overflow: hidden; font-family: 'Poppins', sans-serif;
  background: var(--bg); color: var(--text); font-size: 12px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button, input, select, textarea { font-family: inherit; font-size: 13px; }
.screen { position: fixed; inset: 0; display: none; flex-direction: column; overflow: hidden; }
.screen.active { display: flex; }
.page { display: none; flex-direction: column; min-height: 100%; }
.page.active { display: flex; }

#gpsCheckScreen, #loginScreen { background: linear-gradient(160deg, var(--primary-deeper), var(--primary)); color: #fff; }
#gpsCheckScreen { align-items: center; justify-content: center; text-align: center; padding: 24px; }
.gps-box { max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gps-icon-circle { width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,0.16); display: flex; align-items: center; justify-content: center; }
.login-header { text-align: center; padding: 24px 16px 14px; position: relative; }
.login-card { flex: 1; background: #fff; color: var(--text); border-radius: 22px 22px 0 0; padding: 22px 18px; overflow-y: auto; }
.field-group { position: relative; margin-bottom: 12px; }
.field-group .material-icons.f-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 18px; pointer-events: none; }
.input { width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px; min-height: 42px; background: #fff; outline: none; }
.input.with-icon { padding-left: 36px; }
.input:focus { border-color: var(--primary); }
.btn { width: 100%; min-height: 42px; border: none; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }
.btn-light { background: #f1f5f9; color: #334155; }

.top-header { height: 48px; background: var(--primary); color: #fff; display: flex; align-items: center; padding: 0 8px; flex-shrink: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.header-title { flex: 1; text-align: center; font-weight: 700; font-size: 14px; }
.icon-btn { width: 32px; height: 32px; border-radius: 50%; border: none; background: rgba(255,255,255,0.16); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.content-area { flex: 1; overflow-y: auto; padding-bottom: 66px; -webkit-overflow-scrolling: touch; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: 52px; background: #fff; border-top: 1px solid var(--border); display: flex; z-index: 900; }
.nav-tab { flex: 1; border: none; background: none; color: #94a3b8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; font-size: 9px; font-weight: 600; }
.nav-tab.active { color: var(--primary); }
.nav-tab .material-icons { font-size: 19px; }

.greeting-card { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; padding: 12px 14px; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; }
.stat-card { background: #fff; border-radius: 10px; padding: 8px; text-align: center; box-shadow: var(--shadow); }
.stat-val { font-size: 15px; font-weight: 800; color: var(--text); }
.stat-lbl { font-size: 9px; color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 4px 10px 12px; }
.action-card { background: #fff; border-radius: 12px; padding: 10px 4px; text-align: center; box-shadow: var(--shadow); cursor: pointer; border: none; font-size: 10px; font-weight: 600; color: var(--text); }
.tile-3d { width: 42px; height: 42px; border-radius: 12px; margin: 0 auto 4px; display: flex; align-items: center; justify-content: center; color: #fff; box-shadow: 0 6px 14px rgba(0,0,0,0.18); }
.c-visit { background: linear-gradient(145deg,#60a5fa,#2563eb); }
.c-punch { background: linear-gradient(145deg,#34d399,#059669); }
.c-cust  { background: linear-gradient(145deg,#22d3ee,#0891b2); }
.c-plan  { background: linear-gradient(145deg,#a78bfa,#6d28d9); }
.c-exp   { background: linear-gradient(145deg,#fb7185,#e11d48); }
.c-rpt   { background: linear-gradient(145deg,#38bdf8,#0284c7); }
.c-leave { background: linear-gradient(145deg,#fb923c,#ea580c); }
.c-jw    { background: linear-gradient(145deg,#f472b6,#c026d3); }
.section-card { background: #fff; margin: 0 10px 10px; border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.section-head { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 12px; color: var(--primary-deeper); }
.section-body { padding: 8px 12px; }

.subtab-bar { display: flex; background: #e8eaf6; border-radius: 8px; margin: 8px 10px; padding: 3px; gap: 3px; }
.subtab-btn { flex: 1; padding: 7px 4px; border: none; background: transparent; border-radius: 6px; font-size: 11px; font-weight: 600; color: #4338ca; cursor: pointer; }
.subtab-btn.active { background: var(--primary); color: #fff; }
.cust-card { background: #fff; border-radius: 10px; padding: 10px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; margin-bottom: 6px; cursor: pointer; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 9px; font-weight: 700; }
.b-green { background: #dcfce7; color: #166534; }
.b-orange { background: #ffedd5; color: #9a3412; }
.b-red { background: #fee2e2; color: #991b1b; }
.b-blue { background: #dbeafe; color: #1e40af; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-cell { aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; background: #f1f5f9; color: #94a3b8; cursor: pointer; }
.cal-cell.active-day { background: #dcfce7; color: #166534; }
.cal-cell.selected { background: var(--primary); color: #fff; }
.cal-cell.approved { border: 2px solid #16a34a; }
.cal-cell.disabled { opacity: 0.4; cursor: not-allowed; }

.rpt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; }
.rpt-card { background: #fff; border-radius: 10px; padding: 12px; box-shadow: var(--shadow); cursor: pointer; border-left: 4px solid var(--primary); }
.table-wrap { background: #fff; border-radius: 10px; box-shadow: var(--shadow); overflow-x: auto; margin-top: 8px; }
.rpt-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.rpt-table th { background: #eef2ff; color: var(--primary-deeper); padding: 7px 8px; text-align: left; white-space: nowrap; }
.rpt-table td { padding: 6px 8px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }

.overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.55); z-index: 2000; display: none; align-items: flex-end; justify-content: center; }
.overlay.open { display: flex; }
.sheet { width: 100%; max-height: 86vh; background: #fff; border-radius: 18px 18px 0 0; padding: 14px 16px 24px; overflow-y: auto; }
.sheet-handle { width: 38px; height: 4px; background: #cbd5e1; border-radius: 4px; margin: 0 auto 12px; }
.order-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 1500; display: none; flex-direction: column; }
.order-overlay.open { display: flex; }
.loading-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.65); z-index: 9999; display: none; align-items: center; justify-content: center; }
.loading-overlay.open { display: flex; }
.loader-card { background: #fff; border-radius: 18px; padding: 24px; text-align: center; width: 240px; }
.capsule-pill { width: 24px; height: 50px; border-radius: 12px; margin: 0 auto 10px; background: linear-gradient(to bottom,#ef4444 50%,#f59e0b 50%); animation: spinCap 1.1s linear infinite; }
@keyframes spinCap { to { transform: rotate(360deg); } }
#toastBox { position: fixed; bottom: 64px; left: 12px; right: 12px; z-index: 9500; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { padding: 10px 14px; border-radius: 10px; color: #fff; font-weight: 600; font-size: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #1e293b; }
.toast.info { background: var(--primary); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sync-dot.online { background: #4ade80; }
.sync-dot.offline { background: #f87171; }