:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #e2e8f0;
  --line-soft: #eef2f6;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;
  --accent: #0f766e;
  --accent-bg: #f0fdfa;
  --accent-ring: #99f6e4;
  --today-bg: #ecfdf5;
  --morning-bg: #fffbeb;
  --morning-text: #b45309;
  --afternoon-bg: #ecfdf5;
  --afternoon-text: #047857;
  --evening-bg: #eef2ff;
  --evening-text: #4338ca;
  --holiday-text: #e11d48;
  --holiday-bg: #fff1f2;
  --workday-text: #b45309;
  --workday-bg: #fffbeb;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button, input {
  font: inherit;
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 14px 36px;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

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

.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: #0f172a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16);
}

.brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover {
  background: var(--surface-soft);
  border-color: #cbd5e1;
}

.btn:active {
  transform: scale(0.98);
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-today {
  color: var(--accent);
  border-color: var(--accent-ring);
  background: var(--accent-bg);
}

.btn-today:hover {
  background: #ccfbf1;
  border-color: #5eead4;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  background: var(--surface-soft);
  border-color: #cbd5e1;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* Rule panel */
.rule-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.rule-text {
  margin: 0;
}

.rule-meta {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-light);
}

/* Person filter bar */
.person-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

.person-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.person-bar-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.person-bar-hint {
  font-size: 12px;
  color: var(--text-light);
}

.person-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.person-pill {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text-muted);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.person-pill:hover {
  border-color: #94a3b8;
  color: var(--text);
}

.person-pill.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.18);
}

/* Personal next-duty banner */
.my-duty-banner {
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

.my-duty-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.my-duty-title {
  font-size: 16px;
  font-weight: 700;
}

.my-duty-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 600;
}

.my-duty-badge.urgent {
  background: #10b981;
  color: #022c22;
}

.my-duty-upcoming {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.upcoming-chip {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  color: #f1f5f9;
  cursor: pointer;
  transition: background 0.15s;
}

.upcoming-chip:hover {
  background: rgba(255, 255, 255, 0.2);
}

.upcoming-chip strong {
  color: #5eead4;
  margin-left: 4px;
}

/* Today & Tomorrow hero cards */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.hero-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}

.hero-card.is-today {
  border-color: #99f6e4;
  background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 42%);
}

.hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
}

.hero-tag-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
}

.hero-card:not(.is-today) .hero-tag-pill {
  background: #e2e8f0;
  color: #334155;
}

.hero-date {
  font-size: 12px;
  color: var(--text-muted);
}

.shift-rows {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.shift-box {
  border-radius: var(--radius-md);
  padding: 10px 8px;
  border: 1px solid var(--line-soft);
  background: var(--surface-soft);
  text-align: center;
  position: relative;
  transition: transform 0.15s, border-color 0.15s;
}

.shift-box.morning {
  background: var(--morning-bg);
  border-color: #fde68a;
}

.shift-box.afternoon {
  background: var(--afternoon-bg);
  border-color: #a7f3d0;
}

.shift-box.evening {
  background: var(--evening-bg);
  border-color: #c7d2fe;
}

.shift-box.mine {
  outline: 2px solid #0f172a;
  outline-offset: -1px;
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
}

.shift-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}

.shift-box.morning .shift-label { color: var(--morning-text); }
.shift-box.afternoon .shift-label { color: var(--afternoon-text); }
.shift-box.evening .shift-label { color: var(--evening-text); }

.now-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

.shift-person {
  margin-top: 5px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.shift-now-tag {
  margin-top: 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
}

.holiday-banner {
  padding: 14px 12px;
  border-radius: var(--radius-md);
  background: var(--holiday-bg);
  color: var(--holiday-text);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

/* Main schedule card */
.schedule-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.schedule-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.month-input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.only-mine-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.view-switch {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: #e2e8f0;
}

.view-btn {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.view-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

/* Calendar grid */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.cal-weekday {
  text-align: center;
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.cal-weekday.weekend {
  color: #64748b;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-cell {
  min-height: 124px;
  padding: 8px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: background 0.12s;
  min-width: 0;
}

.cal-cell:nth-child(7n) {
  border-right: 0;
}

.cal-cell:hover {
  background: #f8fafc;
}

.cal-cell.other-month {
  background: #fafbfc;
  opacity: 0.45;
}

.cal-cell.is-today {
  background: var(--today-bg);
}

.cal-cell.has-mine {
  background: #f0fdfa;
}

.cal-cell-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
}

.cal-day-wrap {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}

.cal-day-num {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.cal-cell.is-today .cal-day-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
}

.cal-lunar {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-lunar.holiday {
  color: var(--holiday-text);
  font-weight: 600;
}

.cal-lunar.workday {
  color: var(--workday-text);
  font-weight: 600;
}

.cal-badges {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.mini-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 5px;
  line-height: 1.4;
}

.mini-badge.holiday {
  background: var(--holiday-bg);
  color: var(--holiday-text);
}

.mini-badge.workday {
  background: var(--workday-bg);
  color: var(--workday-text);
}

.mini-badge.override {
  background: #fef3c7;
  color: #92400e;
}

.cal-shifts {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cal-shift-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--surface-soft);
}

.cal-shift-row .p-tag {
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.cal-shift-row.morning .p-tag { color: var(--morning-text); }
.cal-shift-row.afternoon .p-tag { color: var(--afternoon-text); }
.cal-shift-row.evening .p-tag { color: var(--evening-text); }

.cal-shift-row .p-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-shift-row.mine {
  background: #0f172a;
  color: #fff;
}

.cal-shift-row.mine .p-tag {
  color: #5eead4;
}

.cal-shift-row.dim {
  opacity: 0.35;
}

.cal-rest-note {
  margin-top: auto;
  padding: 6px;
  border-radius: 8px;
  background: var(--holiday-bg);
  color: var(--holiday-text);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

/* List view */
.list-wrap {
  divide-y: 1px solid var(--line-soft);
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background 0.12s;
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row:hover {
  background: #f8fafc;
}

.list-row.is-today {
  background: var(--today-bg);
}

.list-row.is-past {
  opacity: 0.62;
}

.list-date-col {
  min-width: 106px;
  flex-shrink: 0;
}

.list-date-main {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 700;
}

.list-date-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.list-shifts-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  flex: 1;
}

.list-chip {
  border-radius: 10px;
  padding: 7px 8px;
  text-align: center;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
}

.list-chip.morning { background: var(--morning-bg); border-color: #fde68a; }
.list-chip.afternoon { background: var(--afternoon-bg); border-color: #a7f3d0; }
.list-chip.evening { background: var(--evening-bg); border-color: #c7d2fe; }

.list-chip.mine {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}

.list-chip.dim {
  opacity: 0.35;
}

.list-chip-k {
  display: block;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.85;
}

.list-chip.mine .list-chip-k {
  color: #5eead4;
}

.list-chip-v {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-top: 1px;
}

.empty-box, .loading-box {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-sub {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.modal-body {
  padding: 16px 18px;
}

.modal-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fefce8;
  color: #854d0e;
  font-size: 13px;
}

.modal-foot {
  padding: 12px 18px 16px;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line-soft);
}

/* Footer & Toast */
.footer {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-light);
  padding: 0 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  z-index: 60;
}

/* Mobile optimizations */
@media (max-width: 760px) {
  .page {
    padding: 12px 10px 28px;
  }

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

  .brand-title {
    font-size: 18px;
  }

  .topbar-actions .btn span {
    display: none;
  }

  .topbar-actions .btn {
    width: 36px;
    padding: 0;
  }

  .list-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .list-date-col {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
  }

  .cal-cell {
    min-height: 98px;
    padding: 5px 3px;
  }

  .cal-cell-head {
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .cal-day-wrap {
    flex-direction: column;
    align-items: center;
    gap: 1px;
  }

  .cal-day-num {
    font-size: 13px;
  }

  .cal-lunar {
    font-size: 9px;
    max-width: 100%;
    text-align: center;
  }

  .cal-shift-row {
    padding: 2px 3px;
    font-size: 10px;
  }

  .cal-shift-row .p-tag {
    display: none;
  }

  .cal-shift-row .p-name {
    width: 100%;
    text-align: center;
  }
}

@media print {
  body {
    background: #fff;
  }
  .topbar-actions, .person-bar, .my-duty-banner, .schedule-toolbar, .footer {
    display: none !important;
  }
  .page {
    max-width: none;
    padding: 0;
  }
  .schedule-card, .hero-card {
    box-shadow: none;
  }
}
