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

:root {
  --bg-dark: #080d1a;
  --bg-panel: #111a2e;
  --bg-hover: #1c2a4a;
  --bg-input: #0c1224;
  --text-main: #f3f4f6;
  --text-muted: #8fa0c4;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: rgba(79, 70, 229, 0.15);
  --accent: #10b981;
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.1);
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);
  --info: #38bdf8;
  --info-light: rgba(56, 189, 248, 0.15);
  --border: #233356;
  --border-focus: #3b5284;
  --font-main: 'Inter', sans-serif;
  --font-display: 'Plus Jakarta Sans', sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.6);
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

/* Role Visibility System */
.manager-only {
  display: block;
}
body.role-va .manager-only {
  display: none !important;
}

.va-only {
  display: inline;
}
body.role-manager .va-only {
  display: none !important;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Offline & Banner alerts */
.offline-banner {
  background-color: #92400e;
  color: #fef3c7;
  text-align: center;
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  display: none;
  z-index: 1100;
}

.save-indicator {
  background-color: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.3s;
}
.save-indicator.show { opacity: 1; }

/* Header & Tabs */
.header {
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  z-index: 10;
  position: relative;
}
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2.5rem;
  border-bottom: 1px solid var(--border);
}
.logo-container h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.75px;
}

/* Role Selector Pill */
.role-selector {
  background: var(--bg-dark);
  padding: 3px;
  border-radius: 99px;
  display: flex;
  border: 1px solid var(--border);
  margin-right: 1.5rem;
}
.role-btn {
  background: none;
  border: none;
  padding: 6px 16px;
  border-radius: 99px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.role-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.tab-nav {
  display: flex;
  /* Wrap tabs onto a second row instead of clipping the rightmost ones
     (e.g. Reports) off-screen on narrower widths / higher browser zoom.
     row-gap keeps wrapped rows tight; column-gap preserves tab spacing. */
  flex-wrap: wrap;
  padding: 0 2rem;
  gap: 0.25rem 1.5rem;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 1rem 0.5rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.tab-btn:hover {
  color: var(--text-main);
}
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Main Content Area */
.main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}
.tab-pane {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.5rem 2.5rem;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}
.tab-pane.active {
  display: flex;
}

/* Controls Grid */
.grid-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-display);
}
.grid-controls h2 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.25px;
}

/* Interactive Dashboard & Calendar / Timeline Toggle */
.dashboard-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.view-toggle {
  display: flex;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.view-toggle-btn {
  background: none;
  border: none;
  padding: 6px 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 4px;
}
.view-toggle-btn.active {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* Chronological Timeline CSS */
.timeline-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.timeline-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  transition: var(--transition-fast);
}
.timeline-section:hover {
  border-color: var(--border-focus);
}
.timeline-header {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.timeline-header span.badge {
  background: var(--primary-light);
  color: var(--text-main);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
}
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Appointment List Item */
.appt-item-card {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 1.5rem;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}
.appt-item-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.appt-time-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  min-width: 90px;
}
.appt-time-box .time {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.9rem;
}
.appt-time-box .date {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.appt-lead-info {
  display: flex;
  flex-direction: column;
}
.appt-lead-info .lead-name {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--info);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 0.95rem;
}
.appt-lead-info .lead-name:hover {
  text-decoration: underline;
  color: var(--primary);
}
.appt-lead-info .lead-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 1rem;
  margin-top: 2px;
}
.appt-lead-info .lead-address {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.appt-status-ops {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.appt-item-notes {
  font-size: 0.78rem;
  color: var(--text-muted);
  border-left: 2px solid var(--border);
  padding-left: 0.75rem;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Open Tasks Checklist Section */
.daily-checklist-container {
  background: linear-gradient(135deg, var(--bg-panel) 0%, #15223c 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.daily-checklist-container::after {
  content: '✓';
  position: absolute;
  right: -20px;
  bottom: -40px;
  font-size: 10rem;
  color: rgba(16, 185, 129, 0.03);
  font-weight: bold;
  pointer-events: none;
}
.daily-checklist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.daily-checklist-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.daily-checklist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media(max-width: 768px) {
  .daily-checklist-grid { grid-template-columns: 1fr; }
}
.checklist-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.checklist-column-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.checklist-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}
.checklist-card:hover {
  border-color: var(--border-focus);
}
.checklist-card.checked {
  opacity: 0.55;
  border-color: var(--success);
}
.checklist-card.checked .lead-link {
  text-decoration: line-through;
}

/* HTML5 Calendar Grid View Styles */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  flex: 1;
}
.calendar-day-header {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 8px 0;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.calendar-cell {
  background: var(--bg-input);
  border: 1px solid var(--border);
  min-height: 100px;
  border-radius: var(--radius-sm);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: var(--transition-fast);
}
.calendar-cell:hover {
  border-color: var(--border-focus);
}
.calendar-cell.other-month {
  opacity: 0.3;
  background: transparent;
}
.calendar-cell.today {
  border: 2px solid var(--primary);
  box-shadow: 0 0 10px rgba(79, 70, 229, 0.2);
}
.calendar-cell .day-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-align: right;
}
.calendar-cell.today .day-number {
  color: var(--primary);
}
.calendar-appointments {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  max-height: 80px;
}
.calendar-appt-indicator {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: var(--transition-fast);
  color: white;
}
.calendar-appt-indicator:hover {
  transform: scale(1.02);
}

/* Standalone VA Booking Form CSS */
.booking-form-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  align-items: start;
}
@media(max-width: 992px) {
  .booking-form-container { grid-template-columns: 1fr; }
}
.form-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-main);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-grid-full {
  grid-column: span 2;
}
.form-card-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.form-card-field label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.form-field-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  transition: var(--transition-fast);
}
.form-field-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.dynamic-slots-deck {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 0.5rem;
}
.slot-deck-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  position: relative;
  transition: var(--transition-fast);
}
.slot-deck-card:hover {
  border-color: var(--border-focus);
}
.slot-deck-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
}
.slot-remove-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition-fast);
}
.slot-remove-btn:hover {
  opacity: 0.8;
}

/* Modern Right Side Drawer (Lead History Drawer) */
.lead-history-drawer {
  position: fixed;
  top: 0;
  right: -560px;
  width: 560px;
  height: 100%;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 1050;
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 1.5rem 1.75rem;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.lead-history-drawer.active {
  right: 0;
}
.drawer-close-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition-fast);
}
.drawer-close-btn:hover {
  color: var(--danger);
}
.drawer-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  margin-top: 0.5rem;
}
.drawer-header h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--info);
  margin-bottom: 4px;
}
.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.drawer-section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.drawer-history-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
}
.drawer-history-item {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  font-size: 0.84rem;
}
.drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Banned matrix columns styling overrides */
.lead-row td.manager-only {
  background-color: rgba(255, 255, 255, 0.01);
}

/* Modals */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(4, 6, 12, 0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 1200;
  opacity: 0; pointer-events: none; transition: opacity var(--transition-fast);
  backdrop-filter: blur(4px);
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-content {
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  width: 92%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition-fast);
}
.modal-overlay.active .modal-content { transform: translateY(0); }

.modal-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; margin-bottom: 1rem; color: var(--text-main); }
.modal-body { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.5rem; line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; }

/* Buttons & Pill UI */
.btn {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 0.65rem 1.35rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
}
.btn:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
}
.btn-secondary:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-focus);
}
.btn-danger {
  background-color: var(--danger);
  color: white;
}
.btn-danger:hover {
  background-color: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}
.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: inline-flex;
}
.btn-icon:hover {
  color: var(--danger);
  background-color: var(--danger-light);
}

.custom-checkbox {
  appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid var(--border);
  border-radius: 4px;
  background-color: var(--bg-input);
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
  flex-shrink: 0;
}
.custom-checkbox:checked {
  background-color: var(--accent);
  border-color: var(--accent);
}
.custom-checkbox:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 3.5px;
  height: 7.5px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.custom-checkbox:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* KPI Cards Layout */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}
.kpi-card {
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  box-shadow: var(--shadow-md);
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--primary);
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}
.kpi-card.kpi-success::before { background-color: var(--success); }
.kpi-card.kpi-warning::before { background-color: var(--warning); }
.kpi-card.kpi-info::before { background-color: var(--info); }
.kpi-title {
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}
.kpi-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.analytics-card {
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow: visible;
  box-shadow: var(--shadow-md);
  height: auto;
}
.analytics-header {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.data-table th {
  text-align: left;
  color: var(--text-muted);
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: none;
  font-family: var(--font-display);
  font-weight: 700;
}
.data-table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.data-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Auto Billing Ledger Style */
.billing-ledger-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
}
.billing-log-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background: var(--bg-input);
}
.billing-log-item {
  font-size: 0.78rem;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 4px;
  color: var(--text-muted);
}
.billing-log-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* Status Pill Stylings */
.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  display: inline-flex;
}

/* Status Select elements */
.editable-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.82rem;
  width: 100%;
  padding: 0.45rem;
  border-radius: 6px;
  outline: none;
  transition: var(--transition-fast);
}
.editable-input:focus {
  border-color: var(--primary);
}

/* ── Custom Datetime Picker ─────────────────────────────────────────── */
.datetime-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  gap: 4px;
}
.datetime-display {
  flex: 1;
  padding: 0.35rem 0.55rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-main);
  cursor: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
}
.datetime-display::placeholder { color: var(--text-muted); }
.datetime-display:focus {
  outline: none;
  border-color: var(--primary);
}
.datetime-cal-btn {
  flex-shrink: 0;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem 0.45rem;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s;
}
.datetime-cal-btn:hover {
  background: var(--border);
  border-color: var(--primary);
}

/* ── Calendar Popup ─────────────────────────────────────────────────── */
.cal-popup {
  position: fixed;
  z-index: 9999;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 16px;
  width: 290px;
  font-family: inherit;
  animation: calFadeIn 0.15s ease;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
@keyframes calFadeIn {
  from { opacity:0; transform: translateY(-6px) scale(0.97); }
  to   { opacity:1; transform: translateY(0)    scale(1);    }
}
@keyframes toast-in {
  from { opacity:0; transform: translateX(-50%) translateY(12px) scale(0.95); }
  to   { opacity:1; transform: translateX(-50%) translateY(0)    scale(1);    }
}
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-main);
  cursor: pointer;
  padding: 2px 8px;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.cal-nav-btn:hover { background: rgba(255,255,255,0.1); }
.cal-month-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
  font-family: var(--font-display);
}
.cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-dow {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 2px 0;
  text-transform: uppercase;
}
.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-day {
  text-align: center;
  padding: 6px 2px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--text-main);
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.cal-day:hover:not(.cal-day-disabled):not(.cal-day-empty) {
  background: rgba(99,102,241,0.35);
}
.cal-day-today {
  border: 1px solid var(--primary);
  font-weight: 700;
}
.cal-day-selected {
  background: var(--primary) !important;
  color: #fff !important;
  font-weight: 700;
}
.cal-day-disabled {
  color: rgba(255,255,255,0.2) !important;
  cursor: not-allowed !important;
  text-decoration: line-through;
}
.cal-day-empty { cursor: default; }

.cal-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.cal-time-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.cal-spin-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  padding: 1px 5px;
  transition: background 0.12s, color 0.12s;
}
.cal-spin-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-main); }
.cal-time-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  min-width: 30px;
  text-align: center;
}
.cal-time-sep { font-size: 1.1rem; font-weight: 700; color: var(--text-muted); }
.cal-ampm-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 8px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.cal-ampm-btn:hover, .cal-ampm-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.cal-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.cal-confirm-btn {
  flex: 1;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 0;
  transition: opacity 0.15s;
}
.cal-confirm-btn:hover { opacity: 0.85; }
.cal-cancel-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 6px 10px;
  transition: background 0.15s;
}
.cal-cancel-btn:hover { background: rgba(255,255,255,0.12); }

/* Tooltip container */
.tooltip-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.info-icon {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border: 1px solid var(--text-muted);
  border-radius: 50%;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}
.tooltip-container:hover .info-icon {
  opacity: 1;
  color: var(--primary);
  border-color: var(--primary);
}
.tooltip-text {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-main);
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: normal;
  line-height: 1.4;
  white-space: normal;
  z-index: 1000;
  width: 240px;
  box-shadow: var(--shadow-md);
  transition: opacity 0.2s ease;
  transition-delay: 150ms;
}
.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: var(--bg-panel) transparent transparent transparent;
}
.tooltip-container:hover .tooltip-text {
  opacity: 1;
}
.tooltip-bottom .tooltip-text::after {
  top: auto;
  bottom: 100%;
  border-color: transparent transparent var(--bg-panel) transparent;
}

/* ==========================================
   PHASE 2: AUTH, TIME CLOCK & UX ENHANCEMENTS
   ========================================== */

/* User Auth Overlay */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 9, 22, 0.95);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.login-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.login-card {
  background: linear-gradient(145deg, var(--bg-panel) 0%, rgba(17, 26, 46, 0.8) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 400px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}
.login-card:hover {
  border-color: var(--border-focus);
}

/* Time Clock Widget */
#time-clock-widget {
  background: var(--bg-dark);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: var(--transition-fast);
}
#time-clock-widget:hover {
  border-color: var(--border-focus);
}
.clock-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--danger);
  display: inline-block;
  box-shadow: 0 0 8px var(--danger);
  transition: var(--transition-fast);
}
.clock-status-dot.active {
  background-color: var(--accent) !important;
  box-shadow: 0 0 10px var(--accent) !important;
  animation: pulseGreen 1.5s infinite;
}

@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0px rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0px rgba(16, 185, 129, 0); }
}

/* Celebratory Victory Overlay */
.victory-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 16, 0.85);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.victory-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.victory-card {
  background: linear-gradient(145deg, var(--bg-panel) 0%, rgba(16, 185, 129, 0.02) 100%);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 3rem;
  width: 460px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.8), 0 0 25px rgba(16, 185, 129, 0.2);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(0.8);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  overflow: hidden;
}
.victory-overlay.active .victory-card {
  transform: scale(1);
}
.trophy-sparkle {
  font-size: 5rem;
  margin-bottom: 1.5rem;
  animation: trophyBounce 1.8s infinite ease-in-out;
  filter: drop-shadow(0 0 15px rgba(245, 158, 11, 0.3));
}

@keyframes trophyBounce {
  0%, 100% { transform: translateY(0) scale(1) rotate(0deg); }
  50% { transform: translateY(-15px) scale(1.08) rotate(5deg); filter: drop-shadow(0 0 25px rgba(245, 158, 11, 0.6)); }
}

/* Confetti particles */
.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  top: -15px;
  animation: confettiFall 3s linear infinite;
  z-index: 1;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* Financial Ledger override structures */
.financials-layout input[type="number"]::-webkit-inner-spin-button,
.financials-layout input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.financials-layout input[type="number"] {
  -moz-appearance: textfield;
}

/* Locked Paid items banner */
.locked-banner {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.locked-appt-card {
  border-color: var(--success) !important;
  background: linear-gradient(to right, var(--bg-panel) 90%, rgba(16, 185, 129, 0.05)) !important;
}

/* Dashboard panel height liberation */
#employee-management-panel,
#settings-panel,
#shift-audit-panel {
  overflow: visible !important;
  height: auto !important;
  min-height: unset !important;
}
#employee-mgmt-table,
#shift-audit-table,
#pending-registrations-list {
  overflow: visible !important;
  height: auto !important;
}

/* Validation animations */
@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25) !important;
  animation: shakeError 0.4s ease;
}

/* ── Master View Filter Pill Buttons ─────────────────────────────────────── */
.mv-filter-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.mv-filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}
.mv-filter-btn:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

/* ── Onboarding Continue Button — Premium Emerald ────────────────────────── */
.ob-continue-btn {
  background: #059669;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.7rem 2.5rem;
  border-radius: 10px;
  letter-spacing: 0.04em;
  border: none;
  cursor: pointer;
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
  box-shadow: 0 2px 12px rgba(5, 150, 105, 0.28);
}
.ob-continue-btn:hover {
  background: #047857;
  box-shadow: 0 4px 18px rgba(5, 150, 105, 0.38);
  transform: translateY(-1px);
}
.ob-continue-btn:active {
  background: #065f46;
  transform: translateY(0);
  box-shadow: 0 1px 6px rgba(5, 150, 105, 0.2);
}
.ob-continue-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ── Light Mode Theme ────────────────────────────────────────────────────── */
body.light-mode {
  --bg-dark: #f0f4f8;
  --bg-panel: #ffffff;
  --bg-hover: #e2e8f0;
  --bg-input: #f8fafc;
  --text-main: #0f172a;
  --text-muted: #475569;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: rgba(79, 70, 229, 0.12);
  --accent: #059669;
  --danger: #dc2626;
  --danger-light: rgba(220, 38, 38, 0.08);
  --warning: #d97706;
  --warning-light: rgba(217, 119, 6, 0.1);
  --success: #059669;
  --success-light: rgba(5, 150, 105, 0.12);
  --info: #0284c7;
  --info-light: rgba(2, 132, 199, 0.12);
  --border: #cbd5e1;
  --border-focus: #94a3b8;
}
body.light-mode .header { border-bottom-color: var(--border); background: var(--bg-panel); }
body.light-mode .lead-history-drawer { background: var(--bg-panel); border-left-color: var(--border); }
body.light-mode .cal-popup { background: var(--bg-panel); border-color: var(--border); }
body.light-mode .cal-day-disabled { color: var(--text-muted); }
body.light-mode .notif-dropdown,
body.light-mode #notif-dropdown { background: var(--bg-panel); }

/* Theme toggle button */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.2s ease;
  line-height: 1.2;
}
.theme-toggle-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--primary);
}

/* ── Dashboard performance charts ── */
#chart-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  display: none;
  background: var(--bg-panel);
  border: 1px solid var(--border-focus);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: var(--shadow-md);
  max-width: 280px;
}
#analytics-charts svg [data-tip] {
  cursor: pointer;
  transition: filter 0.15s ease;
}
#analytics-charts svg [data-tip]:hover {
  filter: brightness(1.45);
}
