:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --border: #e2e8f0;
  --accent: #2440b6;
  --accent-soft: rgba(36, 64, 182, 0.08);
  --danger: #c62828;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.12);
  --radius-lg: 18px;
  --radius-md: 12px;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  scroll-behavior: smooth;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  padding: 24px clamp(16px, 4vw, 48px) 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  background: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}

.brand-title h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.2px;
}

.brand-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.app-nav {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.app-nav button {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--muted);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.app-nav button:hover {
  color: var(--text);
  border-color: rgba(36, 64, 182, 0.3);
}

.app-nav button.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(31, 58, 138, 0.2);
}

.undo-redo-controls {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.icon-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.app-main {
  padding: 24px clamp(16px, 4vw, 48px) 56px;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-header h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.control-field {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
}

.control-field.inline {
  flex-direction: row;
}

.control-field input,
.control-field select {
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.segmented button {
  border: none;
  padding: 6px 14px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.segmented button.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.tab-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.calendar-grid {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.calendar-row {
  display: grid;
  grid-template-columns: 120px repeat(var(--people-count, 3), minmax(120px, 1fr));
  border-bottom: 1px solid var(--border);
}

.calendar-row.header {
  background: var(--bg);
  font-weight: 600;
  color: #2f3a4a;
}

.calendar-cell {
  padding: 12px;
  border-right: 1px solid var(--border);
  min-height: 72px;
}

.calendar-cell:last-child {
  border-right: none;
}

.calendar-cell .date {
  font-weight: 600;
  margin-bottom: 6px;
  color: #2f3a4a;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.shift-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(31, 58, 138, 0.2);
}

.shift-pill.shift-day {
  background: rgba(245, 158, 11, 0.2);
  color: #b45309;
}

.shift-pill.shift-night {
  background: rgba(59, 130, 246, 0.2);
  color: #1d4ed8;
}

.shift-pill.shift-rest {
  background: rgba(16, 185, 129, 0.2);
  color: #047857;
}

.event-tags {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.overview-extras {
  margin-top: 16px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow-md);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.14);
}

.card h3 {
  margin: 0 0 8px;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
}

.progress {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.form-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow-md);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.form-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.14);
}

.form-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select {
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(36, 64, 182, 0.25);
  outline-offset: 2px;
}

input:focus,
select:focus {
  border-color: rgba(36, 64, 182, 0.45);
  box-shadow: 0 0 0 3px rgba(36, 64, 182, 0.12);
}

.form-actions {
  display: flex;
  gap: 12px;
}

button {
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 8px 16px rgba(31, 58, 138, 0.2);
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

button.danger {
  background: var(--danger);
  color: white;
}

button:hover {
  transform: translateY(-1px);
}

.form-hint {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 16px;
}

.list {
  display: grid;
  gap: 12px;
}

.list.compact {
  gap: 8px;
}

.list-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--surface);
  display: grid;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.list-item .item-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.list-item strong {
  color: var(--text);
}

.highlight {
  background: var(--accent-soft);
  border-color: rgba(31, 58, 138, 0.4);
}

.settings-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.file-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--muted);
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.app-footer {
  padding: 16px clamp(16px, 4vw, 48px);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  background: var(--surface);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.modal-backdrop.active {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 16px;
  width: min(560px, 100%);
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.calendar-cell.clickable {
  cursor: pointer;
  transition: background 0.15s ease;
}

.calendar-cell.clickable:hover {
  background: var(--accent-soft);
}

.calendar-cell.shift-day {
  background: rgba(245, 158, 11, 0.08);
}

.calendar-cell.shift-night {
  background: rgba(59, 130, 246, 0.08);
}

.calendar-cell.shift-rest {
  background: rgba(16, 185, 129, 0.08);
}

.calendar-cell.today {
  position: relative;
}

.calendar-cell.today::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  border-radius: var(--radius-md);
  pointer-events: none;
}

.today-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  margin-right: 6px;
}

.holiday-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.4;
  color: #b54708;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.holiday-badge.workday {
  color: #0f5a8a;
  background: rgba(14, 116, 144, 0.16);
  border-color: rgba(14, 116, 144, 0.35);
}

.holiday-cell {
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.2);
}

.workday-cell {
  box-shadow: inset 0 0 0 1px rgba(14, 116, 144, 0.2);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.3);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.toast-success {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.toast.toast-error {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}

.toast.toast-info {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
}

.loading-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state-desc {
  font-size: 14px;
}

.scroll-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.3);
  transition: all 0.3s ease;
  z-index: 999;
}

.scroll-to-top:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.4);
}

.scroll-to-top:active {
  transform: translateY(-2px);
}

/* 年视图样式 */
.calendar-grid.year-view {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  padding: 16px;
  overflow: visible;
}

.year-month {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.year-month-header {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--accent);
  text-align: center;
}

.mini-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.mini-day-header {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px 0;
  font-weight: 600;
}

.mini-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.mini-day:not(.empty):hover {
  background: var(--accent-soft);
  transform: scale(1.1);
}

.mini-day.empty {
  visibility: hidden;
}

.mini-day.today {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.mini-day.holiday {
  background: rgba(245, 158, 11, 0.12);
  color: #b54708;
  font-weight: 600;
}

.mini-day.workday {
  background: rgba(14, 116, 144, 0.12);
  color: #0f5a8a;
  font-weight: 600;
}

.mini-day.today.holiday {
  color: white;
}

.mini-day.today.workday {
  color: white;
}

.mini-day.has-events::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.mini-day.today.has-events::after {
  background: white;
}

@media (max-width: 768px) {
  .calendar-row {
    grid-template-columns: 92px repeat(var(--people-count, 3), minmax(90px, 1fr));
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-actions {
    flex-direction: column;
  }
  
  .toast {
    left: 16px;
    right: 16px;
    transform: translateX(0) translateY(100px);
  }
  
  .toast.show {
    transform: translateX(0) translateY(0);
  }
  
  .scroll-to-top {
    width: 40px;
    height: 40px;
    bottom: 16px;
    right: 16px;
    font-size: 18px;
  }
  
  .calendar-grid.year-view {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
  }
}
