:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  --ink: #172033;
  --muted: #647085;
  --line: #d8dee8;
  --panel: #ffffff;
  --wash: #f5f7fb;
  --accent: #1f7a6d;
  --accent-strong: #155d54;
  --accent-soft: #e4f3f0;
  --warm: #f6ede2;
  --warning: #9b5d12;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(31, 122, 109, 0.08), transparent 320px),
    var(--wash);
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.query-panel {
  display: block;
}

.title-block,
.date-card,
.today-section,
.calendar-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.title-block {
  padding: 22px 28px;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 30px);
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  letter-spacing: 0;
}

.subtitle,
.muted,
.date-hint {
  color: var(--muted);
}

.subtitle {
  margin-bottom: 0;
  font-size: 17px;
}

.date-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 16px;
}

.date-card label {
  color: var(--muted);
  font-weight: 700;
}

.date-row {
  display: grid;
  width: min(100%, 390px);
  grid-template-columns: 172px 128px 64px;
  gap: 10px;
}

.date-picker-shell {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 46px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  overflow: hidden;
}

.date-display {
  min-width: 0;
  font-weight: 700;
  white-space: nowrap;
}

.date-picker-shell input[type="date"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#time-input {
  min-width: 0;
  padding: 0 10px;
}

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

textarea {
  min-height: 74px;
  padding-top: 10px;
  resize: vertical;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

button:active {
  transform: translateY(1px);
}

.primary-button {
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  padding: 0 16px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.secondary-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.date-hint {
  min-height: 0;
  margin-bottom: 0;
}

.tab-bar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.tab-button,
.admin-tab-button,
.mode-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab-button {
  flex: 1;
  min-height: 38px;
}

.tab-button.active,
.admin-tab-button.active,
.mode-button.active {
  border-color: rgba(31, 122, 109, 0.35);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tab-panel,
.admin-panel {
  display: none;
}

.tab-panel.active,
.admin-panel.active {
  display: block;
}

.today-section,
.calendar-section,
.admin-section,
.phone-section {
  margin-top: 12px;
  padding: 20px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.phone-heading {
  align-items: end;
}

.phone-search-input {
  width: min(420px, 100%);
}

.phone-result-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.phone-result-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.phone-result-item strong {
  min-width: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.phone-number-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.phone-number-line span {
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.result-grid {
  display: grid;
  gap: 8px;
}

.duty-line {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 6px;
  align-items: baseline;
  font-size: clamp(19px, 2vw, 21px);
  line-height: 1.38;
  font-weight: 800;
}

.duty-line-label {
  color: var(--accent-strong);
  white-space: nowrap;
}

.duty-line-value {
  min-width: 0;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.duty-phone-button {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  line-height: inherit;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(31, 122, 109, 0.34);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.duty-phone-button:hover {
  color: var(--accent-strong);
}

.duty-separator {
  color: var(--ink);
}

.summary-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.summary-notes p {
  margin-bottom: 0;
}

.inline-date-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--wash);
  box-shadow: none;
}

.result-card {
  min-height: 118px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-card.primary {
  border-color: rgba(31, 122, 109, 0.35);
  background: var(--accent-soft);
}

.result-card.attention {
  border-color: rgba(155, 93, 18, 0.3);
  background: #fffaf2;
}

.department-name {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.duty-name {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.1;
  font-weight: 800;
}

.rule-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.shift-name {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef1f6;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.month-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.calendar-grid {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.calendar-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: #fff;
}

.calendar-table th,
.calendar-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 10px;
  text-align: center;
  vertical-align: middle;
}

.calendar-table th:last-child,
.calendar-table td:last-child {
  border-right: 0;
}

.calendar-table tr:last-child td {
  border-bottom: 0;
}

.day-heading {
  width: 72px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.calendar-day {
  font-weight: 800;
}

.weekend {
  background: var(--warm);
}

.selected-day {
  outline: 3px solid rgba(31, 122, 109, 0.34);
  outline-offset: -3px;
}

.today-marker {
  color: var(--warning);
}

.dept-cell {
  font-size: 14px;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.phone-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.phone-modal-backdrop {
  position: absolute;
  inset: 0;
  min-height: 0;
  border-radius: 0;
  background: rgba(23, 32, 51, 0.42);
}

.phone-modal-card {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  max-height: min(82vh, 680px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.phone-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.phone-modal-close {
  flex: 0 0 42px;
}

.phone-modal-body {
  display: grid;
  gap: 10px;
  padding: 14px;
  overflow: auto;
}

.hidden {
  display: none !important;
}

.login-card,
.password-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.login-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.login-row label {
  align-self: center;
  color: var(--muted);
  font-weight: 800;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--wash);
}

.admin-tab-button {
  flex: 1;
  min-height: 40px;
}

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

.settings-grid.single {
  grid-template-columns: 1fr;
}

.settings-card {
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.settings-card legend {
  padding: 0 8px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.settings-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.check-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.check-line input {
  min-height: auto;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 184px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--wash);
}

.mode-button {
  min-height: 34px;
  padding: 0 10px;
}

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

.field-grid label,
.password-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.wide-field {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.form-actions button {
  min-width: 150px;
}

.cardiology-manual-card {
  display: grid;
  gap: 12px;
}

.cardiology-enable {
  width: max-content;
}

.manual-help {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.manual-week-grid {
  display: grid;
  gap: 10px;
}

.manual-day-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.manual-day-row span {
  display: grid;
  gap: 2px;
}

.manual-day-row small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.phone-card {
  display: grid;
  gap: 12px;
}

.phone-grid {
  display: grid;
  gap: 10px;
}

.phone-row {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) 118px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.phone-row input {
  text-align: center;
}

.phone-lines-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .query-panel {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0 18px;
  }

  .title-block,
  .date-card,
  .today-section,
  .calendar-section,
  .admin-section,
  .phone-section {
    padding: 12px;
  }

  h1 {
    font-size: 25px;
  }

  .date-row {
    width: 100%;
    grid-template-columns: 132px minmax(112px, 1fr) 52px;
    gap: 6px;
  }

  .result-grid,
  .login-row,
  .field-grid,
  .phone-result-list {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .secondary-button,
  #copy-button {
    width: 100%;
  }

  .date-row .secondary-button {
    width: auto;
    padding: 0 6px;
  }

  .today-section .section-heading {
    align-items: center;
    flex-direction: row;
  }

  .today-section .section-heading h2 {
    font-size: 20px;
  }

  #copy-button {
    width: auto;
    min-height: 36px;
    padding: 0 10px;
  }

  .duty-line {
    grid-template-columns: 50px minmax(0, 1fr);
    font-size: 20px;
  }

  .summary-notes {
    gap: 4px;
    font-size: 12px;
  }

  .month-actions {
    width: 100%;
  }

  .icon-button {
    flex: 1;
  }

  .admin-tabs,
  .settings-topline,
  .form-actions {
    flex-direction: column;
  }

  .tab-bar {
    gap: 4px;
    margin-top: 8px;
    padding: 4px;
  }

  .tab-button {
    min-height: 34px;
    padding: 0 6px;
    font-size: 14px;
  }

  .mode-toggle {
    width: 100%;
    min-width: 0;
  }

  .manual-day-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .phone-row {
    grid-template-columns: 1fr;
  }
}
