/* ==========================================================================
   StaffPay — Premium Commercial SaaS Design System
   Brand Palette: #5B8752 (Primary), #E7F0E6 (Sage Light), #A7C36F (Accent), #A65E3A (Terracotta)
   ========================================================================== */

:root {
  /* Brand Palette Tokens */
  --color-primary: #5b8752;
  --color-primary-hover: #4c7344;
  --color-primary-light: #e7f0e6;
  --color-accent: #a7c36f;
  --color-terracotta: #a65e3a;
  --color-terracotta-light: #fdf4f0;
  --color-purple: #72558f;
  --color-purple-light: #f2eef7;
  
  /* Neutral Canvas & Surfaces */
  --color-canvas: #f8faf8;
  --color-surface: #ffffff;
  --color-border: #e2e8e2;
  --color-border-hover: #cbd8cb;
  
  /* High-Contrast Typography Tokens */
  --color-text-heading: #121a13;
  --color-text-body: #354236;
  --color-text-muted: #687569;
  
  /* Shadows & Elevation */
  --shadow-subtle: 0 4px 20px rgba(25, 45, 25, 0.04);
  --shadow-card-hover: 0 8px 28px rgba(25, 45, 25, 0.08);
  --shadow-modal: 0 20px 50px rgba(0, 0, 0, 0.18);
  
  /* Layout Geometry */
  --radius-card: 16px;
  --radius-btn: 10px;
  --radius-pill: 99px;
  --radius-input: 10px;
  --touch-target-min: 48px;
}

/* Reset & Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--color-canvas);
  color: var(--color-text-body);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

/* App Container */
.app {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 100px;
}

/* Header Navbar */
.top {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--color-text-heading);
}

.logo span {
  color: var(--color-primary);
}

.topright {
  display: flex;
  gap: 12px;
  align-items: center;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 700;
}

/* Main Content Surface */
main {
  padding: 24px;
}

.title {
  font-size: 28px;
  font-weight: 800;
  color: var(--color-text-heading);
  margin: 4px 0 6px;
  letter-spacing: -0.6px;
}

.sub {
  color: var(--color-text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

/* Layout Grids */
.grid {
  display: grid;
  gap: 16px;
}

.stats { grid-template-columns: repeat(4, 1fr); }
.two { grid-template-columns: repeat(2, 1fr); }
.three { grid-template-columns: repeat(3, 1fr); }

/* Premium Card Component */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-subtle);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.card.hoverable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.label {
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.big {
  font-size: 30px;
  font-weight: 800;
  color: var(--color-text-heading);
  margin-top: 4px;
  letter-spacing: -0.5px;
}

/* Buttons System (48px Min Touch Height on Mobile) */
.btn {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-heading);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 150ms ease;
  user-select: none;
}

.btn:hover {
  background: #f4f8f4;
  border-color: var(--color-border-hover);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(167, 195, 111, 0.4);
}

.btn.primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--color-primary-hover);
}

.btn.danger {
  color: var(--color-terracotta);
  border-color: #f7dcd5;
  background: var(--color-terracotta-light);
}

.btn.danger:hover {
  background: #fbeae5;
}

.btn.orange {
  background: var(--color-terracotta-light);
  color: var(--color-terracotta);
  border-color: #f7dcd5;
}

/* Toolbar Controls */
.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin: 18px 0;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  background: var(--color-surface);
  color: var(--color-text-heading);
  outline: none;
  font-size: 14px;
  transition: border-color 150ms, box-shadow 150ms;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(91, 135, 82, 0.18);
}

.toolbar input, .toolbar select {
  width: auto;
  min-width: 160px;
}

/* Staff Item Card */
.staff {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.who {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}

.name {
  font-weight: 800;
  font-size: 15px;
  color: var(--color-text-heading);
}

.muted {
  color: var(--color-text-muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* Status Pill Badges */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.pill.half { background: var(--color-purple-light); color: var(--color-purple); }
.pill.leave { background: var(--color-terracotta-light); color: var(--color-terracotta); }
.pill.pending { background: var(--color-terracotta-light); color: var(--color-terracotta); }
.pill.approved { background: var(--color-primary-light); color: var(--color-primary); }
.pill.unmarked { background: #f0f3f0; color: #7a887b; }

/* 1-Tap Attendance Segment Controls (Mobile Optimized UX) */
.att-segment {
  display: inline-flex;
  background: var(--color-canvas);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
  width: 100%;
  max-width: 320px;
}

.att-btn {
  flex: 1;
  min-height: 42px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  background: transparent;
  transition: all 120ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.att-btn.active.full {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid rgba(91, 135, 82, 0.3);
}

.att-btn.active.half {
  background: var(--color-purple-light);
  color: var(--color-purple);
  border: 1px solid rgba(114, 85, 143, 0.3);
}

.att-btn.active.leave {
  background: var(--color-terracotta-light);
  color: var(--color-terracotta);
  border: 1px solid rgba(166, 94, 58, 0.3);
}

/* Tables */
.tablewrap {
  overflow-x: auto;
  border-radius: 12px;
}

.table {
  border-collapse: collapse;
  width: 100%;
  min-width: 680px;
}

.table th, .table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  font-size: 13px;
}

.table th {
  color: var(--color-text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

/* Mobile Touch Bottom Nav */
.bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--color-border);
  z-index: 100;
}

.nav {
  max-width: 800px;
  margin: 0 auto;
  display: grid;
}

.nav.nav-5 { grid-template-columns: repeat(5, 1fr); }
.nav.nav-4 { grid-template-columns: repeat(4, 1fr); }

.nav button {
  background: none;
  border: 0;
  min-height: 56px;
  padding: 8px 4px;
  color: var(--color-text-muted);
  font-size: 11px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: color 150ms;
}

.nav button.active {
  color: var(--color-primary);
  font-weight: 800;
}

.nav b {
  display: block;
  font-size: 19px;
  line-height: 1;
  margin-bottom: 3px;
}

/* Modal Bottom Sheets & Overlays */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18, 26, 19, 0.45);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.sheet {
  background: var(--color-surface);
  width: min(640px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  padding: 24px;
  box-shadow: var(--shadow-modal);
  animation: slideUp 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full { grid-column: 1 / -1; }

.field label {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 700;
}

.modalfoot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* Callout Alert Notices */
.notice {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--color-primary-light);
  color: #2b4725;
  font-size: 13px;
  margin: 14px 0;
  line-height: 1.5;
  border: 1px solid rgba(91, 135, 82, 0.2);
}

.notice.warn {
  background: #fff8eb;
  color: #73431d;
  border: 1px solid #fce3cc;
}

.notice.locked {
  background: var(--color-terracotta-light);
  color: #75331a;
  border: 1px solid #f9d8ce;
}

/* Paystub Payroll Statement Layout */
.paystub {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-subtle);
}

.paystub-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--color-canvas);
  border-radius: 12px;
  font-size: 13px;
}

.paystub-item.net {
  background: var(--color-primary-light);
  border: 1px solid rgba(91, 135, 82, 0.3);
  padding: 16px;
}

.paystub-item.net b {
  font-size: 20px;
  color: var(--color-primary);
}

/* Toast Notifications */
#toastContainer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--color-text-heading);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  pointer-events: auto;
  animation: fadeIn 200ms forwards;
}

.toast.error { background: var(--color-terracotta); }
.toast.success { background: var(--color-primary); }

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

/* Responsive Adaptation */
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .two, .three { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .top { padding: 12px 16px; }
  main { padding: 16px 14px; }
  .title { font-size: 24px; }
  .sheet { padding: 20px; border-radius: 20px 20px 0 0; }
  .btn { width: 100%; }
  .actions { width: 100%; }
}
