:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --panel: #ffffff;
  --ink: #1f2528;
  --muted: #64706a;
  --line: #dbe2dc;
  --accent: #0f766e;
  --day: #e3f2fd;
  --day-ink: #155e91;
  --checkup: #dcfce7;
  --checkup-ink: #166534;
  --night: #ede9fe;
  --night-ink: #5b21b6;
  --full: #fff2cc;
  --full-ink: #925400;
  --rest: #fde8e8;
  --rest-ink: #b42318;
  --off: #f7f4ed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 18px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 6vw, 58px);
  line-height: 1;
}

.controls,
.legend,
.calendar-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.controls {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

select {
  padding: 0 12px;
}

select option {
  background: var(--bg);
  color: var(--ink);
}

select option:checked {
  background: var(--bg);
}

.shift-select option[value="day"] {
  color: var(--day-ink);
}

.shift-select option[value="checkup"] {
  color: var(--checkup-ink);
}

.shift-select option[value="night"] {
  color: var(--night-ink);
}

.shift-select option[value="full"] {
  color: var(--full-ink);
}

.shift-select option[value="afterNight"] {
  color: var(--rest-ink);
}

.shift-select option[value="off"] {
  color: var(--muted);
}

button {
  align-self: end;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 16px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.day {
  background: var(--day-ink);
}

.dot.checkup {
  background: var(--checkup-ink);
}

.dot.night {
  background: var(--night-ink);
}

.dot.full {
  background: var(--full-ink);
}

.dot.rest {
  background: var(--rest-ink);
}

.calendar-panel {
  overflow: hidden;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr)) minmax(92px, 0.72fr);
}

.calendar-weekdays {
  background: #f8faf8;
  border-bottom: 1px solid var(--line);
}

.calendar-weekdays span {
  padding: 12px 10px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 900;
}

.day-cell {
  min-height: 170px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.day-cell:nth-child(8n) {
  border-right: 0;
}

.day-cell.empty {
  background: #f3f6f2;
}

.day-cell.special {
  background: var(--off);
}

.stats-cell {
  min-height: 170px;
  padding: 10px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f8faf8;
}

.stats-title {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.stats-values {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  color: var(--ink);
  line-height: 1;
}

.stats-values span {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: baseline;
  gap: 4px;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.stats-values b {
  color: var(--muted);
  font-size: 12px;
}

.stats-values strong {
  font-size: 18px;
}

.monthly-summary {
  grid-column: 8;
  background: #eef7f4;
}

.last-week-summary {
  grid-column: 8;
}

.date-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 8px;
}

.date-number {
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.date-note {
  color: var(--muted);
  text-align: right;
  font-size: 12px;
  line-height: 1.2;
}

.assignments {
  display: grid;
  gap: 6px;
}

.person-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 6px;
}

.person {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eef2f0;
  font-size: 12px;
  font-weight: 900;
}

.shift,
.shift-select,
.shift-pdf {
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.3;
}

.shift-select {
  width: 100%;
  height: 28px;
  border: 1px solid transparent;
  cursor: pointer;
}

.shift-pdf {
  display: flex;
  align-items: center;
  width: 100%;
  height: 28px;
  border: 1px solid transparent;
}

.shift.day,
.shift-select.day,
.shift-pdf.day {
  background: var(--day);
  color: var(--day-ink);
}

.shift.checkup,
.shift-select.checkup,
.shift-pdf.checkup {
  background: var(--checkup);
  color: var(--checkup-ink);
}

.shift.night,
.shift-select.night,
.shift-pdf.night {
  background: var(--night);
  color: var(--night-ink);
}

.shift.full,
.shift-select.full,
.shift-pdf.full {
  background: var(--full);
  color: var(--full-ink);
}

.shift.rest,
.shift.afterNight,
.shift-select.rest,
.shift-select.afterNight,
.shift-pdf.rest,
.shift-pdf.afterNight {
  background: var(--rest);
  color: var(--rest-ink);
}

.shift.off,
.shift-select.off,
.shift-pdf.off {
  background: #eef1ee;
  color: var(--muted);
}

body.exporting-pdf {
  min-width: 1236px;
}

body.exporting-pdf .workspace {
  width: 1180px;
}

body.exporting-pdf .controls,
body.exporting-pdf .topbar .eyebrow {
  display: none;
}

body.exporting-pdf .topbar h1 {
  font-size: 40px;
}

body.exporting-pdf .calendar-panel {
  overflow: visible;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

  .controls {
    grid-template-columns: repeat(2, 1fr);
  }

  .calendar-weekdays,
  .calendar-grid {
    grid-template-columns: repeat(7, minmax(104px, 1fr)) minmax(88px, 0.72fr);
  }

  .calendar-panel {
    overflow-x: auto;
  }
}

@media (max-width: 560px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .day-cell {
    min-height: 138px;
  }
}

@media print {
  @page {
    size: 320mm 410mm;
    margin: 3mm;
  }

  body {
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-shell {
    padding: 0;
  }

  .topbar {
    display: flex;
  }

  .topbar .eyebrow {
    display: none;
  }

  .controls {
    display: none;
  }

  .workspace {
    width: 1180px;
  }

  .calendar-panel {
    overflow: visible;
  }
}
