/* ============ CSS Variables & Reset ============ */
:root {
  --primary: #d44c2f;
  --primary-dark: #b83a22;
  --primary-light: #ffe8db;
  --bg: #fff5f0;
  --bg-card: #fefaf7;
  --text: #3d2b22;
  --text-light: #5e3a2c;
  --text-muted: #999;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #0c5460;
  --border: #f1cfbc;
  --card-bg: #ffffff;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.03);
  --radius: 1.8rem;
  --radius-sm: 2rem;
  --transition: all 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Roboto, system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, var(--bg) 0%, #ffe8d6 100%);
  padding: 20px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  color: var(--text);
  overflow-x: hidden;
}

/* ============ Layout ============ */
.app {
  display: none;
  max-width: 1300px;
  width: 100%;
  background: white;
  border-radius: 2.5rem;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.1);
  padding: 2rem 2rem 2.5rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.8rem;
  padding: 0 0 0.8rem;
  border-bottom: 1px solid var(--border);
}

.header-left {
  min-width: 0;
}

.header-brand-text {
  min-width: 0;
}

.header-brand-text h1 {
  font-size: 1.5rem;
  color: var(--primary);
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.header-brand-text .subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
}

.header-logo {
  height: 65px;
  width: auto;
  object-fit: contain;
}

h3 {
  margin-bottom: 1rem;
  color: var(--text-light);
}

/* ============ Connection Status (compact) ============ */
.conn-indicator {
  width: 10px;
  height: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0.15rem;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.conn-dot.dot-green {
  background: var(--success);
  box-shadow: 0 0 6px rgba(40, 167, 69, 0.5);
}

.conn-dot.dot-red {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(220, 53, 69, 0.5);
}

/* ============ Config Card ============ */
.config-card {
  background: #fff3cd !important;
  border: 2px solid var(--warning) !important;
  display: none !important;
}

.config-description {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.config-input {
  flex: 1;
  min-width: 250px;
}

.warning-text {
  color: #856404;
  display: block;
  margin-top: 0.5rem;
}

.warning-text code {
  background: #ffe69c;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

/* ============ Navigation Tabs ============ */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid #fce3d6;
  padding-bottom: 0.8rem;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}

.tab-btn:hover {
  background: #fff0e8;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 8px 18px rgba(212, 76, 47, 0.25);
}

/* ============ Panels ============ */
.panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.panel.active {
  display: block;
}

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

/* ============ Cards ============ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.6rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.8rem;
  border: 1px solid var(--primary-light);
}

/* Push notification nudge banner */
.pnm-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark, #b23a1c));
  color: #fff;
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.pnm-banner.hidden { display: none; }
.pnm-text { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.9rem; }
.pnm-text strong { font-size: 0.95rem; }
.pnm-actions { display: flex; align-items: center; gap: 0.5rem; }
.pnm-actions .btn-sm { white-space: nowrap; }
.push-admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border, #eee);
  font-size: 0.9rem;
}
.push-admin-row:last-child { border-bottom: none; }
.push-admin-name { font-weight: 600; }
.push-admin-status { font-size: 0.82rem; color: var(--text-muted, #777); }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.grid-2 > .card {
  min-width: 0;
  overflow: hidden;
}

/* ============ Payroll staff cards ============ */
.pr-staff-grid {
  margin-top: 0.25rem;
}
.pr-staff-card-v2 {
  background: var(--bg-card);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.1rem;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  animation: prCardIn 0.4s ease both;
}
.pr-staff-card-v2:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(212, 76, 47, 0.18);
  border-color: var(--primary);
}
.pr-staff-card-v2:active {
  transform: translateY(-1px) scale(0.99);
}
@keyframes prCardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pr-staff-top {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.pr-staff-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.6), 0 2px 6px rgba(0, 0, 0, 0.12);
}
.pr-staff-id { flex: 1; min-width: 0; }
.pr-staff-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pr-staff-role {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pr-staff-chev {
  color: var(--primary);
  font-size: 1.3rem;
  font-weight: 700;
  flex-shrink: 0;
}
.pr-staff-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.pr-staff-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.pr-staff-stat-pay { align-items: flex-end; text-align: right; }
.pr-stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  font-weight: 600;
}
.pr-stat-value {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.pr-stat-value small {
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 1px;
}
.pr-pay-value {
  color: var(--primary);
  font-size: 1.02rem;
}
.pr-earn-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(212, 76, 47, 0.12);
  overflow: hidden;
}
.pr-earn-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}
body.dark-mode .pr-earn-bar { background: rgba(255, 255, 255, 0.10); }

.pr-advance-chip {
  margin: 0.6rem 0.85rem 0;
  padding: 0.28rem 0.6rem;
  background: #f3f0ff;
  border: 1px solid #d0bfff;
  color: #6741d9;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-block;
}
body.dark-mode .pr-advance-chip { background: rgba(103, 65, 217, 0.18); border-color: rgba(103, 65, 217, 0.45); color: #c1b0ff; }

.pr-adv-row {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.pr-adv-row:last-child { border-bottom: none; }

/* ============ Tables ============ */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

th {
  text-align: left;
  color: #9b4b36;
  font-weight: 600;
  padding: 0.7rem 0.5rem;
  border-bottom: 2px solid #fadbc8;
  background: #fff5f0;
}

td {
  padding: 0.7rem 0.5rem;
  border-bottom: 1px solid #ffe0ce;
}

tr:hover td {
  background: #fff9f5;
}

/* ============ Badges ============ */
.badge {
  display: inline-block;
  padding: 0.25rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: var(--info); }

/* ============ Forms ============ */
.form-input,
.form-select {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 0.9rem;
  background: white;
  transition: var(--transition);
}

.form-input::placeholder {
  color: #bbb;
  font-size: 0.78rem;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212, 76, 47, 0.1);
}

.form-row {
  margin-top: 1.5rem;
}

/* ============ Buttons ============ */
button {
  padding: 0.7rem 1.3rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(212, 76, 47, 0.3);
}

.btn-secondary {
  background: #fce3d6;
  color: var(--text-light);
}

.btn-secondary:hover {
  background: #f5c4a8;
}

.date-nav-btn {
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  line-height: 1.3;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.date-nav-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

.inv-qty {
  width: 80px !important;
  padding: 0.6rem 0.5rem !important;
  font-size: 1.05rem !important;
  text-align: center;
}
.inv-btn {
  padding: 0.65rem 0.9rem !important;
  font-size: 0.95rem !important;
}
textarea.form-input {
  font-family: inherit;
}
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  background: var(--card-bg);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.btn-success {
  background: #28a745;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}
.btn-success:hover {
  background: #218838;
}

.btn-danger {
  background: #dc3545;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}
.btn-danger:hover {
  background: #c82333;
}

/* ============ Utilities ============ */
.row-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
  margin: 1rem 0 0.5rem;
}

/* ============ Task scheduler (segmented controls & day pills) ============ */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-field > label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
  gap: 0.2rem;
  background: var(--bg-secondary, #f8f9fa);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
}

.segmented input[type="radio"],
.segmented input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.segmented label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.5rem 0.6rem;
  border-radius: calc(var(--radius-sm) - 0.4rem);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  user-select: none;
}

.segmented label.active,
.segmented label:has(input:checked) {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(212, 76, 47, 0.35);
}

.segmented label:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.seg-inline-input {
  width: 3.2rem;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  font-size: 0.8rem;
  background: #fff;
  text-align: center;
}

.day-pill-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.3rem;
}

.day-pill {
  position: relative;
  display: block;
  cursor: pointer;
  user-select: none;
}

.day-pill input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.day-pill span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  width: 100%;
  padding: 0.45rem 0;
  border-radius: 10px;
  background: var(--bg-card, #fff);
  border: 1.5px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  transition: var(--transition);
}

.day-pill.active span,
.day-pill:has(input:checked) span {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(212, 76, 47, 0.35);
}

.day-pill:has(input:focus-visible) span {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.repeat-summary {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg-secondary, #f8f9fa);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}

.freq-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(212, 76, 47, 0.1);
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .day-pill-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

body.dark-mode .segmented {
  background: #1a1a2e;
  border-color: #3d2b22;
}

body.dark-mode .segmented label {
  color: var(--text);
}

body.dark-mode .seg-inline-input {
  background: #1a1a2e;
  color: var(--text);
  border-color: #3d2b22;
}

body.dark-mode .day-pill span {
  background: #1a1a2e;
  border-color: #3d2b22;
  color: var(--text);
}

body.dark-mode .day-pill.active span,
body.dark-mode .day-pill:has(input:checked) span {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

body.dark-mode .repeat-summary {
  background: #1a1a2e;
  border-color: #3d2b22;
  color: #bbb;
}

body.dark-mode .freq-badge {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.summary-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.helper-text {
  font-size: 0.8rem;
  margin-top: 0.3rem;
  color: var(--text-muted);
}

.success-message {
  font-weight: 600;
  color: var(--success);
}

.loading-text {
  color: var(--text-muted);
  padding: 1rem;
}

.scrollable-list {
  max-height: 280px;
  overflow-y: auto;
}

.log-list {
  max-height: 150px;
  overflow-y: auto;
  font-size: 0.85rem;
  padding-left: 1.2rem;
  list-style: disc;
}

.subsection {
  margin-top: 1rem;
}

.report-content {
  line-height: 1.8;
}

.report-scroll {
  max-height: 300px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.report-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
}
.report-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--card-bg);
}

hr {
  border: 0.5px solid #f7d7c4;
  margin: 1rem 0;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
  .app {
    padding: 1.2rem;
    border-radius: 1.5rem;
  }
  
  h1 {
    font-size: 1.6rem;
  }
  
  .grid-2 {
    grid-template-columns: 1fr;
  }
  
  .row-flex {
    flex-direction: column;
    align-items: stretch;
  }
  
  .form-input,
  .form-select {
    width: 100% !important;
  }

  #markAttendanceForm .row-flex {
    align-items: stretch !important;
  }

  #markAttendanceForm .row-flex > div {
    width: 100% !important;
    flex: none !important;
    min-width: 0 !important;
  }
}

/* ============ Dark Mode ============ */
body.dark-mode {
  --primary: #e85d3a;
  --primary-dark: #d44c2f;
  --primary-light: #4a2a1e;
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --text: #e8d5c4;
  --text-light: #c9b6a5;
  --text-muted: #8a7a6a;
  --border: #3d2b22;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

body.dark-mode .app {
  background: #0f0f23;
}

body.dark-mode .card {
  background: #16213e;
  border-color: #2a2a4a;
}

body.dark-mode .tab-btn {
  color: #c9b6a5;
}

body.dark-mode .tab-btn:hover {
  background: #2a2a4a;
}

body.dark-mode th {
  background: #1a1a2e;
  color: #c9b6a5;
  border-bottom-color: #3d2b22;
}

body.dark-mode td {
  border-bottom-color: #2a2a4a;
}

body.dark-mode tr:hover td {
  background: #1e2a4a;
}

body.dark-mode .form-input,
body.dark-mode .form-select {
  background: #1a1a2e;
  color: var(--text);
  border-color: #3d2b22;
}

body.dark-mode .form-input::placeholder {
  color: #555;
}

body.dark-mode .btn-secondary {
  background: #2a2a4a;
  color: var(--text);
}

body.dark-mode .btn-secondary:hover {
  background: #3d3d5c;
}

body.dark-mode .config-card {
  background: #2a2a2a !important;
  border-color: #555 !important;
}

body.dark-mode hr {
  border-color: #2a2a4a;
}

body.dark-mode .transaction-item {
  border-bottom-color: #2a2a4a;
}

body.dark-mode .header {
  border-bottom-color: #2a2a4a;
}

body.dark-mode .user-dropdown {
  background: #16213e;
  border-color: #2a2a4a;
}

body.dark-mode .user-dropdown-header {
  border-bottom-color: #2a2a4a;
}

body.dark-mode .user-avatar:hover {
  border-color: var(--primary);
}

body.dark-mode .logout-btn:hover {
  background: #3a1a1a;
  color: #e88;
}

body.dark-mode .notif-bell:hover {
  background: #2a2a4a;
}

body.dark-mode .conn-dot.dot-green {
  box-shadow: 0 0 6px rgba(40, 167, 69, 0.3);
}

body.dark-mode .conn-dot.dot-red {
  box-shadow: 0 0 6px rgba(220, 53, 69, 0.3);
}

body.dark-mode .alert-success {
  background: #1a3a2a;
  color: #8bc48b;
  border-color: #2a5a3a;
}

body.dark-mode .alert-danger {
  background: #3a1a1a;
  color: #e88;
  border-color: #5a2a2a;
}

body.dark-mode .alert-warning {
  background: #3a3a1a;
  color: #e8c84a;
  border-color: #5a5a2a;
}

body.dark-mode .login-overlay {
  background: rgba(15, 15, 35, 0.95);
}

body.dark-mode .login-card {
  background: #16213e;
  border-color: #2a2a4a;
}

body.dark-mode .login-card h2 {
  color: var(--text);
}

body.dark-mode .dashboard-stat {
  background: #16213e;
  border-color: #2a2a4a;
}

/* ============ Theme Toggle ============ */
.theme-toggle {
  width: 42px;
  height: 26px;
  border-radius: 13px;
  border: none;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  cursor: pointer;
  position: relative;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  flex-shrink: 0;
}

.theme-toggle::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease;
  z-index: 1;
}

.theme-toggle::after {
  position: absolute;
  z-index: 2;
  font-size: 11px;
  line-height: 1;
  top: 50%;
  transform: translateY(-50%);
  transition: right 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle:hover {
  box-shadow: 0 2px 12px rgba(102, 126, 234, 0.5);
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* Light mode: sun icon (target: switch to dark) — knob on left */
.theme-toggle::after {
  content: '☀️';
  left: 5px;
}

/* Dark mode: moon icon (target: switch to light) — knob slides right */
body.dark-mode .theme-toggle {
  background: linear-gradient(135deg, #2d3436 0%, #636e72 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode .theme-toggle::before {
  transform: translateX(16px);
  background: #fdcb6e;
}

body.dark-mode .theme-toggle::after {
  content: '🌙';
  left: auto;
  right: 6px;
}

body.dark-mode .theme-toggle:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

/* ============ Auth / Login ============ */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 245, 240, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.login-overlay.hidden {
  display: none;
}

.login-card {
  background: white;
  border-radius: 2rem;
  padding: 2.5rem;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 400px;
  border: 1px solid var(--primary-light);
}

.login-card h2 {
  text-align: center;
  color: var(--primary);
  margin-bottom: 0.5rem;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card h2 .login-logo {
  max-width: 75%;
  height: auto;
  max-height: 120px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.login-card .subtitle {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-card .form-group {
  margin-bottom: 1rem;
}

.login-card .form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--text-light);
  font-size: 0.9rem;
}

.login-card .form-group input {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 2rem;
  border: 1.5px solid var(--border);
  font-size: 0.9rem;
  background: white;
  transition: var(--transition);
}

.login-card .form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212, 76, 47, 0.1);
}

.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 0.8rem;
  margin-top: 0.5rem;
}

.login-card .login-error {
  color: var(--danger);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 0.5rem;
  display: none;
}

.login-card .login-error.show {
  display: block;
}

/* ============ User Menu (Avatar + Dropdown) ============ */
.user-menu {
  position: relative;
  margin-left: 0.15rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0;
  line-height: 1;
}

.user-avatar:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.user-avatar:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.avatar-initials {
  user-select: none;
}

/* Dropdown card */
.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  overflow: hidden;
}

.user-dropdown.open {
  display: block;
  animation: dropdownIn 0.15s ease-out;
}

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

.user-dropdown-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dropdown-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.dropdown-role {
  display: inline-block;
  background: var(--primary-light);
  padding: 0.15rem 0.6rem;
  border-radius: 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--primary);
  align-self: flex-start;
}

.user-dropdown-body {
  padding: 0.4rem;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-light);
  transition: var(--transition);
}

.logout-btn:hover {
  background: #f8d7da;
  color: var(--danger);
}

.logout-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ============ Dashboard ============ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.dashboard-stat {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.2rem;
  border: 1px solid var(--primary-light);
  text-align: center;
  transition: var(--transition);
}

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

.dashboard-stat .stat-icon {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}

.dashboard-stat .stat-cal {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  margin: 0 auto 0.3rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  overflow: hidden;
  background: var(--bg-card);
}
.dashboard-stat .stat-cal-mon {
  width: 100%;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--danger, #dc3545);
  padding: 0.1rem 0;
  line-height: 1.1;
}
.dashboard-stat .stat-cal-day {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.dashboard-stat .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}

.dashboard-stat .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dashboard-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.dashboard-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.2rem;
  border: 1px solid var(--primary-light);
}

.dashboard-card h4 {
  color: var(--text-light);
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}

.quick-action-btn {
  padding: 0.8rem;
  border-radius: 1.2rem;
  border: 1.5px solid var(--border);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-light);
  transition: var(--transition);
  text-align: center;
}

.quick-action-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ============ Alerts ============ */
.alert {
  padding: 0.7rem 1rem;
  border-radius: 1rem;
  margin-bottom: 0.8rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid transparent;
}

.alert-warning {
  background: #fff3cd;
  color: #856404;
  border-color: #ffc107;
}

.alert-danger {
  background: #f8d7da;
  color: #721c24;
  border-color: #dc3545;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border-color: #28a745;
}

.alert-info {
  background: #d1ecf1;
  color: #0c5460;
  border-color: #17a2b8;
}

.low-stock-alerts {
  margin-bottom: 1rem;
}

.low-stock-alerts .alert {
  margin-bottom: 0.4rem;
}

/* ============ Suppliers & Recipes ============ */
.action-bar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.supplier-actions,
.recipe-actions {
  display: flex;
  gap: 0.3rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.8rem;
  background: var(--primary-light);
  border-radius: 1.2rem;
  align-items: end;
}

.inline-form.hidden {
  display: none;
}

.inline-form .form-group {
  flex: 1;
  min-width: 120px;
}

.inline-form .form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.inline-form .form-group input,
.inline-form .form-group select,
.inline-form .form-group textarea {
  width: 100%;
  padding: 0.5rem 0.8rem;
  border-radius: 1rem;
  border: 1.5px solid var(--border);
  font-size: 0.85rem;
  background: white;
}

.inline-form .form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.inline-form .form-group input:focus,
.inline-form .form-group select:focus,
.inline-form .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============ Recipe Ingredients ============ */
.ingredient-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.3rem;
}

.ingredient-row select,
.ingredient-row input {
  padding: 0.4rem 0.8rem;
  border-radius: 1rem;
  border: 1.5px solid var(--border);
  font-size: 0.85rem;
  background: white;
}

.ingredient-row select:focus,
.ingredient-row input:focus {
  outline: none;
  border-color: var(--primary);
}

.ingredient-row .remove-ingredient {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.2rem;
}

.add-ingredient-btn {
  background: none;
  border: 1px dashed var(--border);
  padding: 0.4rem 0.8rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.add-ingredient-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.recipe-cost {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.recipe-cost strong {
  color: var(--text);
}

/* ============ Recipe Collapsible Cards ============ */
.recipe-header {
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.recipe-header-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.recipe-name {
  font-size: 1.1rem;
}
.recipe-essence-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.recipe-header .chev {
  transition: transform 0.2s ease;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.recipe-header.collapsed .chev {
  transform: rotate(-90deg);
}
.recipe-body {
  padding-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.recipe-body.collapsed {
  display: none;
}
.recipe-section {
  background: var(--primary-light);
  border-radius: 0.8rem;
  padding: 0.6rem 0.8rem;
}
.recipe-section-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.recipe-section-content {
  font-size: 0.85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  color: var(--text);
}
.recipe-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.2rem;
}

/* ============ Expense Categories ============ */
.expense-category-select {
  padding: 0.5rem 0.8rem;
  border-radius: 1rem;
  border: 1.5px solid var(--border);
  font-size: 0.85rem;
  background: white;
}

.expense-category-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============ Leave Calendar ============ */
.calendar-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.calendar-nav h4 {
  margin: 0;
  font-size: 1rem;
}

.calendar-nav button {
  background: none;
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-light);
}

.calendar-nav button:hover {
  background: var(--primary-light);
}

.team-calendar {
  max-width: 440px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  font-size: 0.68rem;
}

.calendar-grid .day-header {
  text-align: center;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.25rem 0;
  font-size: 0.62rem;
}

.calendar-grid .day-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 0.45rem;
  background: var(--bg);
  font-size: 0.68rem;
  cursor: default;
  position: relative;
  min-height: 28px;
}

.calendar-grid .day-cell.other-month {
  opacity: 0.3;
}

.calendar-grid .day-cell.today {
  font-weight: 700;
  border: 2px solid var(--primary);
}

.calendar-grid .day-cell .leave-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
  margin-top: 2px;
}

.calendar-grid .day-cell .leave-dot.approved {
  background: var(--success);
}

.calendar-grid .day-cell .leave-dot.pending {
  background: var(--warning);
}

.calendar-grid .day-cell .leave-dot.rejected {
  background: var(--danger);
}

.calendar-legend {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.calendar-legend span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.calendar-legend .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.calendar-legend .dot-leave { background: #20c997; }
.calendar-legend .dot-perm { background: #3b82f6; }
.calendar-legend .dot-pending-leave { background: #ffc107; }
.calendar-legend .dot-pending-perm { background: #fd7e14; }
.calendar-legend .dot-half { background: #ffc107; }
.calendar-legend .dot-absent { background: #dc3545; }

/* Team Calendar highlight states (strong, distinct hues) */
.calendar-grid .day-cell.leave-approved {
  background: rgba(32, 201, 151, 0.32);
  border: 2px solid #20c997;
}
.calendar-grid .day-cell.perm-approved {
  background: rgba(59, 130, 246, 0.32);
  border: 2px solid #3b82f6;
}
/* Pending states use a striped overlay (background-image) layered over any
   base color, so an approved + pending day shows stripes on top of the solid fill. */
.calendar-grid .day-cell.leave-pending {
  background-color: rgba(255, 193, 7, 0.22);
  background-image: repeating-linear-gradient(45deg, rgba(255, 193, 7, 0.55) 0 6px, transparent 6px 12px);
  border: 2px dashed #ffc107;
}
.calendar-grid .day-cell.perm-pending {
  background-color: rgba(253, 126, 20, 0.22);
  background-image: repeating-linear-gradient(45deg, rgba(253, 126, 20, 0.55) 0 6px, transparent 6px 12px);
  border: 2px dashed #fd7e14;
}
.calendar-grid .day-cell.half-day {
  background: rgba(255, 193, 7, 0.32);
  border: 2px solid #ffc107;
}
.calendar-grid .day-cell.absent {
  background: rgba(220, 53, 69, 0.30);
  border: 2px solid #dc3545;
}
.calendar-grid .day-cell.leave-approved.absent,
.calendar-grid .day-cell.leave-approved.half-day,
.calendar-grid .day-cell.half-day.absent {
  background: linear-gradient(135deg, rgba(32, 201, 151, 0.32) 0 50%, rgba(220, 53, 69, 0.30) 50% 100%);
}

/* Diagonal split: Approved Leave (teal) + Approved Permission (blue) */
.calendar-grid .day-cell.leave-approved.perm-approved {
  background: linear-gradient(135deg, rgba(32, 201, 151, 0.32) 0 50%, rgba(59, 130, 246, 0.32) 50% 100%);
}

/* Diagonal split: Approved Permission (blue) + Absent (red) */
.calendar-grid .day-cell.perm-approved.absent {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.32) 0 50%, rgba(220, 53, 69, 0.30) 50% 100%);
}

/* Multi-person badge: 2+ staff approved on same date */
.calendar-grid .day-cell.multi-person {
  outline: 2px solid rgba(0,0,0,0.25);
  outline-offset: -2px;
}

.day-cell .multi-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.50rem;
  font-weight: 700;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  z-index: 2;
  pointer-events: none;
}

/* Tooltip / popup listing staff names for a day */
.calendar-grid .day-cell .cell-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1200;
  min-width: 150px;
  max-width: 240px;
  padding: 0.5rem 0.6rem;
  background: #1c1c2e;
  color: #f0f0f5;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.7rem;
  line-height: 1.35;
  text-align: left;
  pointer-events: none;
}
.calendar-grid .day-cell .cell-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1c1c2e;
}
.calendar-grid .day-cell:hover .cell-tooltip,
.calendar-grid .day-cell.tooltip-open .cell-tooltip {
  display: block;
}
.cell-tooltip .tt-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  margin-top: 0.35rem;
  opacity: 0.95;
}
.cell-tooltip .tt-group:first-child { margin-top: 0; }
.cell-tooltip .tt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.cell-tooltip .tt-dot.leave { background: #20c997; }
.cell-tooltip .tt-dot.perm { background: #3b82f6; }
.cell-tooltip .tt-dot.pending-leave { background: #ffc107; }
.cell-tooltip .tt-dot.pending-perm { background: #fd7e14; }
.cell-tooltip .tt-dot.half { background: #ffc107; }
.cell-tooltip .tt-dot.absent { background: #dc3545; }
.cell-tooltip .tt-name {
  padding-left: 0.95rem;
  opacity: 0.92;
}

body.dark-mode .calendar-grid .day-cell.leave-approved { background: rgba(32, 201, 151, 0.45); }
body.dark-mode .calendar-grid .day-cell.perm-approved { background: rgba(59, 130, 246, 0.45); }
body.dark-mode .calendar-grid .day-cell.leave-pending {
  background-color: rgba(255, 193, 7, 0.30);
  background-image: repeating-linear-gradient(45deg, rgba(255, 193, 7, 0.65) 0 6px, transparent 6px 12px);
}
body.dark-mode .calendar-grid .day-cell.perm-pending {
  background-color: rgba(253, 126, 20, 0.30);
  background-image: repeating-linear-gradient(45deg, rgba(253, 126, 20, 0.65) 0 6px, transparent 6px 12px);
}
body.dark-mode .calendar-grid .day-cell.half-day { background: rgba(255, 193, 7, 0.42); }
body.dark-mode .calendar-grid .day-cell.absent { background: rgba(220, 53, 69, 0.40); }
body.dark-mode .calendar-grid .day-cell.leave-approved.absent,
body.dark-mode .calendar-grid .day-cell.leave-approved.half-day,
body.dark-mode .calendar-grid .day-cell.half-day.absent {
  background: linear-gradient(135deg, rgba(32, 201, 151, 0.45) 0 50%, rgba(220, 53, 69, 0.40) 50% 100%);
}

body.dark-mode .calendar-grid .day-cell.leave-approved.perm-approved {
  background: linear-gradient(135deg, rgba(32, 201, 151, 0.45) 0 50%, rgba(59, 130, 246, 0.45) 50% 100%);
}

body.dark-mode .calendar-grid .day-cell.perm-approved.absent {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.45) 0 50%, rgba(220, 53, 69, 0.40) 50% 100%);
}

body.dark-mode .calendar-grid .day-cell.multi-person {
  outline-color: rgba(255,255,255,0.25);
}

body.dark-mode .day-cell .multi-badge {
  background: rgba(255,255,255,0.55);
  color: #1c1c2e;
}

/* ============ Permission Tracker ============ */
.permission-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0.5rem 0;
}

.permission-form input,
.permission-form select {
  padding: 0.4rem 0.7rem;
  border-radius: 1rem;
  border: 1.5px solid var(--border);
  font-size: 0.8rem;
  background: white;
}

.permission-form input:focus,
.permission-form select:focus {
  outline: none;
  border-color: var(--primary);
}

.permission-log {
  max-height: 150px;
  overflow-y: auto;
  font-size: 0.8rem;
}

.permission-item {
  padding: 0.3rem 0;
  border-bottom: 1px solid #ffe0ce;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.3rem;
}

.permission-item:last-child {
  border-bottom: none;
}

.badge-permission {
  background: #cce5ff;
  color: #004085;
}

.badge-overtime {
  background: #d4edda;
  color: #155724;
}

.badge-late {
  background: #fff3cd;
  color: #856404;
}

.badge-early {
  background: #f8d7da;
  color: #721c24;
}

/* ============ Shift Management ============ */
.shift-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin: 0.5rem 0;
}

.shift-form select,
.shift-form input {
  padding: 0.4rem 0.7rem;
  border-radius: 1rem;
  border: 1.5px solid var(--border);
  font-size: 0.8rem;
  background: white;
}

.shift-form select:focus,
.shift-form input:focus {
  outline: none;
  border-color: var(--primary);
}

.shift-roster {
  font-size: 0.8rem;
  width: 100%;
  border-collapse: collapse;
}

.shift-roster th {
  padding: 0.4rem 0.3rem;
  font-size: 0.7rem;
  text-align: center;
  background: var(--primary-light);
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
}

.shift-roster td {
  padding: 0.3rem;
  text-align: center;
  border-bottom: 1px solid #ffe0ce;
  font-size: 0.75rem;
}

.shift-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
}

.shift-morning {
  background: #fff3cd;
  color: #856404;
}

.shift-evening {
  background: #d1ecf1;
  color: #0c5460;
}

.shift-fullday {
  background: #d4edda;
  color: #155724;
}

/* ============ Team Members Card ============ */
.emp-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.emp-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  transition: var(--transition);
}

.emp-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(212, 76, 47, 0.08);
  transform: translateY(-1px);
}

.emp-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.emp-info {
  flex: 1;
  min-width: 0;
}

.emp-name {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emp-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.emp-pay {
  font-weight: 600;
  color: var(--primary);
}

.emp-pay small {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 1px;
}

.emp-geo-icon {
  font-size: 0.7rem;
}

.emp-badges {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}

.emp-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.emp-status-dot.active { background: var(--success); }
.emp-status-dot.inactive { background: var(--danger); }

.emp-status-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.emp-actions {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
  opacity: 0.5;
  transition: var(--transition);
}

.emp-card:hover .emp-actions {
  opacity: 1;
}

.emp-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  transition: var(--transition);
}

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

.emp-action-btn.danger:hover {
  background: #fde8e8;
  color: var(--danger);
}

.emp-action-btn.warn:hover {
  background: #fff4e1;
  color: #e8590c;
}

.emp-action-btn.ok:hover {
  background: #e6f7ee;
  color: #1a9c5b;
}

.emp-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Employee inline edit form */
.emp-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.emp-edit-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.emp-edit-input {
  padding: 0.35rem 0.6rem !important;
  font-size: 0.82rem !important;
  border-radius: var(--radius-sm) !important;
}

.emp-edit-select {
  padding: 0.35rem 0.4rem !important;
  font-size: 0.78rem !important;
  border-radius: var(--radius-sm) !important;
}

.emp-edit-geo {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
}

.emp-edit-actions {
  display: flex;
  gap: 0.4rem;
}

body.dark-mode .emp-card {
  background: #16213e;
  border-color: #2a2a4a;
}

body.dark-mode .emp-card:hover {
  border-color: var(--primary);
}

body.dark-mode .emp-action-btn:hover {
  background: rgba(232, 93, 58, 0.15);
}

body.dark-mode .emp-action-btn.danger:hover {
  background: rgba(220, 53, 69, 0.15);
}

/* ============ Leave Requests Card ============ */
.leave-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 280px;
  overflow-y: auto;
}

.leave-card {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-left: 3px solid var(--border);
  transition: var(--transition);
}

.leave-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}

.leave-card.status-approved { border-left-color: var(--success); }
.leave-card.status-pending  { border-left-color: var(--warning); }
.leave-card.status-rejected { border-left-color: var(--danger); }

.leave-info {
  flex: 1;
  min-width: 0;
}

.leave-name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.2;
}

.leave-details {
  font-size: 0.73rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

.leave-reason {
  color: var(--text-light);
  font-weight: 500;
}

.leave-dates {
  color: var(--text-muted);
}

.leave-rejection {
  color: var(--danger);
  font-size: 0.7rem;
  margin-top: 2px;
  font-style: italic;
}

.leave-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-shrink: 1;
  min-width: 0;
}

.leave-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.leave-badge.approved { background: #d4edda; color: #155724; }
.leave-badge.pending  { background: #fff3cd; color: #856404; }
.leave-badge.rejected { background: #f8d7da; color: #721c24; }

.leave-penalty {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  background: #fff3e0;
  color: #b35309;
  border: 1px solid #ffcc80;
  margin-top: 0.25rem;
}

.leave-penalty.waived {
  background: #e9ecef;
  color: #868e96;
  border-color: #ced4da;
  text-decoration: line-through;
}

.leave-penalty-preview {
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(240, 140, 0, 0.14);
  border: 1px solid #f08c00;
  color: #a8590a;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
}

.leave-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.3rem;
  max-width: 100%;
}

.leave-action-btn {
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  border: none;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.leave-action-btn.approve {
  background: #d4edda;
  color: #155724;
}

.leave-action-btn.approve:hover {
  background: #28a745;
  color: white;
}

.leave-action-btn.reject {
  background: #f8d7da;
  color: #721c24;
}

.leave-action-btn.reject:hover {
  background: #dc3545;
  color: white;
}

/* ============ Task Assignment cards (Compliance) ============ */
/* Shared, mobile-safe layout so avatar stays top-left and action
   buttons wrap into a full-width footer row on narrow screens. */
.task-card {
  align-items: flex-start;
}

.task-card .leave-actions {
  width: 100%;
}

@media (max-width: 768px) {
  .task-card {
    flex-wrap: wrap;
  }

  .task-card .leave-info {
    flex: 1 1 auto;
    min-width: 0;
  }

  .task-card .leave-right {
    flex: 1 1 100%;
    flex-direction: row;
    align-items: flex-start;
    margin-top: 0.5rem;
  }

  .task-card .leave-actions {
    flex-direction: row !important;
    flex-wrap: wrap;
    align-items: flex-start !important;
    justify-content: flex-start !important;
  }
}

/* ============ Order Task Buttons ============ */
.order-noorder-muted {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  display: block;
  padding: 0.25rem 0;
}
.order-deadline-warn {
  font-size: 0.75rem;
  color: #e8590c;
  font-weight: 600;
  text-align: center;
  margin-top: 0.3rem;
  padding: 0.25rem 0.4rem;
  background: #fff3e0;
  border-radius: 6px;
}
.order-status-label {
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.task-card.order-task {
  border-left: 3px solid #D97706;
}
.task-card.order-task .emp-avatar.order-avatar {
  background: #D97706 !important;
  color: #fff;
}
.order-task-tag {
  display: inline-block;
  background: #FEF3C7;
  color: #92400E;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

/* Leave-request cards: same mobile-safe stacking as .task-card so the wide
   Responsibility penalty tag wraps below the info instead of overlapping it
   or squeezing the date text on small screens. */
@media (max-width: 768px) {
  .leave-card {
    flex-wrap: wrap;
  }

  .leave-card .leave-info {
    flex: 1 1 auto;
    min-width: 0;
  }

  .leave-card .leave-right {
    flex: 1 1 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.35rem;
    margin-top: 0.5rem;
  }

  .leave-card .leave-actions {
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

.leave-empty {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.leave-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
}

.leave-form-row {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.leave-form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

body.dark-mode .leave-card {
  background: #16213e;
  border-color: #2a2a4a;
}

body.dark-mode .leave-card.status-approved { border-left-color: #28a745; }
body.dark-mode .leave-card.status-pending  { border-left-color: #ffc107; }
body.dark-mode .leave-card.status-rejected { border-left-color: #dc3545; }

body.dark-mode .leave-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body.dark-mode .leave-badge.approved { background: rgba(40, 167, 69, 0.2); color: #6fcf7c; }
body.dark-mode .leave-badge.pending  { background: rgba(255, 193, 7, 0.2); color: #ffd54f; }
body.dark-mode .leave-badge.rejected { background: rgba(220, 53, 69, 0.2); color: #f28b8b; }

body.dark-mode .leave-action-btn.approve { background: rgba(40, 167, 69, 0.2); color: #6fcf7c; }
body.dark-mode .leave-action-btn.reject { background: rgba(220, 53, 69, 0.2); color: #f28b8b; }

/* ============ Responsive additions ============ */
/* ============ Sales Charts ============ */
.chart-container {
  position: relative;
  height: 250px;
  margin-top: 0.5rem;
}

@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .dashboard-row {
    grid-template-columns: 1fr;
  }
  
  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .login-card {
    margin: 1rem;
    padding: 1.5rem;
  }
  
  .chart-container {
    height: 180px;
  }
}

/* ============ Notifications ============ */
.notif-bell {
  position: relative;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 50%;
  transition: var(--transition);
  user-select: none;
}

.notif-bell:hover {
  background: var(--primary-light);
}

.icon-bell {
  width: 20px;
  height: 20px;
  display: block;
  color: var(--text-light);
  transition: var(--transition);
}

.notif-bell:hover .icon-bell {
  color: var(--primary);
}

@keyframes bell-ring {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(12deg); }
  40% { transform: rotate(-12deg); }
  60% { transform: rotate(8deg); }
  80% { transform: rotate(-8deg); }
}

.notif-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #dc3545;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 10px;
  padding: 0 4px;
  display: none;
  animation: badge-pop 0.3s ease-out;
  box-shadow: 0 0 6px rgba(220, 53, 69, 0.6);
}
@keyframes badge-pop {
  0% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.notif-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 340px;
  max-width: calc(100vw - 2rem);
  max-height: 400px;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 1000;
  margin-top: 6px;
}

.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 1;
}

.notif-mark-read {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
}

.notif-mark-read:hover {
  text-decoration: underline;
}

.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notif-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.3;
  cursor: pointer;
}

.notif-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item.notif-danger {
  background: rgba(220, 53, 69, 0.06);
}

.notif-item.notif-warning {
  background: rgba(255, 193, 7, 0.06);
}

.notif-item.notif-info {
  background: rgba(13, 110, 253, 0.04);
}

.notif-msg {
  flex: 1;
  color: var(--text);
}

.notif-time {
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 0.75rem;
  margin-top: 0.1rem;
}

.notif-empty {
  text-align: center;
  padding: 1.5rem 0.8rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ============ Toast Notifications ============ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 300px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--card-bg, #fff);
  color: var(--text, #333);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  font-size: 0.85rem;
  line-height: 1.4;
  animation: toastSlideIn 0.3s ease forwards;
  border-left: 4px solid var(--toast-color, #333);
}

.toast.toast-out {
  animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  width: 20px;
  justify-content: center;
}

.toast-msg {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-muted, #999);
  padding: 0 2px;
  line-height: 1;
  opacity: 0.7;
}

.toast-close:hover {
  opacity: 1;
}

.toast-success {
  --toast-color: #28a745;
  background: #f0fdf4;
  color: #166534;
}

.toast-error {
  --toast-color: #dc3545;
  background: #fef2f2;
  color: #991b1b;
}

.toast-warning {
  --toast-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}

.toast-info {
  --toast-color: #0ea5e9;
  background: #f0f9ff;
  color: #075985;
}

body.dark-mode .toast-success {
  background: #052e16;
  color: #86efac;
}

body.dark-mode .toast-error {
  background: #450a0a;
  color: #fca5a5;
}

body.dark-mode .toast-warning {
  background: #451a03;
  color: #fcd34d;
}

body.dark-mode .toast-info {
  background: #0c1929;
  color: #7dd3fc;
}

body.dark-mode .toast {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* ============ Settings Panel ============ */
.settings-section {
  margin-bottom: 1.8rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.settings-section:last-of-type {
  border-bottom: none;
}
.settings-section h4 {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 0.8rem;
}
.policy-subsection {
  margin-top: 1rem;
  padding: 0.9rem 0.9rem 0.2rem;
  background: var(--primary-light, #fff5f0);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
}
.policy-subsection-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}
.policy-subsection .settings-grid {
  margin-top: 0.4rem;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.settings-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.settings-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.logo-upload-area {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.logo-preview-container {
  width: 120px;
  height: 120px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.logo-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.logo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.logo-placeholder span:first-child {
  font-size: 2rem;
}
.logo-upload-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.color-picker-row input[type="color"] {
  width: 46px;
  height: 40px;
  padding: 2px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: white;
}
.color-hex {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-light);
}
body.dark-mode .settings-section {
  border-bottom-color: #2a2a4a;
}
body.dark-mode .settings-actions {
  border-top-color: #2a2a4a;
}
body.dark-mode .logo-preview-container {
  border-color: #3d2b22;
  background: #1a1a2e;
}

/* ============ Bottom Navigation ============ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  padding: 0.3rem 0 env(safe-area-inset-bottom, 0.3rem) 0;
  z-index: 900;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}

.nav-item {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  background: none;
  border: none;
  padding: 0.3rem 0.15rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  position: relative;
  min-width: 0;
}

.nav-item .nav-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.nav-item .nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}

body.dark-mode .bottom-nav {
  background: #0f0f23;
  border-top-color: #2a2a4a;
}

body.dark-mode .nav-item {
  color: #8a7a6a;
}

body.dark-mode .nav-item.active {
  color: var(--primary);
}

/* ============ FAB (Floating Action Button) ============ */
.fab {
  display: none;
  position: fixed;
  bottom: 5rem;
  right: 1.2rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(212, 76, 47, 0.4);
  z-index: 800;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(212, 76, 47, 0.5);
}

.fab:active {
  transform: scale(0.95);
}

body.dark-mode .fab {
  box-shadow: 0 4px 16px rgba(232, 93, 58, 0.5);
}

/* ============ More Menu (Bottom Sheet) ============ */
.more-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 950;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.more-overlay.hidden {
  display: none;
}

.more-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.2s ease;
}

.more-sheet {
  position: relative;
  background: white;
  border-radius: 1.5rem 1.5rem 0 0;
  padding: 0.8rem 1.5rem env(safe-area-inset-bottom, 1.5rem) 1.5rem;
  width: 100%;
  max-width: 500px;
  animation: slideUp 0.25s ease;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
}

.more-handle {
  width: 36px;
  height: 4px;
  background: #ddd;
  border-radius: 4px;
  margin: 0 auto 0.8rem;
}

.more-title {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 0.8rem;
  text-align: center;
}

.more-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.more-item {
  background: var(--bg-card);
  border: 1px solid var(--primary-light);
  border-radius: 1.2rem;
  padding: 1rem 0.8rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
}

.more-item:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

body.dark-mode .more-sheet {
  background: #16213e;
}

body.dark-mode .more-handle {
  background: #3d2b22;
}

body.dark-mode .more-item {
  background: #1a1a2e;
  border-color: #2a2a4a;
  color: var(--text);
}

body.dark-mode .more-item:hover {
  background: #2a2a4a;
}

/* ============ Mobile-First Layout ============ */
@media (max-width: 768px) {
  body {
    padding: 0;
    background: #f5f0ed;
    align-items: stretch;
  }

  .app {
    border-radius: 0;
    box-shadow: none;
    padding: 0.8rem 0.8rem 5.5rem;
    max-width: 100%;
    min-height: 100vh;
  }

  .header {
    padding: 0.4rem 0;
    margin-bottom: 0.8rem;
  }

  .header-brand-text h1 {
    font-size: 1.2rem;
  }

  .header-brand-text .subtitle {
    font-size: 0.65rem;
  }

  .header-right {
    gap: 0.05rem;
  }

  .theme-toggle {
    width: 36px;
    height: 22px;
  }

  .theme-toggle::before {
    width: 16px;
    height: 16px;
    top: 3px;
    left: 3px;
  }

  body.dark-mode .theme-toggle::before {
    transform: translateX(14px);
  }

  .theme-toggle::after {
    font-size: 9px;
  }

  body.dark-mode .theme-toggle::after {
    right: 5px;
  }

  .theme-toggle:active {
    transform: scale(0.95);
  }

  .user-avatar {
    width: 30px;
    height: 30px;
    font-size: 0.7rem;
  }

  .icon-bell {
    width: 18px;
    height: 18px;
  }

  .notif-bell {
    padding: 0.25rem;
  }

  .notif-badge {
    top: -4px;
    right: -4px;
    min-width: 14px;
    height: 14px;
    line-height: 14px;
    font-size: 0.55rem;
  }

  .header-logo {
    height: 40px;
  }

  .bottom-nav {
    display: flex;
  }

  /* Shrink labels/icon so up to 6 items fit comfortably on small phones */
  .nav-item .nav-label {
    font-size: 0.6rem;
  }

  .nav-item .nav-icon {
    font-size: 1.25rem;
  }

  .fab {
    display: flex;
  }

  #topTabs {
    display: none !important;
  }

  .card {
    padding: 1rem;
    border-radius: 1.2rem;
    margin-bottom: 1rem;
  }

  h3 {
    font-size: 1rem;
    margin-bottom: 0.6rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .dashboard-stat {
    padding: 0.8rem;
  }

  .dashboard-stat .stat-value {
    font-size: 1.4rem;
  }

  .dashboard-stat .stat-icon {
    font-size: 1.4rem;
  }

  .dashboard-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .row-flex {
    flex-direction: column;
    align-items: stretch;
  }

  .row-flex .form-input,
  .row-flex .form-select,
  .row-flex input,
  .row-flex select {
    width: 100% !important;
  }

  #markAttendanceForm .row-flex {
    align-items: stretch !important;
  }

  #markAttendanceForm .row-flex > div {
    width: 100% !important;
    flex: none !important;
    min-width: 0 !important;
  }

  button {
    padding: 0.7rem 1rem;
    font-size: 0.85rem;
    width: 100%;
    justify-content: center;
  }

  .btn-sm {
    padding: 0.5rem 0.8rem;
  }

  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 0.5rem 0.4rem;
    white-space: nowrap;
  }

  .summary-number {
    font-size: 1.6rem;
  }

  .login-card {
    margin: 1rem;
    padding: 1.5rem;
  }

  .chart-container {
    height: 180px;
  }

  .notif-dropdown {
    width: 300px;
    right: 0;
    max-width: calc(100vw - 2rem);
  }

  .more-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form .form-group {
    min-width: unset;
  }

  .logo-preview-container {
    width: 80px;
    height: 80px;
  }

  .toast {
    min-width: unset;
    max-width: calc(100vw - 2rem);
    width: 100%;
    padding: 6px 10px;
    gap: 4px;
    font-size: 0.75rem;
    border-radius: 6px;
  }

  .toast-icon {
    font-size: 0.85rem;
    width: 16px;
  }

  .toast-close {
    font-size: 0.8rem;
    padding: 0;
    width: 16px;
  }

  .toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }

  /* FAB positioning for mobile */
  .fab {
    bottom: 5rem;
    right: 1rem;
    width: 52px;
    height: 52px;
    font-size: 1.3rem;
  }

  .scrollable-list {
    max-height: 200px;
  }
}

/* ============ Desktop keeps top tabs, no bottom nav ============ */
@media (min-width: 769px) {
  .bottom-nav {
    display: none !important;
  }

  .fab {
    display: none !important;
  }

  .more-overlay {
    display: none !important;
  }

  #topTabs {
    display: flex !important;
  }
}

/* ============ Inventory Cards ============ */
.inv-stats {
  display: flex;
  gap: 0.8rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}
.inv-stats strong {
  color: var(--text);
}

.inv-search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 2rem;
  padding: 0.4rem 1rem;
  margin-bottom: 0.6rem;
  transition: var(--transition);
}
.inv-search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212, 76, 47, 0.1);
}
.inv-search-icon {
  font-size: 1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.inv-search-input {
  border: none;
  background: none;
  outline: none;
  font-size: 0.9rem;
  color: var(--text);
  width: 100%;
}
.inv-search-input::placeholder {
  color: var(--text-muted);
}

.inv-categories {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.6rem;
  margin-bottom: 0.4rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.inv-categories::-webkit-scrollbar {
  display: none;
}
.inv-cat-chip {
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 2rem;
  padding: 0.35rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.inv-cat-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}
.inv-cat-chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.inv-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.inv-card-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

.inv-item-card {
  background: var(--card-bg);
  border: 1px solid var(--primary-light);
  border-left: 4px solid var(--border);
  border-radius: 1.2rem;
  padding: 0.8rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: var(--transition);
}
.inv-item-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.inv-item-low { border-left-color: #e65100; }
.inv-item-empty { border-left-color: #dc3545; }
.inv-item-ok { border-left-color: #28a745; }

.inv-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.inv-card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inv-card-menu {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.2rem;
  flex-shrink: 0;
}

.inv-card-body {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.inv-card-stock {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.inv-stock-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.inv-stock-dot.ok { background: #28a745; }
.inv-stock-dot.low { background: #ffc107; }
.inv-stock-dot.empty { background: #dc3545; }

.inv-stock-value {
  font-size: 1.4rem;
  font-weight: 700;
}
.inv-stock-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.inv-card-price {
  font-size: 0.9rem;
  color: var(--text-light);
  font-weight: 600;
}
.inv-card-category {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 1rem;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
}

.inv-card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}
.inv-qty-input {
  width: 65px;
  padding: 0.4rem 0.3rem;
  border-radius: 0.8rem;
  border: 1.5px solid var(--border);
  font-size: 0.85rem;
  text-align: center;
  background: white;
  color: var(--text);
  outline: none;
}
.inv-qty-input:focus {
  border-color: var(--primary);
}
.inv-action-btn {
  padding: 0.5rem 0.9rem;
  border-radius: 0.8rem;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 42px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.inv-btn-primary {
  flex: 1;
  min-height: 44px;
  font-weight: 700;
  font-size: 0.9rem;
}
.inv-primary-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.inv-item-admin {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
  align-items: center;
}
.inv-action-btn.bal { background: #e8f5e9; color: #2e7d32; }
.inv-action-btn.bal:hover { background: #c8e6c9; }
.inv-action-btn.add { background: #e3f2fd; color: #1565c0; flex: 1; min-height: 44px; font-weight: 700; }
.inv-action-btn.add:hover { background: #bbdefb; }
.inv-action-btn.free { background: #fff3e0; color: #e65100; }
.inv-action-btn.free:hover { background: #ffe0b2; }
.inv-action-btn.dmg { background: #fce4ec; color: #c62828; }
.inv-action-btn.dmg:hover { background: #f8bbd0; }
.inv-action-btn.edit { background: #f3e5f5; color: #6a1b9a; min-width: 42px; font-size: 1.05rem; opacity: 0.7; }
.inv-action-btn.edit:hover { background: #e1bee7; opacity: 1; }
.inv-action-btn.del { background: #ffebee; color: #b71c1c; min-width: 42px; font-size: 1.05rem; opacity: 0.7; }
.inv-action-btn.del:hover { background: #ffcdd2; opacity: 1; }
.inv-action-btn.rec { background: #e8f5e9; color: #2e7d32; }
.inv-action-btn.rec:hover { background: #c8e6c9; }
.inv-action-btn.ret { background: #e3f2fd; color: #1971c2; width: 100%; min-height: 44px; font-weight: 700; font-size: 0.9rem; }
.inv-action-btn.ret:hover { background: #bbdefb; }

.inv-add-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px dashed var(--border);
}
.inv-add-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.inv-rec-form {
  width: 100%;
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px dashed var(--border);
}
.inv-rec-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
  font-size: 0.82rem;
}
.inv-rec-row label {
  min-width: 62px;
  font-weight: 600;
  color: var(--text);
}
.inv-rec-input {
  width: 68px;
  padding: 0.25rem 0.3rem;
  border-radius: 0.6rem;
  border: 1.5px solid var(--border);
  font-size: 0.85rem;
  text-align: center;
  outline: none;
  background: white;
  color: var(--text);
}
.inv-rec-input:focus {
  border-color: var(--primary);
}
.inv-rec-btns {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.3rem;
}
.inv-rec-summary {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.2rem 0 0 0;
  display: flex;
  gap: 0.5rem;
  border-top: 1px dashed var(--border);
  margin-top: 0.2rem;
  padding-top: 0.25rem;
}
body.dark-mode .inv-rec-input {
  background: #1a1a2e;
  border-color: #3d2b22;
  color: var(--text);
}

body.dark-mode .inv-search-bar {
  background: #1a1a2e;
  border-color: #3d2b22;
}
body.dark-mode .inv-search-input {
  color: var(--text);
}
body.dark-mode .inv-cat-chip {
  background: #1a1a2e;
  border-color: #3d2b22;
}
body.dark-mode .inv-cat-chip:hover {
  background: #2a2a4a;
}
body.dark-mode .inv-item-card {
  background: #16213e;
  border-color: #2a2a4a;
}
body.dark-mode .inv-qty-input {
  background: #1a1a2e;
  border-color: #3d2b22;
  color: var(--text);
}
body.dark-mode .inv-card-empty {
  background: #16213e;
  border-color: #2a2a4a;
}

/* ============ Inventory Activity ============ */
.inv-activity-details {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--primary-light);
  margin-bottom: 1rem;
  overflow: hidden;
}
.inv-activity-summary {
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  user-select: none;
}
.inv-activity-summary:hover {
  background: var(--primary-light);
}
.inv-activity-list {
  padding: 0 1rem 0.6rem;
  font-size: 0.8rem;
  max-height: 150px;
  overflow-y: auto;
}

/* ============ Bottom Sheet ============ */
.bottom-sheet-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 950;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.bottom-sheet-overlay.hidden {
  display: none;
}
.bottom-sheet-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  animation: fadeIn 0.2s ease;
}
.bottom-sheet {
  position: relative;
  background: var(--card-bg, white);
  border-radius: 1.5rem 1.5rem 0 0;
  padding: 0.8rem 1.5rem env(safe-area-inset-bottom, 1.5rem) 1.5rem;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.12);
}
.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: #ddd;
  border-radius: 4px;
  margin: 0 auto 0.8rem;
}
.bottom-sheet-title {
  font-size: 1.1rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  text-align: center;
}
.bottom-sheet-form {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.bs-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.bs-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}
.bs-field input,
.bs-field select {
  width: 100%;
  padding: 0.7rem 1rem;
  border-radius: 1rem;
  border: 1.5px solid var(--border);
  font-size: 0.9rem;
  background: var(--bg, white);
  color: var(--text);
  outline: none;
  transition: var(--transition);
}
.bs-field input:focus,
.bs-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212,76,47,0.1);
}
.bs-row {
  display: flex;
  gap: 0.8rem;
}
.bs-half {
  flex: 1;
}
.bs-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  padding: 0.3rem 0;
}
.bs-toggle-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}
.bs-conv-fields {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 0.6rem 0.8rem;
  margin-top: 0.2rem;
  background: var(--primary-light);
  border-radius: 0.8rem;
}
body.dark-mode .bs-conv-fields {
  background: #1a1a3e;
}
.bs-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.bs-actions button {
  flex: 1;
  justify-content: center;
  padding: 0.75rem;
}

body.dark-mode .bottom-sheet {
  background: #16213e;
}
body.dark-mode .bottom-sheet-handle {
  background: #3d2b22;
}

/* Backend-stock edit/add sheet: keep actions clear of the gesture bar
   without depending on viewport-fit=cover (safe-area fallback to real px). */
.bs-sheet {
  padding: 0.8rem 1.5rem calc(env(safe-area-inset-bottom, 0px) + 1.5rem) 1.5rem;
  max-height: 90vh;
}
.bs-sheet .bs-actions {
  margin-top: 0.75rem;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px));
}
body.dark-mode .bs-field input,
body.dark-mode .bs-field select {
  background: #1a1a2e;
  border-color: #3d2b22;
}
body.dark-mode .inv-activity-details {
  background: #16213e;
  border-color: #2a2a4a;
}
body.dark-mode .inv-activity-summary:hover {
  background: #2a2a4a;
}

/* Party order line-item repeater */
.party-add-item {
  margin: 0.4rem 0 0.2rem;
  background: var(--primary-light, #fff5f0);
  color: var(--primary, #d44c2f);
  border: 1px dashed var(--primary, #d44c2f);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.party-item-row {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1fr auto;
  gap: 0.4rem;
  align-items: center;
  margin-top: 0.4rem;
}
.party-item-row select,
.party-item-row input {
  width: 100%;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  font-size: 0.82rem;
  background: var(--bg, #fff);
  color: var(--text, #222);
}
.party-item-remove {
  background: #ffe3e3;
  color: #c92a2a;
  border: none;
  border-radius: 8px;
  width: 30px;
  height: 32px;
  font-size: 0.8rem;
  cursor: pointer;
}

/* ============ Party Order Form — Modern Polish ============ */
.bs-hero {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: -0.2rem -0.2rem 0.8rem;
  padding: 1rem 1.1rem;
  border-radius: 1.1rem 1.1rem 0 0;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgba(212, 76, 47, 0.25);
  animation: fadeIn 0.25s ease;
}
.bs-hero-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  flex-shrink: 0;
}
.bs-hero-text {
  display: flex;
  flex-direction: column;
}
.bs-hero .bottom-sheet-title {
  color: #fff;
  text-align: left;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.bs-hero-sub {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
}

.bs-section-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.5rem 0 0.1rem;
  letter-spacing: 0.02em;
}

/* Floating labels (text/number inputs) */
.float-field {
  position: relative;
}
.float-field input {
  padding: 1.15rem 1rem 0.45rem;
}
.float-field label {
  position: absolute;
  left: 1rem;
  top: 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
  transition: all 0.15s ease;
  background: transparent;
}
.float-field input:focus + label,
.float-field input:not(:placeholder-shown) + label {
  top: 0.35rem;
  font-size: 0.62rem;
  color: var(--primary);
}
.float-field select {
  padding: 1.15rem 1rem 0.45rem;
}
.float-field select + label {
  top: 0.35rem;
  font-size: 0.62rem;
  color: var(--primary);
}

/* Inline validation */
.bs-field {
  position: relative;
}
.bs-error {
  display: block;
  visibility: hidden;
  height: 0.85rem;
  font-size: 0.68rem;
  color: var(--danger);
  padding-left: 0.2rem;
}
.bs-field.invalid input,
.bs-field.invalid select,
.bs-field.invalid textarea {
  border-color: var(--danger) !important;
  animation: shake 0.3s ease;
}
.bs-field.invalid .bs-error {
  visibility: visible;
}
.bs-field.invalid label {
  color: var(--danger);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* Animated total bar */
.party-total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.1rem;
  margin: 0.2rem 0;
  border-radius: 1rem;
  background: linear-gradient(135deg, var(--primary-light) 0%, #fff 100%);
  border: 1.5px solid var(--border);
}
.party-total-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
}
.party-total-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary-dark);
}
.party-total-bar.pulse {
  animation: totalPulse 0.35s ease;
}
@keyframes totalPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* Dark mode */
body.dark-mode .bs-hero {
  background: linear-gradient(135deg, #b83a22 0%, #7a2614 100%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
body.dark-mode .bs-section-label {
  color: #ff9e80;
}
body.dark-mode .float-field label {
  color: #b0a39c;
}
body.dark-mode .float-field input:focus + label,
body.dark-mode .float-field input:not(:placeholder-shown) + label {
  color: #ff9e80;
}
body.dark-mode .party-total-bar {
  background: linear-gradient(135deg, #2a1a14 0%, #1a1a2e 100%);
  border-color: #3d2b22;
}
body.dark-mode .party-total-label {
  color: #d9c4ba;
}
body.dark-mode .party-total-value {
  color: #ff9e80;
}

/* ============ PIN Lock Overlay ============ */
.pin-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

.pin-overlay.hidden {
  display: none;
}

.pin-card {
  background: var(--card-bg, #fff);
  border-radius: 2rem;
  padding: 2rem 2rem 1.5rem;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.pin-header {
  margin-bottom: 0.5rem;
}

.pin-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary, #d44c2f);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 0.3rem;
}

.pin-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text, #3d2b22);
}

.pin-label {
  font-size: 0.85rem;
  color: var(--text-muted, #999);
  margin-bottom: 1rem;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  min-height: 16px;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border, #ccc);
  transition: all 0.15s ease;
}

.pin-dot.filled {
  background: var(--primary, #d44c2f);
  border-color: var(--primary, #d44c2f);
}

.pin-error {
  color: var(--danger, #dc3545);
  font-size: 0.8rem;
  min-height: 1.2rem;
  margin-bottom: 0.5rem;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  max-width: 240px;
  margin: 0 auto;
}

.pin-key {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  background: var(--bg-card, #f5f5f5);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text, #333);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  padding: 0;
}

.pin-key:hover {
  background: var(--border, #ddd);
}

.pin-key:active {
  background: var(--primary-light, #e8d5c4);
  transform: scale(0.95);
}

.pin-key-blank {
  background: transparent !important;
  cursor: default;
  pointer-events: none;
}

.pin-key-back {
  font-size: 1.2rem;
}

.pin-alt-btn {
  background: none;
  border: none;
  color: var(--primary, #d44c2f);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.75rem 0 0;
  width: 100%;
  text-align: center;
  display: inline-block;
}

.pin-alt-btn:hover {
  text-decoration: underline;
}

.pin-setup-title {
  font-size: 1.2rem;
  color: var(--text, #3d2b22);
  margin-bottom: 0.3rem;
}

.pin-setup-desc {
  font-size: 0.8rem;
  color: var(--text-muted, #999);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.pin-setup-step {
  font-size: 0.85rem;
  color: var(--text-muted, #999);
  margin-bottom: 0.5rem;
}

body.dark-mode .pin-card {
  background: #16213e;
}

body.dark-mode .pin-key {
  background: #2a2a4a;
  color: #e8d5c4;
}

body.dark-mode .pin-key:hover {
  background: #3d3d5c;
}

body.dark-mode .pin-key:active {
  background: var(--primary-dark, #b83a22);
}

body.dark-mode .pin-overlay {
  background: rgba(0, 0, 0, 0.75);
}

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

/* ============ Dark mode extras ============ */
body.dark-mode .more-backdrop {
  background: rgba(0, 0, 0, 0.6);
}

body.dark-mode {
  background: #1a1a2e;
}

/* ============ Backend Stock ============ */
.bs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.bs-header h3 {
  margin: 0;
  font-size: 1.15rem;
}
.bs-header-actions {
  display: flex;
  gap: 0.4rem;
}
.bs-btn-add-item {
  background: linear-gradient(135deg, #43a047, #2e7d32);
  color: #fff;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 2rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(46,125,50,0.2);
  transition: all 0.2s;
}
.bs-btn-add-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(46,125,50,0.3);
}
/* ─── Backend Stock accordion (color-coded, collapsed by default) ─── */
.bs-accordion {
  border: 1px solid var(--border);
  border-left: 4px solid var(--bs-cat, var(--border));
  border-radius: 0.8rem;
  margin-bottom: 0.6rem;
  overflow: hidden;
  background: color-mix(in srgb, var(--bs-cat, #888) 7%, var(--card-bg));
}
.bs-accordion-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  user-select: none;
}
.bs-accordion-header:active { transform: scale(0.995); }
.bs-accordion-chevron {
  font-size: 0.7rem;
  color: var(--bs-cat, var(--text-muted));
  width: 1rem;
  text-align: center;
  transition: transform 0.15s ease;
}
.bs-accordion-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--bs-cat, var(--text));
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: 1;
}
.bs-accordion-body {
  padding: 0.5rem 0.6rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.bs-accordion-body.collapsed { display: none; }
.bs-accordion-loading {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.3rem 0.2rem;
}
/* Keep per-item stock-level tints; they sit inside the category color block. */
.bs-accordion-body .bs-item {
  background: var(--card-bg);
}
.bs-category {
  background: none;
  border-radius: 0;
  padding: 0;
  margin-bottom: 1rem;
  border: none;
}
.bs-cat-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0 0.35rem;
  border-bottom: 2px solid var(--primary-light);
  margin-bottom: 0.15rem;
}
.bs-item {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.6rem 0.7rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: box-shadow 0.15s, transform 0.1s;
}
.bs-item:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
}
.bs-item-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.bs-item-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}
.bs-item-admin {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
  align-items: center;
}
.bs-item-conv {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
  background: rgba(212,76,47,0.08);
  padding: 0.12rem 0.5rem;
  border-radius: 0.6rem;
}
.bs-alerts {
  margin-bottom: 0.75rem;
}
.bs-stock-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.bs-dot-ok { background: #28a745; }
.bs-dot-low { background: #e65100; }
.bs-dot-empty { background: #dc3545; }
.bs-item-low { background: #fff3e0; border-left-color: #e65100; }
.bs-item-empty { background: #ffebee; border-left-color: #dc3545; }
body.dark-mode .bs-item-low { background: #3d2b1a; border-left-color: #e65100; }
body.dark-mode .bs-item-empty { background: #3d1a1a; border-left-color: #dc3545; }
.bs-item-name {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}
.bs-item-qty {
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--text-light);
  padding: 0.15rem 0.6rem;
  border-radius: 1rem;
  min-width: 60px;
  text-align: center;
  white-space: nowrap;
}
.bs-item-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.bs-item-actions.hidden { display: none; }
.bs-adjust {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
  flex-shrink: 0;
}
.bs-adjust.hidden { display: none; }
.bs-btn {
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.bs-btn-add, .bs-btn-use {
  flex: 1;
  min-height: 42px;
  padding: 0 0.5rem;
  border-radius: 0.6rem;
  font-size: 0.85rem;
}
.bs-btn-add {
  background: #e8f5e9;
  color: #2e7d32;
}
.bs-btn-add:hover { background: #c8e6c9; }
.bs-btn-use {
  background: #fce4ec;
  color: #c62828;
}
.bs-btn-use:hover { background: #f8bbd0; }
.bs-btn-edit, .bs-btn-del {
  background: none;
  font-size: 1rem;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 0.5rem;
  opacity: 0.7;
  line-height: 1;
}
.bs-btn-edit:hover, .bs-btn-del:hover {
  opacity: 1;
  background: var(--primary-light);
}
.bs-btn-confirm, .bs-btn-cancel {
  min-height: 42px;
  padding: 0 0.8rem;
  border-radius: 0.6rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.bs-btn-confirm {
  background: #e8f5e9;
  color: #2e7d32;
}
.bs-btn-cancel {
  background: #eee;
  color: #666;
}
.bs-btn-cancel:hover { background: #ddd; }
.bs-adj-input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  width: auto;
  padding: 0.3rem 0.5rem;
  border-radius: 0.6rem;
  border: 1.5px solid var(--border);
  font-size: 0.95rem;
  text-align: center;
  outline: none;
  background: white;
  color: var(--text);
}
.bs-adj-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212,76,47,0.1);
}
body.dark-mode .bs-adj-input {
  background: #1a1a2e;
  border-color: #3d2b22;
  color: var(--text);
}
body.dark-mode .bs-btn-add-item {
  background: linear-gradient(135deg, #388e3c, #1b5e20);
}
body.dark-mode .bs-btn-cancel {
  background: #2a2a4a;
  color: #aaa;
}
body.dark-mode .bs-btn-cancel:hover {
  background: #3d3d5c;
}
body.dark-mode .bs-category {
  background: #16213e;
  border-color: #2a2a4a;
}
body.dark-mode .bs-cat-title {
  border-color: #2a2a4a;
}
body.dark-mode .bs-accordion {
  background: color-mix(in srgb, var(--bs-cat, #888) 14%, #16213e);
  border-color: #2a2a4a;
}
body.dark-mode .bs-accordion-body .bs-item {
  background: #16213e;
}
body.dark-mode .bs-item:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
body.dark-mode .bs-item-qty {
  background: #2a2a4a;
  color: #ccc;
}
body.dark-mode .bs-btn-edit, body.dark-mode .bs-btn-del {
  opacity: 0.4;
}
body.dark-mode .bs-btn-edit:hover, body.dark-mode .bs-btn-del:hover {
  opacity: 1;
  background: #2a2a4a;
}

/* Fix: keep adjust row + action buttons inside the card on mobile.
   The global `button { width: 100% }` mobile rule overflows the
   flex rows below, pushing ✓/✕ past the card border. */
@media (max-width: 768px) {
  .bs-adjust {
    flex-wrap: nowrap;
  }
  .bs-adj-input {
    flex: 1 1 auto;
    min-width: 0;
  }
  .bs-btn-confirm, .bs-btn-cancel,
  .bs-btn-add, .bs-btn-use,
  .bs-btn-edit, .bs-btn-del {
    width: auto;
    flex-shrink: 0;
  }
  .bs-item-actions {
    flex-wrap: nowrap;
  }
}

/* ============ Backend Stock Activity ============ */
.bs-activity {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}
.bs-activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  user-select: none;
}
.bs-activity-header:hover {
  color: var(--text);
}
.bs-activity-toggle {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.bs-activity-body {
  max-height: 300px;
  overflow-y: auto;
}
.bs-activity-body.hidden {
  display: none;
}
.bs-act-entry {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--primary-light);
}
.bs-act-entry:last-child {
  border-bottom: none;
}
.bs-act-sign {
  font-weight: 700;
  font-size: 0.9rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}
.bs-act-add .bs-act-sign { color: #2e7d32; }
.bs-act-use .bs-act-sign { color: #c62828; }
.bs-act-detail {
  flex: 1;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bs-act-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}
body.dark-mode .bs-activity {
  border-color: #2a2a4a;
}
body.dark-mode .bs-act-entry {
  border-color: #2a2a4a;
}

/* ============ Party Orders ============ */
/* ─── Party Orders ─── */
.party-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  margin-bottom: 0.75rem;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s, transform 0.15s;
}
.party-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}
.party-card-topbar {
  height: 4px;
}
.party-card-inner {
  padding: 0.75rem 1rem 0.85rem;
}
.party-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}
.party-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.party-head-info {
  flex: 1;
  min-width: 0;
}
.party-head-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.party-head-date {
  font-size: 0.7rem;
  font-weight: 600;
  color: #155724;
  background: #d4edda;
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 0.5rem;
  margin-top: 0.1rem;
  white-space: nowrap;
  width: fit-content;
}
.party-order-num {
  font-weight: 700;
}
.party-head-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.1rem;
}
.party-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 1.5rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.party-addr {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.3rem 0 0.3rem 0;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 0.5rem;
}
.party-order-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem 0.75rem;
  margin-bottom: 0.65rem;
}
.party-sum-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--border);
}
.party-sum-full {
  grid-column: 1 / -1;
}
.party-sum-label {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.party-sum-val {
  font-weight: 600;
  font-size: 0.8rem;
  text-align: right;
}
.party-pricing {
  background: var(--primary-light, #fff5f0);
  border-radius: 0.65rem;
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.6rem;
}
.party-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  padding: 0.15rem 0;
}
.party-price-amt {
  font-weight: 700;
  font-size: 0.9rem;
}
.party-balance-row {
  border-top: 1px solid rgba(0,0,0,0.08);
  margin-top: 0.15rem;
  padding-top: 0.3rem;
}
.party-balance-amt {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary);
}
.party-progress-bar {
  height: 4px;
  background: #e0e0e0;
  border-radius: 4px;
  margin-top: 0.4rem;
  overflow: hidden;
}
.party-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.party-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.party-btn {
  padding: 0.35rem 0.6rem;
  border-radius: 0.55rem;
  border: none;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.party-btn:active {
  transform: scale(0.95);
}
.party-btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.party-btn-primary {
  background: #004085;
  color: #fff;
}
.party-btn-success {
  background: #155724;
  color: #fff;
}
.party-btn-danger {
  background: transparent;
  border: 1px solid #dc3545;
  color: #dc3545;
}
.party-btn-danger:hover {
  background: #dc3545;
  color: #fff;
}
.party-search-bar {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 2rem;
  padding: 0.3rem 1rem;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
  transition: var(--transition);
}
.party-search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212,76,47,0.1);
}
.party-search-icon {
  font-size: 0.9rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.party-search-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.85rem;
  color: var(--text);
  width: 100%;
  padding: 0.4rem 0;
}
body.dark-mode .party-search-bar {
  background: #1a1a2e;
  border-color: #2a2a4a;
}

.party-filter-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.party-filter-btn {
  padding: 0.3rem 0.7rem;
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}
.party-filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
body.dark-mode .party-card {
  background: #1a1a2e;
  border-color: #2a2a4a;
}
body.dark-mode .party-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
body.dark-mode .party-pricing {
  background: #1e1e3a;
}
body.dark-mode .party-progress-bar {
  background: #2a2a4a;
}

/* Generic utility: hidden elements are not displayed (used by confirm modal input wrap, etc.) */
.hidden { display: none; }

/* ─── Party Close Modal ─── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden {
  display: none;
}
/* Confirm dialog must stack above other modals (e.g. reconcile) so its buttons stay clickable when nested */
#confirmModal {
  z-index: 1100;
}
.modal-panel {
  background: var(--card-bg, #fff);
  border-radius: 1.25rem;
  padding: 1.5rem;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: slideUp 0.25s ease;
}
.modal-header h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.1rem;
}
.modal-body {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 1.25rem;
  max-height: 70vh;
  overflow-y: auto;
}
.modal-body .balance-amount {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  display: block;
  text-align: center;
  margin: 0.75rem 0;
}
.modal-actions {
  display: flex;
  gap: 0.6rem;
}
.modal-actions button {
  flex: 1;
  padding: 0.7rem;
  justify-content: center;
  font-size: 0.9rem;
}
body.dark-mode .modal-panel {
  background: #1a1a2e;
}

/* Reconciliation Adjustment modal (stacks above the reconcile modal) */
#reconcileAdjustModal {
  z-index: 1100;
}
.rec-adj-field {
  margin-bottom: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.rec-adj-field label {
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  font-weight: 600;
}
.rec-adjust-btn {
  background: var(--primary, #d44c2f);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
}
.rec-adjust-btn:hover { opacity: 0.9; }
.rec-adj-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.rec-adj-list li {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #eee);
  border-radius: 0.5rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.82rem;
}
.rec-adj-type {
  display: inline-block;
  background: rgba(212, 76, 47, 0.12);
  color: var(--primary, #d44c2f);
  border-radius: 0.35rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  margin-right: 0.35rem;
  text-transform: capitalize;
}
.rec-adj-list small { color: var(--text-muted, #999); margin-left: 0.3rem; }

/* ─── Dashboard Version Bar ─── */
#versionBar {
  margin-top: 1rem;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted, #999);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
  user-select: none;
}
#versionBar:hover { background: var(--primary-light, #e8d5c4); }
#versionBar.checking { color: var(--primary, #d44c2f); }
#versionBar.has-update { color: #28a745; font-weight: 600; }
#versionBar.error { color: var(--danger, #dc3545); }

/* ============ Party Calendar ============ */
.party-calendar-wrap {
  margin-bottom: 0.5rem;
  max-width: 440px;
}

.party-calendar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.5rem 0.6rem 0.4rem;
}

/* Party Orders calendar — reuses .calendar-grid/.day-cell/.cell-tooltip (same system as Team Calendar) */
.calendar-grid .day-cell.has-orders {
  background: rgba(0, 0, 0, 0.05);
}
.calendar-grid .day-cell.party-pending {
  background: rgba(255, 193, 7, 0.30);
  border: 2px solid #ffc107;
}
.calendar-grid .day-cell.party-confirmed {
  background: rgba(59, 130, 246, 0.30);
  border: 2px solid #3b82f6;
}
.calendar-grid .day-cell.party-closed {
  background: rgba(40, 167, 69, 0.30);
  border: 2px solid #28a745;
}
.calendar-grid .day-cell.party-cancelled {
  background: rgba(108, 117, 125, 0.30);
  border: 2px solid #6c757d;
}

.party-mini-dots {
  display: flex;
  gap: 2px;
  margin-top: 2px;
  justify-content: center;
}
.party-mini-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}
.party-mini-dot.party-pending { background: #ffc107; }
.party-mini-dot.party-confirmed { background: #3b82f6; }
.party-mini-dot.party-closed { background: #28a745; }
.party-mini-dot.party-cancelled { background: #6c757d; }

.calendar-legend .dot-party-pending { background: #ffc107; }
.calendar-legend .dot-party-confirmed { background: #3b82f6; }
.calendar-legend .dot-party-closed { background: #28a745; }
.calendar-legend .dot-party-cancelled { background: #6c757d; }

.cell-tooltip .tt-dot.party-pending { background: #ffc107; }
.cell-tooltip .tt-dot.party-confirmed { background: #3b82f6; }
.cell-tooltip .tt-dot.party-closed { background: #28a745; }
.cell-tooltip .tt-dot.party-cancelled { background: #6c757d; }

body.dark-mode .calendar-grid .day-cell.has-orders {
  background: rgba(255, 255, 255, 0.06);
}
body.dark-mode .calendar-grid .day-cell.party-pending {
  background: rgba(255, 193, 7, 0.40);
}
body.dark-mode .calendar-grid .day-cell.party-confirmed {
  background: rgba(59, 130, 246, 0.42);
}
body.dark-mode .calendar-grid .day-cell.party-closed {
  background: rgba(40, 167, 69, 0.42);
}
body.dark-mode .calendar-grid .day-cell.party-cancelled {
  background: rgba(108, 117, 125, 0.42);
}

/* ============ Clocked-In Lock Splash ============ */
.clock-lock-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, #ffe8d6 100%);
  padding: 1.5rem;
  animation: fadeIn 0.2s ease;
}
.clock-lock-overlay.hidden {
  display: none;
}
.clock-lock-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--primary-light);
  border-radius: 1.6rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
  padding: 2rem 1.6rem;
  text-align: center;
  max-width: 360px;
  width: 100%;
}
.clock-lock-logo {
  font-size: 3rem;
  margin-bottom: 0.4rem;
}
.clock-lock-title {
  color: var(--primary);
  font-size: 1.4rem;
  margin: 0 0 0.4rem;
}
.clock-lock-msg {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 1.4rem;
  line-height: 1.5;
}
.clock-lock-btn {
  width: 100%;
  justify-content: center;
  font-size: 1.15rem;
  padding: 0.9rem 2rem;
  border-radius: var(--radius-sm);
}
.clock-lock-timer {
  font-size: 2.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: 'Courier New', monospace;
  color: var(--primary);
  margin: 0.3rem 0 0.6rem;
  letter-spacing: 0.04em;
}
body.dark-mode .clock-lock-overlay {
  background: linear-gradient(135deg, #1a1a2e 0%, #2a1a2e 100%);
}
body.dark-mode .clock-lock-card {
  background: #16213e;
  border-color: #2a2a4a;
  color: var(--text);
}

/* ===== Past Closings (premium cards) ===== */
.closing-card {
  background: var(--bg-card);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.closing-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
}
.closing-card.expanded {
  border-color: var(--primary);
}
.closing-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.closing-head-toggle {
  cursor: pointer;
  user-select: none;
}
.closing-head-toggle:active { opacity: 0.7; }
.closing-head-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.closing-date {
  font-weight: 600;
  color: var(--text-light);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.closing-net {
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.15rem 0.6rem;
  border-radius: 2rem;
}
.closing-net.pos { color: var(--success); background: rgba(40, 167, 69, 0.12); }
.closing-net.neg { color: var(--danger); background: rgba(220, 53, 69, 0.12); }
.closing-chevron {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.18s ease;
}
.closing-card.expanded .closing-chevron {
  transform: rotate(180deg);
}

.closing-detail {
  display: none;
  margin-top: 0.55rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border);
  animation: closingDetailIn 0.18s ease;
}
.closing-card.expanded .closing-detail {
  display: block;
}
@keyframes closingDetailIn {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.closing-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.55rem;
}
.cl-stat {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.cl-stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.cl-stat-val {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}
.cl-stat-val.neg { color: var(--danger); }

.closing-partners {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.partner-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
}
.partner-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.partner-avatar.alt {
  background: linear-gradient(135deg, #2a9d8f 0%, #1d6f63 100%);
}
.partner-info {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}
.partner-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.partner-amt {
  font-size: 0.8rem;
  color: var(--text-light);
}

/* Restyle the Mark / Paid toggle as a premium pill (used in Past closings) */
.sm-paid-btn {
  flex: 0 0 auto;
  width: auto;
  border: 1.5px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.35rem 0.9rem;
  border-radius: 2rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, color 0.15s ease;
}
.sm-paid-btn:hover { background: var(--primary-light); }
.sm-paid-btn:active { transform: scale(0.96); }
.sm-paid-btn.paid {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
  cursor: not-allowed;
  opacity: 0.92;
}
.sm-paid-btn.paid:active { transform: none; }

/* ===== Common Fund card (Partner Settlement) ===== */
.cf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.cf-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cf-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.7rem 0;
}
.cf-stat {
  flex: 1 1 140px;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
}
.cf-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.cf-stat-val {
  font-weight: 800;
  font-size: 1.15rem;
}
.cf-stat-val.pos { color: var(--success); }
.cf-stat-val.neg { color: var(--danger); }
.cf-divider {
  margin: 0.7rem 0;
  border: none;
  border-top: 1px solid var(--border);
}
.cf-withdraw-label {
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 600;
}
.cf-withdraw-row {
  margin-top: 0.35rem;
}
.cf-ledger {
  margin-top: 0.4rem;
  font-size: 0.8rem;
}

/* ===== Accounts consolidation: hero + sections + accordion ===== */
.hero-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
}
.hero-net {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
}
.hero-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}
.hero-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.hero-stats strong { color: var(--text); font-weight: 700; }
.hero-entry {
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.hero-entry .row-flex { flex-wrap: wrap; }

.card-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.card-head h3, .card-head h4 { margin: 0; }
.sub-head {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.section-head {
  margin: 1.1rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--primary);
}
.section-head.collapsible {
  cursor: pointer;
  user-select: none;
  justify-content: space-between;
}
.section-head.collapsible .chev {
  transition: transform 0.2s ease;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.section-head.collapsible.collapsed .chev { transform: rotate(-90deg); }
.section-head.collapsible.collapsed + .section-body { display: none; }

.card { transition: box-shadow 0.2s ease; }
.card:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.08); }

body.dark-mode .hero-card {
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}

/* ============ Policy Configuration (premium, interactive) ============ */
.policy-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
.policy-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), #f0a06a);
}
.policy-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.policy-icon {
  width: 46px; height: 46px;
  flex-shrink: 0;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--primary-light), #fff);
  border: 1px solid var(--border);
}
.policy-title { font-size: 1.05rem; font-weight: 700; color: var(--text-light); margin: 0; }
.policy-sub { font-size: 0.78rem; color: var(--text-muted); margin: 0.1rem 0 0; }

.policy-section {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--border);
}
.policy-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0.8rem; }
.policy-section-label {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--primary);
  margin-bottom: 0.6rem;
}
.policy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.7rem;
}
.policy-field { position: relative; }
.policy-field input {
  width: 100%;
  padding: 1.05rem 3.2rem 0.4rem 0.9rem;
  border-radius: 0.9rem;
  border: 1.5px solid var(--border);
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  background: #fff;
  transition: var(--transition);
  text-align: left;
}
.policy-field label {
  position: absolute; left: 0.9rem; top: 0.8rem;
  font-size: 0.82rem; font-weight: 600; color: var(--text-muted);
  pointer-events: none; transition: all 0.15s ease;
}
.policy-field input:focus,
.policy-field input:not(:placeholder-shown) {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212,76,47,0.1);
}
.policy-field input:focus + label,
.policy-field input:not(:placeholder-shown) + label {
  top: 0.32rem; font-size: 0.6rem; color: var(--primary);
}
.policy-stepper {
  position: absolute; right: 0.45rem; top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 2px;
}
.policy-step-btn {
  width: 1.5rem; height: 1.2rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff; color: var(--primary);
  font-size: 0.75rem; font-weight: 800; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition);
  padding: 0;
}
.policy-step-btn:hover { background: var(--primary-light); }
.policy-step-btn:active { transform: scale(0.9); }

.policy-preview {
  margin-top: 1rem;
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.policy-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-size: 0.76rem; font-weight: 600;
  background: var(--primary-light); color: var(--primary-dark);
  border: 1px solid var(--border);
}
.policy-chip b { color: var(--text); }
.policy-actions {
  display: flex; gap: 0.6rem; margin-top: 1.1rem;
}
.policy-save { flex: 1; justify-content: center; font-size: 0.95rem; padding: 0.8rem; border-radius: 0.9rem; }
.policy-reset { font-size: 0.85rem; padding: 0.8rem 1rem; border-radius: 0.9rem; }


/* ===== Re-applied from later commits (employee pill restyle + return chip color) ===== */
.emp-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.emp-badges {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Compact colored pill replaces the old dot + uppercase label ΓÇö reads cleaner
   and matches the premium theme. */
.emp-status-pill {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 0.18rem 0.5rem;
  border-radius: 1rem;
  white-space: nowrap;
}
.emp-status-pill.active {
  background: #e6f7ee;
  color: #1a9c5b;
  border: 1px solid #b7e4c7;
}
.emp-status-pill.inactive {
  background: #fde8e8;
  color: #c0392b;
  border: 1px solid #f5c6c6;
}
.emp-status-pill.relieved {
  background: #fff3e0;
  color: #b45309;
  border: 1px solid #ffd8a8;
}

/* Archived employee metadata row (relief date, exit reason, advance due). */
.emp-archive-info {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}
.emp-archive-chips {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}
.emp-archive-chip {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.04);
  border-radius: 0.7rem;
  padding: 0.1rem 0.45rem;
}
.emp-archive-info .emp-action-btn {
  width: 26px;
  height: 26px;
  font-size: 0.82rem;
}

/* Staff Management Active / Archived toggle. */
.staff-filter-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}
.staff-filter-toggle {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 1rem;
  padding: 0.15rem;
  gap: 0.15rem;
}
.staff-filter-btn {
  border: none;
  background: transparent;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.28rem 0.8rem;
  border-radius: 1rem;
  cursor: pointer;
}
.staff-filter-btn.active {
  background: var(--primary, #1a9c5b);
  color: #fff;
}

.emp-actions {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
  opacity: 0.5;
  transition: var(--transition);
}

.emp-card:hover .emp-actions {
  opacity: 1;
}

.emp-action-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  transition: var(--transition);
}

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

.emp-action-btn.danger:hover {
  background: #fde8e8;
  color: var(--danger);
}

.emp-action-btn.warn:hover {
  background: #fff4e1;
  color: #e8590c;
}

.emp-action-btn.ok:hover {
  background: #e6f7ee;
  color: #1a9c5b;
}

.emp-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Employee inline edit form */
.emp-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.emp-edit-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.emp-edit-input {
  padding: 0.35rem 0.6rem !important;
  font-size: 0.82rem !important;
  border-radius: var(--radius-sm) !important;
}

.emp-edit-select {
  padding: 0.35rem 0.4rem !important;
  font-size: 0.78rem !important;
  border-radius: var(--radius-sm) !important;
}

.emp-edit-geo {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
}

.emp-edit-actions {
  display: flex;
  gap: 0.4rem;
}

/* ===== Mobile: stack the card into two comfortable tiers so nothing
   is squeezed. Top tier = avatar + name/role + status pill.
   Bottom tier = meta + action buttons, full-width, space-between. ===== */
@media (max-width: 560px) {
  .emp-card {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.45rem 0.75rem;
  }
  .emp-head {
    width: 100%;
    flex-wrap: wrap;
  }
  .emp-info {
    flex: 1;
    min-width: 0;
  }
  .emp-name {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .emp-badges {
    margin-left: auto;
  }
  .emp-actions {
    opacity: 1;
    width: 100%;
    justify-content: flex-end;
    gap: 0.4rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
  }
  .emp-action-btn {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }
}

body.dark-mode .emp-card {
  background: #16213e;
  border-color: #2a2a4a;
}
body.dark-mode .emp-status-pill.active {
  background: #14331f;
  color: #4ade80;
  border-color: #1f5132;
}
body.dark-mode .emp-status-pill.inactive {
}
body.dark-mode .emp-status-pill.relieved {
  background: #3a2a12;
  color: #fbbf24;
  border-color: #5c4416;
}
body.dark-mode .emp-archive-chip {
  background: rgba(255, 255, 255, 0.06);
  color: #9aa4bf;
}
body.dark-mode .staff-filter-toggle {
  background: rgba(255, 255, 255, 0.08);
}
body.dark-mode .staff-filter-btn.active {
  background: #1a9c5b;
  color: #fff;
}
.inv-chip-return {
  background: #fff3e0;
  color: #b45309;
  border-color: #ffd8a8;
}
body.dark-mode .inv-chip-return {
  background: #3a2a12;
  color: #fbbf24;
  border-color: #5c4416;
}

/* ============ Compliance Filter Bar ============ */
.compliance-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0;
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 10;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.compliance-search-bar {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 2rem;
  padding: 0.3rem 1rem;
  gap: 0.5rem;
  transition: var(--transition);
  flex: 1;
  min-width: 120px;
}
.compliance-search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212,76,47,0.1);
}
.compliance-search-icon {
  font-size: 0.9rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.compliance-search-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.85rem;
  color: var(--text);
  width: 100%;
  padding: 0.4rem 0;
}
.compliance-search-spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: compliance-spin 0.6s linear infinite;
}
@keyframes compliance-spin {
  to { transform: rotate(360deg); }
}

.compliance-pills {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
}

.compliance-pill {
  padding: 0.3rem 0.7rem;
  border-radius: 1.5rem;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  min-height: 32px;
}
.compliance-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.compliance-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.3rem;
  vertical-align: middle;
}
.count-badge {
  font-weight: 400;
  opacity: 0.8;
}

.compliance-section-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0.7rem 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.compliance-section-label .count {
  font-weight: 400;
  text-transform: none;
}

.compliance-activity-details {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--primary-light);
  margin-bottom: 1rem;
  overflow: hidden;
  margin-top: 0.5rem;
}
.compliance-activity-summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.compliance-activity-summary::-webkit-details-marker { display: none; }
.compliance-activity-summary::marker { display: none; content: ''; }
.compliance-activity-summary:hover {
  background: var(--primary-light);
}
.compliance-activity-arrow {
  transition: transform 0.2s;
  font-size: 0.7rem;
}
details[open] > .compliance-activity-summary .compliance-activity-arrow {
  transform: rotate(90deg);
}
#complianceHistoryTasks {
  padding: 0 1rem 0.6rem;
}

.compliance-load-more {
  display: block;
  width: 100%;
  padding: 0.6rem;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  transition: var(--transition);
  min-height: 40px;
}
.compliance-load-more:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.task-toggle-btn {
  font-size: 0.82rem;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
}

.compliance-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.6rem 0;
  text-align: center;
}

/* ============ Parcel Target Summary ============ */
.parcel-summary-bar {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  margin: 0.5rem 0 0.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.parcel-summary-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.parcel-summary-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}
.parcel-summary-total {
  font-size: 0.82rem;
  color: var(--text-light);
}
.parcel-summary-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
}
.parcel-clear-filters {
  font-size: 0.72rem;
  color: var(--danger);
  cursor: pointer;
  font-weight: 600;
  margin-left: auto;
  opacity: 0.75;
  transition: var(--transition);
  white-space: nowrap;
}
.parcel-clear-filters:hover {
  opacity: 1;
  text-decoration: underline;
}
.parcel-summary-bar.parcel-filter-active {
  border-color: #1971c2;
  box-shadow: 0 0 0 1px rgba(25, 113, 194, 0.15);
}
.parcel-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 1rem;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
}
.parcel-chip.item-chip {
  background: rgba(212, 76, 47, 0.12);
  color: var(--primary-dark);
  border: 1px solid rgba(212, 76, 47, 0.25);
}
.parcel-chip.item-chip.active {
  background: var(--primary-dark);
  color: #fff;
  border-color: var(--primary-dark);
}
.parcel-chip.staff-chip {
  background: rgba(25, 113, 194, 0.12);
  color: #1971c2;
  border: 1px solid rgba(25, 113, 194, 0.25);
}
.parcel-chip.staff-chip.active {
  background: #1971c2;
  color: #fff;
  border-color: #1971c2;
}

/* ============ Refill Card (Premium) ============ */
.refill-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid rgba(40, 167, 69, 0.15);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(40, 167, 69, 0.10);
  margin-bottom: 1rem;
  animation: fadeIn 0.25s ease;
}
.refill-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #28a745, #5cb85c);
}
.refill-header {
  padding: 0.65rem 1rem 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1a7a38;
}
.refill-body {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.45rem 1rem 0.7rem;
}
.refill-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: rgba(40, 167, 69, 0.07);
  color: #1a7a38;
  border: 1px solid rgba(40, 167, 69, 0.18);
  cursor: default;
  white-space: nowrap;
  transition: var(--transition);
}
.refill-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.15);
}
/* Gold / star badge for staff whose daily refills include extra (proactive) units
   beyond their mandatory parcel targets (over-target or after-deadline restocks). */
.refill-chip.refill-chip-bonus {
  background: linear-gradient(135deg, #fff7e0, #ffe9b3);
  color: #8a5b00;
  border-color: rgba(212, 175, 55, 0.55);
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.25), 0 2px 10px rgba(212, 175, 55, 0.35);
}
.refill-chip.refill-chip-bonus b {
  color: #b8860b;
  font-weight: 700;
}
.refill-chip.refill-chip-bonus:hover {
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.35), 0 4px 14px rgba(212, 175, 55, 0.45);
}

/* ============ Refill Matrix (admin interactive summary table) ============ */
.refill-matrix-wrap {
  overflow-x: auto;
  padding: 0.45rem 1rem 0.2rem;
}
.refill-matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.78rem;
  min-width: 420px;
}
.refill-matrix-th {
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  padding: 0.4rem 0.55rem;
  white-space: nowrap;
  border-bottom: 1px solid rgba(40, 167, 69, 0.18);
}
.refill-matrix-staff {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-card);
  text-align: left;
  color: var(--text);
  font-weight: 700;
}
.refill-matrix-th.active {
  color: #1a7a38;
  background: rgba(40, 167, 69, 0.10);
}
.refill-matrix-tr.active .refill-matrix-staff {
  color: #1971c2;
  background: rgba(25, 113, 194, 0.08);
}
.refill-matrix-cell {
  text-align: center;
  padding: 0.4rem 0.55rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
  white-space: nowrap;
}
.refill-matrix-cell:hover {
  background: rgba(40, 167, 69, 0.14);
  transform: translateY(-1px);
}
.refill-matrix-cell.active {
  background: var(--primary-dark);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.4);
}
.refill-matrix-cell.bonus {
  background: linear-gradient(135deg, #fff7e0, #ffe9b3);
  color: #8a5b00;
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.35);
}
.refill-matrix-cell.bonus:hover {
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.35), 0 2px 10px rgba(212, 175, 55, 0.4);
}
.refill-matrix-cell.bonus.active {
  background: #b8860b;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.5);
}
.refill-matrix-bonus {
  color: #b8860b;
  font-weight: 700;
}
.refill-matrix-zero {
  text-align: center;
  padding: 0.4rem 0.55rem;
  color: var(--text-muted);
  opacity: 0.45;
}
.refill-matrix-total {
  text-align: center;
  padding: 0.45rem 0.55rem;
  font-weight: 700;
  border-top: 1px solid rgba(40, 167, 69, 0.25);
  color: #1a7a38;
}
.refill-matrix-total.bonus {
  color: #b8860b;
}
.refill-matrix-total-row .refill-matrix-staff {
  color: #1a7a38;
}
.refill-matrix-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 1rem 0.7rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ============ Compliance Mobile ============ */
@media (max-width: 768px) {
  .compliance-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }
  .compliance-pills {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }
  .compliance-pill {
    width: auto;
    flex-shrink: 0;
    min-width: fit-content;
    min-height: 36px;
    font-size: 0.8rem;
  }
  .compliance-search-bar {
    width: 100%;
    min-width: 0;
  }
  .compliance-load-more {
    min-height: 44px;
    font-size: 0.85rem;
  }
  .task-toggle-btn {
    width: 100%;
    text-align: center;
  }
  .compliance-activity-summary {
    padding: 0.75rem 1rem;
  }
  .parcel-summary-bar {
    padding: 0.5rem 0.7rem;
  }
  .parcel-chip {
    font-size: 0.72rem;
    padding: 0.12rem 0.45rem;
  }
  .refill-body {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 2px;
  }
  .refill-chip {
    flex-shrink: 0;
    font-size: 0.72rem;
    padding: 0.18rem 0.5rem;
  }
  .refill-matrix-wrap {
    padding: 0.45rem 0.6rem 0.2rem;
  }
  .refill-matrix {
    min-width: 0;
    width: 100%;
    table-layout: auto;
    font-size: 0.74rem;
  }
  .refill-matrix-th {
    white-space: normal;
    line-height: 1.2;
    padding: 0.35rem 0.3rem;
  }
  .refill-matrix-staff {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  .refill-matrix-cell,
  .refill-matrix-zero,
  .refill-matrix-total {
    padding: 0.35rem 0.3rem;
    white-space: nowrap;
  }
}

/* ============ Compliance Dark Mode ============ */
body.dark-mode .compliance-filter-bar {
  background: #16213e;
  border-color: #2a2a4a;
}
body.dark-mode .compliance-search-bar {
  background: #1a1a2e;
  border-color: #2a2a4a;
}
body.dark-mode .compliance-search-input {
  color: #e0d6cc;
}
body.dark-mode .compliance-activity-details {
  background: #16213e;
  border-color: #2a2a4a;
}
body.dark-mode .compliance-activity-summary:hover {
  background: #2a2a4a;
}
body.dark-mode .compliance-pill {
  border-color: #2a2a4a;
  color: #b0a89e;
  background: transparent;
}
body.dark-mode .compliance-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
body.dark-mode .compliance-load-more {
  border-color: #2a2a4a;
  color: var(--primary);
}
body.dark-mode .compliance-load-more:hover {
  background: rgba(212, 76, 47, 0.1);
}
body.dark-mode .compliance-empty {
  color: #7a7068;
}
body.dark-mode .parcel-summary-bar {
  background: rgba(212, 76, 47, 0.08);
  border-color: rgba(212, 76, 47, 0.3);
}
body.dark-mode .parcel-chip.item-chip {
  background: rgba(212, 76, 47, 0.15);
  color: #ff8a65;
  border-color: rgba(212, 76, 47, 0.3);
}
body.dark-mode .parcel-chip.item-chip.active {
  background: #ff8a65;
  color: #1a1a2e;
  border-color: #ff8a65;
}
body.dark-mode .parcel-chip.staff-chip {
  background: rgba(25, 113, 194, 0.15);
  color: #64b5f6;
  border-color: rgba(25, 113, 194, 0.3);
}
body.dark-mode .parcel-chip.staff-chip.active {
  background: #64b5f6;
  color: #1a1a2e;
  border-color: #64b5f6;
}
body.dark-mode .parcel-summary-bar.parcel-filter-active {
  border-color: #64b5f6;
  box-shadow: 0 0 0 1px rgba(100, 181, 246, 0.2);
}
body.dark-mode .refill-card {
  background: #16213e;
  border-color: rgba(40, 167, 69, 0.2);
  box-shadow: 0 4px 16px rgba(40, 167, 69, 0.08);
}
body.dark-mode .refill-card::before {
  background: linear-gradient(90deg, #2e7d32, #43a047);
}
body.dark-mode .refill-header {
  color: #4ade80;
}
body.dark-mode .refill-chip {
  background: rgba(40, 167, 69, 0.12);
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.2);
}
body.dark-mode .refill-chip:hover {
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.12);
}
body.dark-mode .refill-chip.refill-chip-bonus {
  background: linear-gradient(135deg, #3a3208, #4a3d10);
  color: #ffd968;
  border-color: rgba(212, 175, 55, 0.45);
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.25), 0 2px 10px rgba(212, 175, 55, 0.25);
}
body.dark-mode .refill-chip.refill-chip-bonus b {
  color: #ffd968;
}
body.dark-mode .refill-chip.refill-chip-bonus:hover {
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.35), 0 4px 14px rgba(212, 175, 55, 0.35);
}
body.dark-mode .refill-matrix-th {
  background: #16213e;
  color: #8b9bb4;
  border-bottom-color: rgba(74, 222, 128, 0.2);
}
body.dark-mode .refill-matrix-staff {
  color: #e6edf7;
}
body.dark-mode .refill-matrix-th.active {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
}
body.dark-mode .refill-matrix-tr.active .refill-matrix-staff {
  color: #64b5f6;
  background: rgba(100, 181, 246, 0.12);
}
body.dark-mode .refill-matrix-cell:hover {
  background: rgba(74, 222, 128, 0.16);
}
body.dark-mode .refill-matrix-cell.active {
  background: #4ade80;
  color: #1a1a2e;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.4);
}
body.dark-mode .refill-matrix-cell.bonus {
  background: linear-gradient(135deg, #3a3208, #4a3d10);
  color: #ffd968;
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.4);
}
body.dark-mode .refill-matrix-cell.bonus:hover {
  box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.4), 0 2px 10px rgba(212, 175, 55, 0.3);
}
body.dark-mode .refill-matrix-cell.bonus.active {
  background: #ffd968;
  color: #1a1a2e;
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.5);
}
body.dark-mode .refill-matrix-bonus {
  color: #ffd968;
}
body.dark-mode .refill-matrix-total {
  color: #4ade80;
  border-top-color: rgba(74, 222, 128, 0.3);
}
body.dark-mode .refill-matrix-total.bonus {
  color: #ffd968;
}
body.dark-mode .refill-matrix-total-row .refill-matrix-staff {
  color: #4ade80;
}

