@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --red: #c0392b;
  --red-dark: #96281b;
  --red-light: #fadbd8;
  --red-xlight: #fdf2f0;
  --green: #1e8449;
  --green-light: #d5f5e3;
  --amber: #d68910;
  --amber-light: #fef9e7;
  --blue: #1a5276;
  --blue-light: #d6eaf8;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f4;
  --gray-200: #e8eaed;
  --gray-300: #dadce0;
  --gray-400: #bdc1c6;
  --gray-500: #80868b;
  --gray-600: #5f6368;
  --gray-700: #3c4043;
  --gray-800: #202124;
  --white: #ffffff;
  --wa-green: #128C7E;
  --wa-dark: #075E54;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --transition: all 0.18s ease;
}

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

html, body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── SPLASH ── */
#splash {
  position: fixed; inset: 0;
  background: var(--red);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 1000;
  transition: opacity 0.4s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-logo { width: 64px; height: 64px; background: rgba(255,255,255,0.2); border-radius: 18px; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.splash-logo span { font-size: 22px; font-weight: 600; color: #fff; }
.splash-title { font-size: 22px; font-weight: 600; color: #fff; letter-spacing: -0.3px; }
.splash-sub { font-size: 13px; color: rgba(255,255,255,0.7); margin-top: 4px; }
.splash-loader { margin-top: 40px; width: 36px; height: 3px; background: rgba(255,255,255,0.2); border-radius: 2px; overflow: hidden; }
.splash-loader::after { content: ''; display: block; width: 40%; height: 100%; background: #fff; border-radius: 2px; animation: load 1.2s ease infinite; }
@keyframes load { 0%{transform:translateX(-100%)} 100%{transform:translateX(350%)} }

/* ── LOGIN ── */
#login-screen {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  background: var(--gray-50);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-logo { width: 56px; height: 56px; background: var(--red); border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.login-logo span { font-size: 20px; font-weight: 600; color: #fff; }
.login-title { font-size: 20px; font-weight: 600; color: var(--gray-800); }
.login-sub { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.login-tabs { display: flex; gap: 6px; margin-bottom: 20px; background: var(--gray-100); border-radius: var(--radius-md); padding: 4px; }
.login-tab { flex: 1; padding: 8px; border: none; background: none; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; color: var(--gray-500); font-family: 'DM Sans', sans-serif; transition: var(--transition); }
.login-tab.active { background: var(--white); color: var(--red); box-shadow: var(--shadow-sm); }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; color: var(--gray-600); margin-bottom: 5px; letter-spacing: 0.02em; }
.form-group input, .form-group select {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 14px; font-family: 'DM Sans', sans-serif;
  color: var(--gray-800); background: var(--white);
  transition: var(--transition); outline: none;
}
.form-group input:focus, .form-group select:focus { border-color: var(--red); }
.btn-primary {
  width: 100%; padding: 12px;
  background: var(--red); color: #fff; border: none;
  border-radius: var(--radius-md);
  font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--red-dark); }
.btn-primary:active { transform: scale(0.98); }

/* ── MAIN APP ── */
#app { display: none; flex-direction: column; min-height: 100vh; }
#app.visible { display: flex; }

/* ── TOP BAR ── */
.topbar {
  background: var(--red);
  padding: 14px 16px 12px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-logo { width: 34px; height: 34px; background: rgba(255,255,255,0.2); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; }
.topbar-title { font-size: 15px; font-weight: 600; color: #fff; }
.topbar-sub { font-size: 11px; color: rgba(255,255,255,0.7); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.avatar-btn { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,0.2); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; font-family: 'DM Sans', sans-serif; }
.notif-btn { width: 34px; height: 34px; border-radius: 50%; background: none; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; position: relative; }
.notif-dot { width: 8px; height: 8px; background: #ffd600; border-radius: 50%; position: absolute; top: 6px; right: 6px; }

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 10px 4px 8px;
  cursor: pointer; border: none; background: none;
  font-family: 'DM Sans', sans-serif;
  transition: var(--transition); position: relative;
}
.nav-item .nav-icon { font-size: 20px; margin-bottom: 3px; transition: var(--transition); }
.nav-item .nav-label { font-size: 10px; font-weight: 500; color: var(--gray-500); transition: var(--transition); }
.nav-item.active .nav-label { color: var(--red); }
.nav-item.active .nav-icon { transform: translateY(-1px); }
.nav-badge { position: absolute; top: 8px; right: calc(50% - 14px); background: var(--red); color: #fff; font-size: 9px; font-weight: 600; padding: 1px 5px; border-radius: 10px; }

/* ── CONTENT ── */
.content { flex: 1; padding: 16px; padding-bottom: 80px; overflow-y: auto; }
.page { display: none; }
.page.active { display: block; }

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}
.card-title {
  font-size: 13px; font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.card-title::before { content: ''; width: 3px; height: 14px; background: var(--red); border-radius: 2px; flex-shrink: 0; }

/* ── FORM ELEMENTS ── */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--gray-600); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 14px; font-family: 'DM Sans', sans-serif;
  color: var(--gray-800); background: var(--white);
  transition: var(--transition); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--red); background: var(--white); }
.field textarea { resize: none; line-height: 1.5; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ── BUTTONS ── */
.btn { padding: 11px 16px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; cursor: pointer; border: none; font-family: 'DM Sans', sans-serif; transition: var(--transition); width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: scale(0.98); }
.btn-red { background: var(--red); color: #fff; margin-bottom: 8px; }
.btn-red:hover { background: var(--red-dark); }
.btn-wa { background: var(--wa-green); color: #fff; }
.btn-wa:hover { background: var(--wa-dark); }
.btn-outline { background: none; color: var(--red); border: 1.5px solid var(--red); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-sm { padding: 7px 12px; font-size: 12px; width: auto; }

/* ── BADGES ── */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ── STATS ── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-card { background: var(--white); border-radius: var(--radius-lg); padding: 14px; box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200); }
.stat-label { font-size: 11px; color: var(--gray-500); font-weight: 500; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-val { font-size: 26px; font-weight: 600; color: var(--gray-800); line-height: 1; }
.stat-sub { font-size: 11px; color: var(--gray-500); margin-top: 4px; }
.stat-accent { width: 3px; height: 100%; border-radius: 2px; }

/* ── LIST ROWS ── */
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.list-row:last-child { border-bottom: none; padding-bottom: 0; }
.list-row:first-child { padding-top: 0; }
.row-main { font-size: 13px; font-weight: 500; color: var(--gray-800); }
.row-sub { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

/* ── PROGRESS BAR ── */
.progress-wrap { margin-top: 6px; }
.progress-bar { height: 4px; background: var(--gray-200); border-radius: 2px; }
.progress-fill { height: 4px; background: var(--red); border-radius: 2px; transition: width 0.6s ease; }
.progress-label { font-size: 11px; color: var(--gray-500); margin-top: 3px; }

/* ── POLICY BOX ── */
.policy-banner {
  background: linear-gradient(135deg, #fff5f5, #ffeaea);
  border: 1px solid #f5c6c6;
  border-left: 3px solid var(--red);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex; align-items: flex-start; gap: 10px;
}
.policy-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.policy-title { font-size: 13px; font-weight: 600; color: var(--red); }
.policy-text { font-size: 12px; color: var(--gray-600); margin-top: 2px; line-height: 1.4; }

/* ── LOCK WALL ── */
.lock-wall {
  background: var(--red-xlight);
  border: 1px solid var(--red-light);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  margin-bottom: 12px;
}
.lock-icon-big { font-size: 40px; margin-bottom: 10px; }
.lock-title { font-size: 16px; font-weight: 600; color: var(--red); margin-bottom: 6px; }
.lock-msg { font-size: 13px; color: var(--gray-600); line-height: 1.5; }

/* ── WHATSAPP PREVIEW ── */
.wa-preview {
  background: #e5ddd5;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
  position: relative;
}
.wa-bubble {
  background: var(--white);
  border-radius: 0 10px 10px 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--gray-800);
  white-space: pre-wrap;
  font-family: 'DM Mono', monospace;
  max-height: 180px;
  overflow-y: auto;
}
.wa-time { font-size: 10px; color: var(--gray-500); text-align: right; margin-top: 4px; }
.wa-label { font-size: 11px; color: var(--gray-500); margin-bottom: 6px; display: flex; align-items: center; gap: 5px; font-weight: 500; }

/* ── TOAST ── */
.toast-container { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 9999; width: calc(100% - 32px); max-width: 380px; pointer-events: none; }
.toast { padding: 12px 16px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; margin-bottom: 8px; box-shadow: var(--shadow-md); opacity: 0; transform: translateY(-8px); transition: all 0.25s ease; display: flex; align-items: center; gap: 8px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #d5f5e3; color: #1e8449; border: 1px solid #abebc6; }
.toast-error { background: var(--red-light); color: var(--red); border: 1px solid #f5b7b1; }
.toast-info { background: var(--blue-light); color: var(--blue); border: 1px solid #aed6f1; }
.toast-warning { background: var(--amber-light); color: var(--amber); border: 1px solid #f9e79f; }

/* ── TOGGLE ── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.toggle-row:last-child { border-bottom: none; }
.toggle-info .toggle-name { font-size: 14px; font-weight: 500; color: var(--gray-800); }
.toggle-info .toggle-desc { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.toggle-switch { width: 44px; height: 24px; border-radius: 12px; background: var(--gray-300); cursor: pointer; position: relative; transition: background 0.2s; flex-shrink: 0; border: none; }
.toggle-switch.on { background: var(--red); }
.toggle-switch::after { content: ''; width: 18px; height: 18px; border-radius: 50%; background: #fff; position: absolute; top: 3px; left: 3px; transition: left 0.2s; box-shadow: var(--shadow-sm); }
.toggle-switch.on::after { left: 23px; }

/* ── ATTENDANCE ── */
.att-summary { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 4px; }
.att-chip { flex-shrink: 0; padding: 8px 14px; border-radius: var(--radius-xl); font-size: 13px; font-weight: 600; }
.att-chip-p { background: var(--green-light); color: var(--green); }
.att-chip-a { background: var(--red-light); color: var(--red); }
.att-chip-w { background: var(--amber-light); color: var(--amber); }
.att-chip-t { background: var(--gray-100); color: var(--gray-700); }

/* ── EMP CARDS ── */
.emp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.emp-card { background: var(--white); border-radius: var(--radius-lg); padding: 12px; border: 1px solid var(--gray-200); display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: var(--shadow-sm); }
.emp-avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; }
.emp-name { font-size: 12px; font-weight: 600; color: var(--gray-800); text-align: center; }
.emp-site-label { font-size: 11px; color: var(--gray-500); text-align: center; }

/* ── SECTION HEADER ── */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title { font-size: 16px; font-weight: 600; color: var(--gray-800); }
.section-action { font-size: 13px; color: var(--red); font-weight: 500; cursor: pointer; background: none; border: none; font-family: 'DM Sans', sans-serif; }

/* ── MANAGER PANEL ── */
.manager-only { display: none; }
.manager-only.show { display: block; }
.filter-row { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 4px; }
.filter-chip { flex-shrink: 0; padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 500; cursor: pointer; border: 1.5px solid var(--gray-200); background: var(--white); color: var(--gray-600); transition: var(--transition); }
.filter-chip.active { background: var(--red); color: #fff; border-color: var(--red); }

/* ── DATE DISPLAY ── */
.date-display { font-size: 12px; color: var(--gray-500); margin-bottom: 16px; display: flex; align-items: center; gap: 6px; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-500); }
.empty-icon { font-size: 36px; margin-bottom: 10px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.empty-sub { font-size: 13px; }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500; display: flex; align-items: flex-end; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-sheet { background: var(--white); border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: 20px 20px 40px; width: 100%; transform: translateY(100%); transition: transform 0.3s ease; max-height: 80vh; overflow-y: auto; }
.modal-overlay.show .modal-sheet { transform: translateY(0); }
.modal-handle { width: 40px; height: 4px; background: var(--gray-300); border-radius: 2px; margin: 0 auto 16px; }
.modal-title { font-size: 16px; font-weight: 600; color: var(--gray-800); margin-bottom: 16px; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

/* ── UTILITY ── */
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.text-center { text-align: center; }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-muted { color: var(--gray-500); font-size: 13px; }
.divider { height: 1px; background: var(--gray-200); margin: 12px 0; }
.hidden { display: none !important; }

@media (max-width: 400px) {
  .row3 { grid-template-columns: 1fr 1fr; }
}
