:root {
  --primary-color: #07c160;
  --primary-hover: #06ad56;
  --primary-light: #e8f8f0;
  --bg-main: #f4f6f9;
  --bg-card: #ffffff;
  --text-main: #1f2d3d;
  --text-muted: #6b778c;
  --border-color: #e2e8f0;
  --border-dark: #cbd5e1;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);

  /* 岗位专用区分色 */
  --color-urgent: #ff9800;
  --color-urgent-bg: #fff7ed;
  --color-night: #e53935;
  --color-night-bg: #fef2f2;
  --color-postnight: #8b5cf6;
  --color-postnight-bg: #f5f3ff;
  --color-secondline: #3b82f6;
  --color-secondline-bg: #eff6ff;
  --color-thirdline: #06b6d4;
  --color-thirdline-bg: #ecfeff;
  --color-backup: #14b8a6;
  --color-backup-bg: #f0fdfa;
  --color-painless: #ec4899;
  --color-painless-bg: #fdf2f8;
  --color-vacation: #10b981;
  --color-vacation-bg: #ecfdf5;
  --color-festival: #6366f1;
  --color-festival-bg: #eef2ff;
  --color-remaining: #64748b;
  --color-remaining-bg: #f8fafc;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  overflow-x: hidden;
}

/* 顶部导航条 */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

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

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #07c160, #10b981);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.02em;
}

.brand-badge {
  font-size: 0.72rem;
  background: var(--primary-light);
  color: var(--primary-color);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

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

/* 主容器布局 */
.app-layout {
  display: flex;
  min-height: calc(100vh - 65px);
}

/* 侧边栏：人员管理与配置 */
.sidebar {
  width: 320px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex-shrink: 0;
}

.panel-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #334155;
}

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

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

.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: #fafbfc;
  color: var(--text-main);
  transition: all 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.15);
}

/* 按钮通用 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(7, 193, 96, 0.3);
}

.btn-outline {
  background: #ffffff;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

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

.btn-block {
  width: 100%;
}

/* 人员池胶囊列表 */
.pool-category {
  margin-bottom: 1rem;
}

.pool-header {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.staff-tag {
  background: #f1f5f9;
  color: #334155;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  cursor: grab;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  transition: all 0.15s ease;
}

.staff-tag:active {
  cursor: grabbing;
}

.staff-tag:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background-color: var(--primary-light);
}

.staff-tag.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  border: 1px dashed var(--primary-color);
}

.staff-tag.drag-over {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(7, 193, 96, 0.3);
  transform: translateY(-2px);
}

.staff-tag-del {
  font-size: 0.75rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 2px;
}

.staff-tag-del:hover {
  color: #ef4444 !important;
}

/* 主内容区域 */
.main-content {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
}

/* 工具条 */
.toolbar {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 1rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 20px;
}

.status-badge.dirty {
  background: #fef3c7;
  color: #b45309;
}

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

/* 周视图卡片与矩阵表格 */
.week-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
  overflow: hidden;
}

.week-card-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.week-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 矩阵大表 */
.matrix-wrapper {
  overflow-x: auto;
  width: 100%;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.84rem;
}

.matrix-table th,
.matrix-table td {
  border: 1px solid var(--border-color);
  text-align: center;
  padding: 8px 4px;
  min-width: 110px;
  position: relative;
  vertical-align: middle;
}

.matrix-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
}

.col-role-group {
  width: 50px;
  min-width: 50px;
  background: #f1f5f9;
  font-weight: 700;
  color: #334155;
  writing-mode: vertical-lr;
  letter-spacing: 2px;
  text-align: center;
  padding: 10px 0;
}

.col-subrole {
  width: 75px;
  min-width: 75px;
  background: #f8fafc;
  font-weight: 600;
  color: #64748b;
  padding: 6px 4px;
}

.col-role-single {
  width: 125px;
  min-width: 125px;
  background: #f8fafc;
  font-weight: 600;
  color: #334155;
  padding: 6px 8px;
  text-align: center;
}

/* 日期表头高亮 */
.th-date {
  padding: 8px 6px;
}

.th-date .weekday {
  font-size: 0.95rem;
  font-weight: 700;
  display: block;
}

.th-date .date-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.weekend-header {
  background: #fff5f5 !important;
  color: #dc2626 !important;
}

.holiday-tag {
  display: inline-block;
  background: #fee2e2;
  color: #ef4444;
  font-size: 0.7rem;
  padding: 1px 4px;
  border-radius: 3px;
  margin-top: 2px;
}

/* 单元格交互 */
.cell-interactive {
  cursor: pointer;
  transition: background-color 0.15s;
  user-select: none;
}

.cell-interactive:hover {
  background-color: #f0fdf4 !important;
  box-shadow: inset 0 0 0 1.5px var(--primary-color);
}

.cell-occupied {
  color: #0f172a;
  font-weight: 600;
}

/* 手动微调过的单元格高亮：柔和浅黄色底色 + 右上角红色小星号 */
.cell-modified {
  background-color: #fffbeb !important;
  color: #b45309 !important;
  font-weight: 700 !important;
  position: relative;
}

.cell-modified::after {
  content: '★';
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 0.62rem;
  color: #ef4444;
  line-height: 1;
  pointer-events: none;
}

/* 各班次专属配色微调 */
.urgent-accent {
  border-left: 3px solid var(--color-urgent);
}
.night-accent {
  border-left: 3px solid var(--color-night);
}
.postnight-accent {
  border-left: 3px solid var(--color-postnight);
}
.secondline-accent {
  border-left: 3px solid var(--color-secondline);
}
.thirdline-accent {
  border-left: 3px solid var(--color-thirdline);
}
.vacation-accent {
  border-left: 3px solid var(--color-vacation);
  background-color: var(--color-vacation-bg);
}
.painless-accent {
  border-left: 3px solid var(--color-painless);
}
.festival-accent {
  border-left: 3px solid var(--color-festival);
}

.remaining-cell {
  font-size: 0.75rem;
  color: #64748b;
  text-align: left !important;
  padding: 6px 8px !important;
  word-break: break-all;
  white-space: normal;
  max-width: 140px;
}

/* 换人弹窗 Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from {
    transform: scale(0.95) translateY(10px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.05rem;
  color: #1e293b;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 换人挑选器选项 */
.select-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 1rem 0 0.5rem 0;
}

.select-section-title:first-child {
  margin-top: 0;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
}

.candidate-btn {
  padding: 8px 4px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

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

.order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 6px;
}
.order-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.order-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  width: 22px;
}
.order-name {
  font-weight: 600;
  color: #1e293b;
  font-size: 0.92rem;
}
.order-actions {
  display: flex;
  gap: 4px;
}
.order-btn {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  cursor: pointer;
}
/* 全局优雅 Toast 提示 */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  background: #1e293b;
  color: #fff;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.success {
  background: #0f766e;
}

.toast.error {
  background: #be123c;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 打印与导出友好样式 */
@media print {
  .navbar,
  .sidebar,
  .toolbar,
  .modal-overlay {
    display: none !important;
  }

  body {
    background: #ffffff;
  }

  .app-layout {
    display: block;
  }

  .main-content {
    padding: 0;
    overflow: visible;
  }

  .week-card {
    box-shadow: none;
    border: 1px solid #000;
    page-break-after: always;
  }

  .matrix-table th,
  .matrix-table td {
    border: 1px solid #000 !important;
  }
}

/* 手机端与小屏幕自适应 (Responsive Design) */
@media (max-width: 768px) {
  .navbar {
    padding: 0.6rem 1rem;
    flex-wrap: wrap;
    gap: 8px;
  }

  .brand-title {
    font-size: 1.05rem;
  }

  .nav-actions {
    gap: 6px;
  }

  .nav-actions .btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.78rem;
  }

  /* 侧边栏转为顶部折叠/平铺 */
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    gap: 1rem;
  }

  .main-content {
    padding: 1rem 0.6rem;
    width: 100%;
  }

  .toolbar {
    padding: 0.6rem 0.8rem;
    margin-bottom: 1rem;
  }

  /* 表格左侧前两列固定 (Sticky Columns)，让手机横滑时第一列永远可见 */
  .col-role-group {
    position: sticky;
    left: 0;
    z-index: 10;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
  }

  .col-subrole {
    position: sticky;
    left: 40px;
    z-index: 9;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
  }

  .col-role-single {
    position: sticky;
    left: 0;
    z-index: 10;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
  }

  .matrix-table th:first-child {
    position: sticky;
    left: 0;
    z-index: 12;
    background: #f1f5f9;
  }

  .matrix-table th,
  .matrix-table td {
    min-width: 82px;
    padding: 6px 3px;
    font-size: 0.78rem;
  }

  .th-date .weekday {
    font-size: 0.85rem;
  }

  .th-date .date-sub {
    font-size: 0.72rem;
  }

  .modal-box {
    width: 95%;
  }
}
