:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --ink: #1d2724;
  --muted: #64726d;
  --line: #dce4df;
  --accent: #0e7c68;
  --accent-strong: #095f50;
  --blue: #246b9f;
  --amber: #b56d16;
  --danger: #b03333;
  --danger-soft: #fff0f0;
  --danger-line: #eba8a8;
  --shadow: 0 18px 40px rgba(30, 42, 38, 0.09);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(14, 124, 104, 0.08), rgba(14, 124, 104, 0) 280px),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.workspace {
  max-width: 1440px;
  margin: 0 auto;
}

.topbar,
.calendar-toolbar,
.section-heading,
.summary-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
}

.topbar-actions,
.status-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 2.6vw, 2.7rem);
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

h3 {
  margin: 0;
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.control-panel,
.calendar-area,
.summary-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 20px;
  overflow: hidden;
}

.panel-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 0.8fr;
  gap: 12px;
  margin-top: 14px;
}

.single-field {
  display: block;
  margin-top: 14px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(14, 124, 104, 0.22);
  outline-offset: 2px;
}

.button,
.icon-button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.button {
  min-height: 42px;
  padding: 0 16px;
}

.button.secondary {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  flex: 0 0 auto;
  font-size: 1.1rem;
  line-height: 1;
}

.icon-button.danger {
  background: #fff1f1;
  color: var(--danger);
  border: 1px solid #f0caca;
}

.doctor-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.doctor-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 34px 34px;
  gap: 6px 8px;
  align-items: center;
}

.doctor-input {
  min-width: 0;
}

.period-button {
  color: var(--doctor-ink, var(--accent-strong));
  background: var(--doctor-bg, var(--surface-soft));
  border: 1px solid var(--doctor-border, var(--line));
}

.period-button:hover {
  border-color: var(--doctor-chip, var(--accent));
}

.doctor-period-label {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.doctor-row.has-custom-period .doctor-period-label {
  color: var(--doctor-ink, var(--accent-strong));
  font-weight: 700;
}

.period-dialog {
  width: min(460px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.period-dialog::backdrop {
  background: rgba(29, 39, 36, 0.35);
}

.period-dialog-meta {
  margin: 8px 0 20px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  cursor: pointer;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  min-height: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.checkbox-field span {
  margin: 0;
  color: var(--ink);
}

.period-date-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.period-date-grid input {
  min-width: 0;
  padding: 0 8px;
}

.period-date-grid input:disabled {
  background: var(--bg);
  color: var(--muted);
}

.period-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.doctor-swatch {
  width: 18px;
  height: 18px;
  border: 2px solid var(--doctor-chip, var(--accent));
  border-radius: 50%;
  background: var(--doctor-bg, var(--surface-soft));
}

.helper-text {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.calendar-area {
  padding: 18px;
  min-width: 0;
}

.calendar-toolbar {
  margin-bottom: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.blue {
  background: #edf5fb;
  color: var(--blue);
}

.pill.amber {
  background: #fff4e6;
  color: var(--amber);
}

.pill.red {
  background: var(--danger-soft);
  color: var(--danger);
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(126px, 1fr));
  gap: 10px;
}

.weekday-row {
  margin-bottom: 10px;
}

.weekday-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.day-card,
.empty-day {
  min-height: 154px;
  border-radius: var(--radius);
}

.day-card {
  display: grid;
  grid-template-rows: auto minmax(44px, 1fr) auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--doctor-border, var(--line));
  border-left: 5px solid var(--doctor-chip, var(--accent));
  background: var(--doctor-bg, #fff);
}

.day-card.today {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(14, 124, 104, 0.12);
}

.day-card.special-day {
  border-color: var(--danger-line);
  border-left-color: var(--danger);
  background:
    linear-gradient(180deg, rgba(176, 51, 51, 0.14), rgba(176, 51, 51, 0.08)),
    var(--doctor-bg, #fff);
}

.day-card.uncovered-day {
  border-color: #ecc98e;
  border-left-color: var(--amber);
  background: #fff4e6;
}

.uncovered-day .day-detail strong {
  color: var(--amber);
}

.empty-day {
  border: 1px dashed #d7dfda;
  background: repeating-linear-gradient(
    -45deg,
    #f8faf8,
    #f8faf8 8px,
    #f1f5f2 8px,
    #f1f5f2 16px
  );
}

.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.day-number {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  font-weight: 900;
}

.special-day .day-number {
  background: var(--danger);
  color: #fff;
}

.week-tag {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.doctor-name {
  align-self: center;
  min-width: 0;
}

.day-detail {
  align-self: center;
  min-width: 0;
}

.day-detail strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--doctor-ink, var(--ink));
  font-size: clamp(1rem, 1.1vw, 1.2rem);
}

.day-detail span,
.shift-time {
  color: var(--muted);
  font-size: 0.83rem;
}

.holiday-detail strong {
  color: var(--danger);
}

.holiday-note {
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.shift-time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.summary-band {
  margin-top: 20px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  align-items: start;
}

.summary-title {
  min-width: 0;
}

.summary-stack {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.summary-block {
  min-width: 0;
}

.summary-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.summary-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 10px;
  flex: 1;
}

.summary-item {
  min-height: 78px;
  border: 1px solid var(--doctor-border, var(--line));
  border-left: 5px solid var(--doctor-chip, var(--accent));
  border-radius: var(--radius);
  padding: 12px;
  background: var(--doctor-bg, #fff);
}

.summary-item strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--doctor-ink, var(--ink));
  font-size: 1.1rem;
}

.summary-item span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.83rem;
}

.warning {
  color: var(--danger);
  font-weight: 800;
}

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

  .control-panel {
    position: static;
  }

  .summary-band {
    display: block;
  }

  .summary-stack {
    margin-top: 14px;
  }

  .summary-grid {
    margin-top: 0;
  }
}

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

  .topbar,
  .calendar-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .button {
    flex: 1;
  }

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

  .weekday-row,
  .calendar-grid {
    min-width: 680px;
  }

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

}

@media (max-width: 520px) {
  .field-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.6rem;
  }

  .period-date-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff;
  }

  @page {
    margin: 12mm;
  }

  .app-shell {
    padding: 0;
  }

  .topbar,
  .control-panel,
  .summary-band,
  .period-dialog {
    display: none;
  }

  .period-dialog::backdrop {
    display: none;
  }

  .workspace,
  .layout {
    display: block;
    max-width: none;
  }

  .calendar-area,
  .summary-band {
    box-shadow: none;
    border-color: #bbb;
  }

  .calendar-area {
    padding: 0;
    border: 0;
  }

  .weekday-row,
  .calendar-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 7px;
    min-width: 0;
  }

  .day-card,
  .empty-day {
    min-height: 112px;
    break-inside: avoid;
  }

  .day-card {
    box-shadow: none;
  }
}
