:root {
  color-scheme: light;
  --bg: #eaf5ff;
  --surface: #fbfdff;
  --surface-soft: #f2f8ff;
  --text: #071d36;
  --muted: #49657f;
  --line: #bed8f2;
  --green: #0877c9;
  --green-soft: #dff1ff;
  --coral: #1d4ed8;
  --coral-soft: #e1edff;
  --gold: #2563eb;
  --gold-soft: #eaf3ff;
  --blue: #0877c9;
  --blue-soft: #dceeff;
  --shadow: 0 14px 34px rgba(18, 92, 157, 0.12);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 0%, rgba(121, 188, 255, 0.28), transparent 28%),
    linear-gradient(135deg, #eaf5ff 0%, #f7fbff 44%, #e8f9fb 100%);
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  min-height: 84px;
  padding: 24px;
  border: 1px solid #c9ddec;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff 0%, #edf6fb 100%);
  box-shadow: 0 12px 28px rgba(45, 103, 154, 0.1);
}

.eyebrow {
  margin: 0 0 6px;
  color: #0070c9;
  font-size: 13px;
  font-weight: 800;
}

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

h1 {
  color: #0c2038;
  font-size: 34px;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
}

.sync-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.refresh-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #c8ddf2;
  border-radius: 8px;
  color: var(--blue);
  background: #f7fbff;
  font: 700 18px/1 "Segoe UI", Arial, sans-serif;
  cursor: pointer;
}

.refresh-button:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.refresh-button.is-syncing {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.sync-meta span,
.count-pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.metric {
  min-height: 112px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f3f9ff 100%);
  box-shadow: var(--shadow);
  text-align: center;
}

.metric:first-child {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #154f8d 0%, #098fd1 56%, #29c4c0 100%);
}

.metric:first-child .metric-label {
  color: rgba(255, 255, 255, 0.88);
}

.metric-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.metric strong {
  font-size: 34px;
  line-height: 1;
}

.metric-warm {
  border-color: #ff9f96;
  background: linear-gradient(135deg, #fff4f1 0%, #ffe5df 100%);
  box-shadow: 0 14px 34px rgba(224, 70, 61, 0.14);
}

.metric-warm .metric-label {
  color: #8b4d55;
}

.metric-warm strong {
  color: #e0463d;
}

.metric-alert {
  background: linear-gradient(135deg, #e5f1ff 0%, #d9ecff 100%);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 253, 255, 0.86);
  box-shadow: var(--shadow);
}

.toolbar label,
.toolbar input,
.toolbar select {
  text-align: center;
}

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

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(8, 119, 201, 0.22);
  border-color: var(--blue);
}

.toggle {
  min-height: 40px;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: var(--text);
}

.toggle input {
  width: 18px;
  min-height: 18px;
}

.panel {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(251, 253, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel-main {
  min-height: 280px;
}

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

.section-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.export-button {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid #0877c9;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, #0877c9, #12a6da);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.export-button:hover {
  background: linear-gradient(135deg, #0566ad, #0d92c2);
}

.export-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.section-head.compact {
  min-height: 32px;
}

.detail-head {
  align-items: flex-end;
}

.detail-tools {
  display: grid;
  grid-template-columns: 150px minmax(220px, 320px);
  gap: 12px;
  align-items: end;
  width: min(520px, 100%);
}

.detail-tools label {
  min-width: 0;
}

.birthday-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.birthday-card {
  min-height: 164px;
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--card-border, var(--line));
  border-radius: 8px;
  background: linear-gradient(135deg, var(--card-bg-1, #ffffff) 0%, var(--card-bg-2, #f3f9ff) 100%);
}

.date-tile {
  width: 70px;
  height: 86px;
  display: grid;
  align-content: center;
  justify-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--tile-bg-1, #dff1ff) 0%, var(--tile-bg-2, #d4f4fb) 100%);
  color: var(--card-accent, #0877c9);
}

.date-tile strong {
  font-size: 24px;
  line-height: 1;
}

.date-tile span {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
}

.person-main {
  min-width: 0;
}

.person-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 800;
}

.days-badge {
  flex: 0 0 auto;
  min-width: 54px;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--date-badge-fg, #1d4ed8);
  background: var(--date-badge-bg, #e1edff);
  font-size: 12px;
  text-align: center;
}

.person-line,
.person-meta {
  margin: 5px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.calendar-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--date-badge-bg, var(--blue-soft));
  color: var(--date-badge-fg, var(--blue));
  font-size: 12px;
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.month-bars {
  display: grid;
  gap: 10px;
}

.month-row {
  display: grid;
  grid-template-columns: 48px minmax(80px, 1fr) 36px;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  color: var(--muted);
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 8px;
  background: #d8e9fa;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--bar-start, #0b7fd0), var(--bar-end, #55c4f0));
}

.missing-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.missing-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f9ff;
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dceeff;
  color: #0877c9;
  font-weight: 800;
}

.missing-item strong {
  display: block;
  font-size: 14px;
}

.missing-item span {
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  background: var(--surface);
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}

.table-wrap th,
.table-wrap td {
  text-align: center;
}

.sequence-col {
  width: 72px;
}

.sort-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.sort-header:hover {
  color: var(--blue);
}

.sequence-cell {
  color: #31506f;
  font-weight: 800;
}

.dept-badge,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.dept-badge {
  color: var(--badge-fg);
  background: var(--badge-bg);
}

.status-badge {
  color: #5f6872;
  background: #e9ecef;
}

.status-formal {
  color: #0877c9;
  background: #dff1ff;
}

.status-trial {
  color: #1d4ed8;
  background: #e1edff;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #edf6ff;
  font-size: 13px;
}

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

.empty {
  min-height: 120px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

@media (max-width: 960px) {
  .kpis,
  .split {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 680px) {
  .shell {
    width: min(100% - 20px, 1440px);
    padding-top: 18px;
  }

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

  h1 {
    font-size: 28px;
  }

  .kpis,
  .split,
  .toolbar,
  .detail-tools {
    grid-template-columns: 1fr;
  }

  .detail-head {
    align-items: stretch;
  }

  .metric {
    min-height: 96px;
  }

  .birthday-card {
    grid-template-columns: 62px 1fr;
  }

  .date-tile {
    width: 62px;
    height: 78px;
  }
}
