* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  background: #f4f7fb;
  color: #172033;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  min-height: 40px;
  white-space: nowrap;
}

button:hover {
  background: #1d4ed8;
}

button:disabled,
button:disabled:hover {
  background: #cbd5e1;
  color: #64748b;
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-header h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.page-header p {
  margin: 0;
  color: #667085;
}

.link-button {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 9px 12px;
  background: #fff;
  text-align: center;
}

.dashboard-shell {
  min-height: 100vh;
  padding: 24px;
}

.history-shell {
  min-height: 100vh;
  padding: 24px;
}

.history-dashboard-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  align-items: start;
  gap: 16px;
}

.history-dashboard-shell .history-panel {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.dashboard-main,
.history-panel,
.panel {
  background: #fff;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  padding: 18px;
}

.team-panels {
  display: grid;
  gap: 16px;
}

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

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.section-title span {
  color: #64748b;
  font-size: 13px;
}

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

.member-card {
  border: 1px solid #d8e1ef;
  border-radius: 8px;
  padding: 14px;
  background: #fbfdff;
  display: grid;
  gap: 12px;
  min-height: 150px;
}

.member-card h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.member-card p {
  margin: 0;
  color: #64748b;
  overflow-wrap: anywhere;
}

.member-card dl {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 0;
}

.member-card dt {
  color: #64748b;
  font-size: 12px;
}

.member-card dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.status-pill {
  width: fit-content;
  justify-self: start;
  align-self: start;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  line-height: 1.4;
  background: #e2e8f0;
  white-space: nowrap;
}

.status-ok .status-pill {
  background: #dcfce7;
  color: #166534;
}

.status-off .status-pill {
  background: #fee2e2;
  color: #991b1b;
}

.status-busy .status-pill {
  background: #fef3c7;
  color: #92400e;
}

.availability-notes {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: #b45309;
  font-size: 12px;
  line-height: 1.45;
}

.availability-notes li {
  overflow-wrap: anywhere;
}

.availability-summary {
  display: grid;
  justify-items: start;
  gap: 6px;
}

.availability-detail-button {
  font-size: 12px;
  white-space: normal;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-list article {
  border-bottom: 1px solid #e5eaf2;
  padding-bottom: 10px;
}

.history-list strong,
.history-list span,
.history-list p {
  display: block;
}

.history-list span,
.history-list p {
  color: #64748b;
  margin: 4px 0 0;
}

.empty-text {
  color: #94a3b8;
  margin: 0;
}

.admin-shell {
  min-height: 100vh;
  padding: 24px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.panel {
  min-width: 0;
}

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

.panel-heading h2 {
  margin: 0;
}

.muted-text {
  color: #64748b;
  font-size: 13px;
}

.panel label,
.modal-panel label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: #475569;
}

.panel input,
.panel select,
.panel textarea,
.modal-panel input,
.modal-panel select,
.modal-panel textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  min-width: 0;
}

.panel textarea,
.modal-panel textarea {
  resize: none;
  overflow: hidden;
  min-height: 66px;
  line-height: 1.5;
}

.site-time-field {
  position: relative;
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  color: #475569;
}

.site-time-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.site-time-range-input {
  cursor: pointer;
}

.site-time-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}

.site-time-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.site-time-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

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

.admin-list,
.history-table {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.compact-member-list {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: grid;
  overflow: hidden;
  background: #fff;
}

.member-list-header,
.member-list-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.5fr) 90px minmax(118px, .7fr) 126px;
  gap: 12px;
  padding: 10px 12px;
}

.member-list-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid #e2e8f0;
  align-items: center;
}

.member-list-row {
  min-height: 72px;
  border-bottom: 1px solid #edf2f7;
  align-items: center;
}

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

.member-list-name {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.member-list-row > * {
  min-width: 0;
}

.member-list-name .availability-notes {
  margin-top: 2px;
  white-space: normal;
}

.member-list-name .availability-notes li {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.member-list-name strong,
.member-list-name small,
.member-counts {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-list-name strong {
  font-size: 14px;
}

.member-list-name small,
.member-counts {
  color: #64748b;
  font-size: 12px;
}

.mini-status {
  justify-self: start;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.member-list-row .mini-status,
.member-list-row .compact-actions,
.member-list-row .member-counts {
  align-self: center;
  margin-top: 0;
}

.status-ready {
  background: #dcfce7;
  color: #166534;
}

.status-blocked {
  background: #fee2e2;
  color: #991b1b;
}

.mini-status.status-busy {
  background: #fef3c7;
  color: #92400e;
}

.compact-actions {
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.mini-button {
  padding: 7px 9px;
  font-size: 13px;
}

.row-card {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
  display: grid;
  gap: 8px;
  background: #f8fafc;
}

.history-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.row-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.row-card strong,
.row-card span,
.row-card small {
  overflow-wrap: anywhere;
}

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

.pagination-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  color: #64748b;
  font-size: 13px;
}

.secondary-button {
  background: #475569;
}

.text-button {
  min-height: auto;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: #2563eb;
  text-align: left;
}

.text-button:hover {
  background: transparent;
  color: #1d4ed8;
}

.secondary-button:hover {
  background: #334155;
}

.danger-button {
  background: #dc2626;
}

.danger-button:hover {
  background: #b91c1c;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .38);
}

.modal-panel {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  padding: 18px;
  background: #fff;
  box-shadow: 0 22px 58px rgba(15, 23, 42, .24);
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header {
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.member-detail-modal {
  width: min(640px, 100%);
}

.member-detail-profile {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.member-detail-profile h3 {
  margin: 0 0 4px;
  font-size: 20px;
}

.member-detail-profile p {
  margin: 0;
  color: #64748b;
}

.member-detail-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.member-detail-stats div {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.member-detail-stats dt {
  color: #64748b;
  font-size: 12px;
}

.member-detail-stats dd {
  margin: 3px 0 0;
  font-size: 18px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.member-detail-section h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.member-detail-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.member-detail-list li {
  border-bottom: 1px solid #e5eaf2;
  padding-bottom: 8px;
  color: #475569;
  overflow-wrap: anywhere;
}

.icon-button {
  background: #e2e8f0;
  color: #334155;
  padding: 8px 10px;
}

.icon-button:hover {
  background: #cbd5e1;
}

@media (max-width: 980px) {
  .dashboard-shell,
  .history-dashboard-shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .history-dashboard-shell .history-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

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

  .compact-member-list {
    overflow: visible;
  }

  .member-list-header,
  .member-list-row {
    grid-template-columns: minmax(180px, 1.4fr) 84px 112px 118px;
  }

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

  .pagination-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .field-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .site-time-control,
  .site-time-picker-grid {
    grid-template-columns: 1fr;
  }

  .site-time-popover {
    position: static;
    margin-top: 4px;
  }
}

@media (max-width: 640px) {
  body {
    background: #eef3f8;
  }

  button,
  .link-button,
  input,
  select,
  textarea {
    min-height: 44px;
  }

  .dashboard-shell,
  .history-shell,
  .admin-shell {
    padding: 10px;
  }

  .dashboard-shell {
    gap: 10px;
  }

  .dashboard-main,
  .history-panel,
  .panel {
    border-radius: 8px;
    padding: 12px;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .page-header p,
  .section-title span,
  .muted-text {
    font-size: 12px;
  }

  .link-button {
    width: 100%;
  }

  .team-panels,
  .admin-grid,
  .history-list,
  .admin-list,
  .history-table {
    gap: 10px;
  }

  .section-title,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .panel-heading button {
    width: 100%;
  }

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

  .member-card {
    min-height: auto;
    padding: 12px;
  }

  .member-card h3 {
    font-size: 17px;
  }

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

  .member-card dd {
    font-size: 18px;
  }

  .history-list article {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 10px;
    background: #f8fafc;
  }

  .site-time-control,
  .site-time-picker-grid {
    grid-template-columns: 1fr;
  }

  .site-time-picker-actions,
  .modal-actions,
  .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .site-time-picker-actions button,
  .modal-actions button,
  .row-actions button {
    width: 100%;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 8px;
  }

  .modal-panel {
    width: 100%;
    max-height: calc(100vh - 16px);
    padding: 12px;
  }

  .modal-header {
    align-items: flex-start;
  }

  .compact-member-list {
    border: 0;
    border-radius: 0;
    gap: 8px;
    background: transparent;
  }

  .member-list-header {
    display: none;
  }

  .member-list-row {
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: auto;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
  }

  .member-list-name strong,
  .member-list-name small,
  .member-counts {
    white-space: normal;
  }

  .member-list-row .mini-status,
  .member-list-row .compact-actions,
  .member-list-row .member-counts {
    justify-self: stretch;
  }

  .mini-status {
    width: fit-content;
  }

  .compact-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    justify-content: stretch;
  }

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

  .pagination-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .pagination-controls button {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .member-card dl {
    grid-template-columns: 1fr;
  }

  .site-time-picker-actions,
  .modal-actions,
  .row-actions,
  .compact-actions {
    grid-template-columns: 1fr;
  }
}
