/**
 * ShiftMate Main Stylesheet
 * 餐飲智慧排班平台
 * Depends on: design-tokens.css
 */

/* ============================================
   1. Base / Reset
   ============================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg-page);
  color: var(--color-text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--color-text-link);
  text-decoration: none;
}

a:hover {
  color: var(--color-text-link-hover);
}

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

/* ============================================
   2. Layout
   ============================================ */

.app-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 100vh;
}

#sidebar {
  width: 240px;
  background: var(--color-white);
  border-right: 1px solid var(--color-border-default);
  color: var(--color-text-primary);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  z-index: var(--z-sidebar);
  transition: width 0.2s ease;
  position: sticky;
  top: 0;
}

#sidebar.collapsed {
  width: 64px;
}

#sidebar.collapsed .sidebar-text {
  display: none;
}

#sidebar.collapsed .sidebar-brand-text {
  display: none;
}

.sidebar-brand {
  padding: 20px 16px;
  border-bottom: 1px solid var(--color-border-default);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  background: var(--color-primary-600);
  color: white;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.brand-subtitle {
  font-size: 11px;
  color: var(--color-text-tertiary);
  font-weight: 500;
}

.sidebar-nav {
  flex-grow: 1;
  padding: 12px 0;
}

.nav-item {
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-radius: var(--radius-md);
  margin: 2px 8px;
  transition: all 0.15s ease;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text-secondary);
  border: none;
  background: transparent;
  width: calc(100% - 16px);
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: var(--color-neutral-100);
  color: var(--color-text-primary);
}

.nav-item.active {
  background: var(--color-primary-50);
  color: var(--color-primary-700);
  font-weight: 600;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

#header {
  height: 64px;
  background: var(--color-bg-header);
  border-bottom: 1px solid var(--color-border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: var(--z-header);
}

#mainContent {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ============================================
   3. Conflict Banner (see section 18c)
   ============================================ */

/* ============================================
   4. Schedule Table
   ============================================ */

.schedule-page {
  width: 100%;
}

.schedule-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.schedule-actions,
.schedule-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-group {
  display: inline-flex;
  background: var(--color-neutral-100);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.tab-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--color-text-secondary);
  transition: all 0.15s ease;
  font-family: inherit;
}

.tab-btn.active {
  background: white;
  color: var(--color-primary-600);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

.period-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-arrow-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border-default);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.nav-arrow-btn:hover {
  background: var(--color-neutral-50);
}

.current-period {
  font-weight: 600;
  font-size: 14px;
  min-width: 180px;
  text-align: center;
}

.schedule-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.schedule-table th {
  background: var(--color-neutral-100);
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid var(--color-border-default);
}

.emp-header {
  min-width: 160px;
  text-align: left;
  padding-left: 14px;
}

.day-header {
  min-width: 120px;
}

.day-header.is-today {
  background: var(--color-primary-50);
  color: var(--color-primary-600);
}

.emp-cell {
  padding: 8px 14px;
  border-bottom: 1px solid var(--color-neutral-100);
  vertical-align: middle;
}

.emp-row-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.emp-av-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.emp-row-name {
  font-size: 13px;
  font-weight: 600;
}

.emp-row-meta {
  font-size: 11px;
  color: var(--color-text-tertiary);
}

.shift-cell {
  padding: 4px;
  border-bottom: 1px solid var(--color-neutral-100);
  vertical-align: top;
  min-height: 60px;
  position: relative;
}

.shift-cell.has-conflict {
  background: var(--color-error-50);
}

.shift-cell.is-today-col {
  background: var(--color-primary-50);
}

.shift-cell.drop-target {
  background: var(--color-primary-50);
  transition: background 0.15s;
}

.shift-cell.drag-over {
  background: var(--color-primary-100) !important;
  outline: 2px dashed var(--color-primary-400);
  outline-offset: -2px;
}

.add-shift-btn {
  width: 100%;
  padding: 4px;
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  font-size: 11px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.15s ease;
  font-family: inherit;
}

.shift-cell:hover .add-shift-btn {
  opacity: 1;
}

.add-shift-btn:hover {
  background: var(--color-neutral-100);
  color: var(--color-primary-600);
}

/* ============================================
   5. Shift Block
   ============================================ */

.shift-block {
  padding: 6px 8px;
  border-radius: var(--radius-md);
  color: white;
  font-size: 11.5px;
  cursor: pointer;
  margin-bottom: 3px;
  position: relative;
  transition: all 0.15s ease;
  user-select: none;
}

.shift-block:hover {
  filter: brightness(1.1);
  box-shadow: var(--shadow-md);
}

.shift-block.is-conflict {
  outline: 2px solid var(--color-error-500);
  animation: conflict-flash 1s ease-in-out infinite;
}

.shift-block.is-draft {
  opacity: 0.8;
}

.shift-type-label {
  font-weight: 600;
  font-size: 11px;
}

.shift-time-label {
  font-size: 10.5px;
  opacity: 0.9;
}

.shift-store-badge {
  font-size: 9px;
  background: rgba(0, 0, 0, 0.2);
  padding: 0 4px;
  border-radius: 3px;
  display: inline-block;
  margin-top: 2px;
}

.shift-cost-label {
  font-size: 9.5px;
  opacity: 0.85;
  font-weight: 600;
  margin-top: 1px;
}

.draft-indicator {
  font-size: 9px;
  background: rgba(0, 0, 0, 0.3);
  padding: 0 4px;
  border-radius: 3px;
}

/* Drag feedback */
.shift-block[draggable="true"]:active {
  opacity: 0.6;
  transform: scale(0.95);
  box-shadow: var(--shadow-drag);
}

.shift-cell.drag-over {
  background: var(--color-primary-100) !important;
  outline: 2px dashed var(--color-primary-400);
  outline-offset: -2px;
}

/* Empty week guidance */
.empty-week-guide {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-tertiary);
}
.empty-week-guide .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.empty-week-guide .empty-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text-secondary);
}
.empty-week-guide .empty-desc {
  font-size: 13px;
  margin-bottom: 20px;
}
.empty-week-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ============================================
   6. Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
  border-radius: var(--radius-md);
  font-size: 13px;
  padding: 8px 16px;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary-600);
  color: white;
}

.btn-primary:hover {
  background: var(--color-primary-700);
}

.btn-secondary {
  background: var(--color-neutral-100);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-default);
}

.btn-secondary:hover {
  background: var(--color-neutral-200);
}

.btn-danger {
  background: var(--color-error-600);
  color: white;
}

.btn-danger:hover {
  background: var(--color-error-700);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn-ghost:hover {
  background: var(--color-neutral-100);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

/* ============================================
   7. Badges & Tags
   ============================================ */

.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.badge-blue {
  background: var(--color-primary-50);
  color: var(--color-primary-700);
}

.badge-green {
  background: var(--color-success-50);
  color: var(--color-success-700);
}

.badge-yellow {
  background: var(--color-accent-50);
  color: var(--color-accent-700);
}

.badge-red {
  background: var(--color-error-50);
  color: var(--color-error-700);
}

.badge-gray {
  background: var(--color-neutral-100);
  color: var(--color-neutral-600);
}

.tag {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
}

.tag-filled {
  color: white;
}

.tag-cashier {
  background: #3B82F6;
}

.tag-kitchen {
  background: #EF4444;
}

.tag-floor {
  background: #10B981;
}

.tag-delivery {
  background: #F59E0B;
}

.tag-training {
  background: #8B5CF6;
}

/* ============================================
   8. Cards
   ============================================ */

.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-default);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-neutral-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
}

/* ============================================
   9. Employee Cards
   ============================================ */

.emp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.emp-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-default);
  padding: 16px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-xs);
}

.emp-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.emp-card.conflict-card {
  border-color: var(--color-error-500);
}

.emp-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.emp-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: white;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.emp-card-name {
  font-size: 15px;
  font-weight: 700;
}

.emp-card-sub {
  font-size: 12px;
  color: var(--color-text-tertiary);
}

.emp-level-stars {
  font-size: 12px;
}

.emp-skills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.emp-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.emp-stat-val {
  font-size: 14px;
  font-weight: 700;
}

.emp-stat-lbl {
  font-size: 10.5px;
  color: var(--color-text-tertiary);
}

.emp-card-actions {
  display: flex;
  gap: 6px;
}

.employees-page {
  padding: 0;
}

.employees-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ============================================
   10. Cost Dashboard
   ============================================ */

.cost-page {
  padding: 0;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-default);
  padding: 16px 20px;
  box-shadow: var(--shadow-xs);
}

.kpi-label {
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-text-primary);
}

.kpi-trend {
  font-size: 12px;
  margin-top: 4px;
}

.kpi-trend.up {
  color: var(--color-error-600);
}

.kpi-trend.down {
  color: var(--color-success-600);
}

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.chart-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-default);
  padding: 16px 20px;
  box-shadow: var(--shadow-xs);
}

.chart-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

.chart-canvas-wrap {
  height: 200px;
}

.budget-section {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-default);
  padding: 16px 20px;
  margin-bottom: 20px;
}

.budget-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.budget-label {
  min-width: 100px;
  font-size: 13px;
  font-weight: 600;
}

.budget-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--color-neutral-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.budget-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.budget-pct {
  min-width: 40px;
  text-align: right;
  font-size: 12.5px;
  font-weight: 700;
}

.emp-cost-table {
  width: 100%;
  border-collapse: collapse;
}

.emp-cost-table th {
  background: var(--color-neutral-100);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}

.emp-cost-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-neutral-100);
  font-size: 13px;
}

/* ============================================
   11. Multi-store View
   ============================================ */

.multistore-page {
  padding: 0;
}

.store-section {
  margin-bottom: 24px;
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.store-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 3px solid;
  background: var(--color-neutral-50);
}

.store-section-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.store-section-name {
  font-weight: 700;
  font-size: 15px;
}

.store-section-meta {
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-left: auto;
}

.multistore-table {
  width: 100%;
  border-collapse: collapse;
}

.multistore-table th {
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
  background: var(--color-neutral-50);
  border-bottom: 1px solid var(--color-border-default);
}

.multistore-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-neutral-100);
  font-size: 12px;
  vertical-align: top;
}

/* ============================================
   12. Leave Manager
   ============================================ */

.leave-page {
  padding: 0;
}

.leave-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.leave-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leave-card {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-default);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.15s ease;
}

.leave-card:hover {
  box-shadow: var(--shadow-sm);
}

.leave-status {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
}

.leave-status.pending {
  background: var(--color-accent-100);
  color: var(--color-accent-700);
}

.leave-status.approved {
  background: var(--color-success-100);
  color: var(--color-success-700);
}

.leave-status.rejected {
  background: var(--color-error-100);
  color: var(--color-error-700);
}

/* ============================================
   13. Modal System
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background: var(--color-bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: all 0.25s ease;
  opacity: 0;
}

.modal-overlay.active .modal-container {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--color-text-secondary);
  transition: background 0.15s ease;
}

.modal-close:hover {
  background: var(--color-neutral-100);
}

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border-default);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================
   14. Forms
   ============================================ */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--color-border-default);
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-family: inherit;
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  transition: border-color 0.15s ease;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary-500);
  box-shadow: var(--shadow-focus-primary);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border-default);
  font-size: 12.5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.form-checkbox-label:has(:checked) {
  background: var(--color-primary-50);
  border-color: var(--color-primary-500);
  color: var(--color-primary-700);
  font-weight: 600;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  font-size: 14px;
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.search-input {
  padding-left: 36px;
}

/* ============================================
   15. Toast Notifications
   ============================================ */

.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  background: var(--color-bg-card);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid;
  font-size: 13px;
  min-width: 280px;
  max-width: 400px;
  animation: toast-in 0.3s ease;
}

.toast.success {
  border-color: var(--color-success-500);
}

.toast.error {
  border-color: var(--color-error-500);
}

.toast.warning {
  border-color: var(--color-warning-500);
}

.toast.removing {
  animation: toast-out 0.3s ease forwards;
}

/* ============================================
   16. Day View Specific
   ============================================ */

.day-view {
  padding: 0;
}

.day-emp-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-neutral-100);
}

.day-emp-info {
  min-width: 160px;
}

.day-timeline {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.day-shift-block {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  color: white;
  font-size: 12px;
  font-weight: 500;
}

/* ============================================
   17. Month View Specific
   ============================================ */

.month-grid {
  padding: 0;
}

.month-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  margin-bottom: 8px;
}

.month-weeks {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.month-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.month-day {
  min-height: 80px;
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid var(--color-neutral-100);
}

.month-day:hover {
  background: var(--color-neutral-50);
  box-shadow: var(--shadow-xs);
}

.month-day.other-month {
  opacity: 0.4;
}

.month-day.is-today {
  border-color: var(--color-primary-500);
  background: var(--color-primary-50);
}

.month-day-num {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.month-shift-dots {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.month-shift-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.month-more {
  font-size: 10px;
  color: var(--color-text-tertiary);
}

/* ============================================
   18. Store Filter (Sidebar)
   ============================================ */

.sidebar-store-filter {
  padding: 16px;
  border-top: 1px solid var(--color-border-default);
  margin-top: auto;
}

.store-filter-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-tertiary);
  margin-bottom: 10px;
}

.store-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.store-filter-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================
   18b. Sidebar Bottom
   ============================================ */

.sidebar-bottom {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border-default);
}

.dark-mode-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s;
}

.dark-mode-toggle:hover {
  background: var(--color-neutral-100);
}

.toggle-icon {
  display: flex;
  align-items: center;
}

/* ============================================
   18c. Header Enhancements
   ============================================ */

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.hamburger-btn {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.hamburger-line {
  width: 18px;
  height: 2px;
  background: var(--color-text-secondary);
  border-radius: 1px;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-success-600);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--color-success-50);
}

.sync-icon {
  display: flex;
  align-items: center;
}

.notification-bell {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: background 0.15s;
  position: relative;
}

.notification-bell:hover {
  background: var(--color-neutral-100);
}

.bell-icon {
  display: flex;
  align-items: center;
}

.notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-error-500);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-border-default);
  background: var(--color-neutral-100);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: all 0.15s;
}

.avatar-btn:hover {
  background: var(--color-neutral-200);
}

.avatar-placeholder {
  display: flex;
  align-items: center;
}

.user-avatar-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border-default);
  min-width: 160px;
  z-index: var(--z-dropdown);
  overflow: hidden;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text-primary);
  cursor: pointer;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--color-neutral-50);
}

.dropdown-divider {
  border: none;
  border-top: 1px solid var(--color-border-default);
  margin: 4px 0;
}

.conflict-banner {
  background: var(--color-error-50);
  border-bottom: 2px solid var(--color-error-500);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-error-700);
}

.conflict-icon {
  display: flex;
  align-items: center;
  color: var(--color-error-500);
}

.conflict-dismiss {
  margin-left: auto;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--color-error-500);
  font-size: 16px;
  padding: 4px;
}

/* ============================================
   19. Dark Mode
   ============================================ */

body.dark {
  --color-bg-page: #0F172A;
  --color-bg-card: #1E293B;
  --color-bg-header: #1E293B;
  --color-text-primary: #F1F5F9;
  --color-text-secondary: #94A3B8;
  --color-text-tertiary: #64748B;
  --color-border-default: #334155;
  --color-neutral-100: #334155;
  --color-neutral-50: #1E293B;
}

body.dark #sidebar {
  background: #1E293B;
  border-right-color: #334155;
}

body.dark .sidebar-brand {
  border-bottom-color: #334155;
}

body.dark .brand-logo {
  color: #F1F5F9;
}

body.dark .nav-item {
  color: #94A3B8;
}

body.dark .nav-item:hover {
  background: #334155;
  color: #F1F5F9;
}

body.dark .nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
}

body.dark .sidebar-store-filter {
  border-top-color: #334155;
}

body.dark .sidebar-bottom {
  border-top-color: #334155;
}

body.dark .dark-mode-toggle {
  color: #94A3B8;
}

body.dark .dark-mode-toggle:hover {
  background: #334155;
}

body.dark .sync-status {
  background: rgba(16, 185, 129, 0.1);
}

body.dark .avatar-btn {
  background: #334155;
  border-color: #475569;
  color: #F1F5F9;
}

body.dark .schedule-table,
body.dark .card,
body.dark .emp-card,
body.dark .kpi-card,
body.dark .chart-card,
body.dark .budget-section,
body.dark .leave-card,
body.dark .store-section,
body.dark .modal-container,
body.dark .toast {
  background: var(--color-bg-card);
}

body.dark .tab-btn.active {
  background: #334155;
  color: var(--color-primary-400);
}

body.dark .nav-arrow-btn {
  background: #334155;
  border-color: #475569;
  color: #F1F5F9;
}

body.dark .btn-secondary {
  background: #334155;
  color: #F1F5F9;
  border-color: #475569;
}

body.dark .form-input,
body.dark .form-select,
body.dark .form-textarea {
  background: #0F172A;
  border-color: #475569;
  color: #F1F5F9;
}

/* ============================================
   20. Responsive
   ============================================ */

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    left: -240px;
    transition: left 0.3s ease;
    height: 100vh;
    border-right: none;
    box-shadow: var(--shadow-xl);
  }

  #sidebar.open {
    left: 0;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .hamburger-btn {
    display: flex;
  }

  #mainContent {
    padding: 16px;
  }

  .schedule-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .charts-row {
    grid-template-columns: 1fr;
  }

  .emp-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-container {
    max-width: 95%;
    max-height: 90vh;
  }
}

/* ============================================
   21. Utility Classes
   ============================================ */

.text-danger {
  color: var(--color-error-600);
}

.text-success {
  color: var(--color-success-600);
}

.text-warning {
  color: var(--color-warning-600);
}

.text-muted {
  color: var(--color-text-tertiary);
}

.fw-bold {
  font-weight: 700;
}

.d-flex {
  display: flex;
}

.gap-2 {
  gap: 8px;
}

.hidden {
  display: none;
}

/* ============================================
   22. Scrollbar Styling
   ============================================ */

#mainContent::-webkit-scrollbar {
  width: 6px;
}

#mainContent::-webkit-scrollbar-track {
  background: transparent;
}

#mainContent::-webkit-scrollbar-thumb {
  background: var(--color-neutral-300);
  border-radius: var(--radius-full);
}

#mainContent::-webkit-scrollbar-thumb:hover {
  background: var(--color-neutral-400);
}

#sidebar::-webkit-scrollbar {
  width: 4px;
}

#sidebar::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
  background: var(--color-neutral-300);
  border-radius: var(--radius-full);
}

/* ============================================
   23. Page Toolbar (reusable)
   ============================================ */

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.page-toolbar-title {
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.page-toolbar-meta {
  font-size: var(--font-size-body-sm);
  color: var(--color-text-tertiary);
}

.page-toolbar-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-left: auto;
}

/* ============================================
   24. Empty State (reusable)
   ============================================ */

.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-5);
  color: var(--color-text-tertiary);
}

.empty-state-icon {
  margin-bottom: var(--space-4);
  color: var(--color-neutral-300);
}

.empty-state-icon svg {
  width: 48px;
  height: 48px;
}

.empty-state-title {
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: var(--font-size-body);
  margin-bottom: var(--space-5);
}

.empty-state-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

/* ============================================
   25. Store Group Header (reusable)
   ============================================ */

.store-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.store-group-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.store-group-name {
  font-size: 15px;
  font-weight: var(--font-weight-bold);
}

/* ============================================
   26. Conflict Alert Badge (reusable)
   ============================================ */

.conflict-alert-badge {
  background: var(--color-error-50);
  color: var(--color-error-700);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-body-sm);
  font-weight: var(--font-weight-semibold);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

/* ============================================
   27. Table Scroll Wrapper
   ============================================ */

.table-scroll-wrap {
  overflow-x: auto;
}

/* ============================================
   28. Conflict Summary
   ============================================ */

.conflict-summary {
  background: var(--color-error-50);
  border: 1.5px solid var(--color-error-300);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.conflict-summary-title {
  font-weight: 700;
  color: var(--color-error-700);
  margin-bottom: 8px;
  font-size: 13px;
}

.conflict-summary-item {
  font-size: 12.5px;
  color: var(--color-text-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.conflict-summary-meta {
  color: var(--color-text-tertiary);
  font-size: 12px;
}

/* ============================================
   29. Leave Page Specific
   ============================================ */

.leave-kpi-icon {
  font-size: 20px;
}

.leave-card-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.leave-card-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 130px;
}

.leave-card-name {
  font-weight: 700;
  font-size: 14px;
}

.leave-card-store {
  font-size: 12px;
  color: var(--color-text-tertiary);
}

.leave-card-center {
  flex: 1;
  min-width: 200px;
}

.leave-card-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.leave-type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.leave-card-dates {
  font-size: 13px;
  color: var(--color-text-secondary);
}

.leave-card-days {
  color: var(--color-text-tertiary);
  font-size: 12px;
}

.leave-card-reason {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.leave-card-right {
  text-align: right;
  min-width: 90px;
}

.leave-status-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.leave-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.leave-review-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-tertiary);
  font-style: italic;
}

.leave-conflict-warn {
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-error-600);
  font-weight: 600;
}

/* Leave calendar */
.leave-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.leave-calendar-day {
  text-align: center;
  padding: 3px 2px;
  border-radius: 6px;
  min-height: 42px;
}

.leave-calendar-day.is-today {
  background: var(--color-primary-600);
  color: white;
}

.leave-calendar-day-num {
  font-size: 12px;
  font-weight: 500;
}

.leave-calendar-day.is-today .leave-calendar-day-num {
  font-weight: 700;
}

.leave-calendar-dots {
  display: flex;
  gap: 2px;
  justify-content: center;
  margin-top: 2px;
}

.leave-calendar-initials {
  font-size: 9px;
  color: var(--color-text-tertiary);
  line-height: 1;
  margin-top: 1px;
}

.leave-calendar-legend {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--color-text-tertiary);
}

.leave-calendar-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 3px;
}

/* ============================================
   30. Login Screen
   ============================================ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #EFF6FF 0%, #F8FAFC 50%, #EDE9FE 100%);
  z-index: 9999;
}

.login-card {
  background: #fff;
  border-radius: var(--radius-xl, 16px);
  box-shadow: 0 20px 60px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.04);
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 380px;
  margin: 16px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-text-primary);
  margin: 0;
}

.login-subtitle {
  font-size: 13px;
  color: var(--color-text-tertiary);
  margin: 4px 0 0;
}

.login-form .form-group {
  margin-bottom: 16px;
}

.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.login-form .form-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  background: var(--color-bg-card, #fff);
  transition: border-color .15s, box-shadow .15s;
}

.login-form .form-input:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.login-error {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--color-error-50, #FEF2F2);
  color: var(--color-error-600);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
}

.login-btn {
  width: 100%;
  padding: 11px;
  font-size: 15px;
  font-weight: 700;
  margin-top: 4px;
}

/* ============================================
   31. No Permission State
   ============================================ */
.no-permission {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--color-text-tertiary);
  text-align: center;
}

.no-permission-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: .4;
}

.no-permission-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.no-permission-desc {
  font-size: 13px;
}
