:root {
  --primary: #1677ff;
  --primary-hover: #4096ff;
  --primary-bg: #e6f4ff;
  --success-bg: #f6ffed;
  --success-border: #b7eb8f;
  --warning-bg: #fffbe6;
  --warning-border: #ffe58f;
  --error: #ff4d4f;
  --text: rgba(0, 0, 0, 0.88);
  --text-2: rgba(0, 0, 0, 0.65);
  --text-3: rgba(0, 0, 0, 0.45);
  --border: #d9d9d9;
  --border-light: #f0f0f0;
  --bg: #f5f5f5;
  --card: #ffffff;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-size: 14px;
  line-height: 1.5715;
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

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

h1,
h2,
p {
  margin: 0;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 700;
}

h1 {
  font-size: 20px;
  line-height: 1.25;
  font-weight: 600;
}

h2 {
  font-size: 15px;
  line-height: 1.4;
  font-weight: 600;
}

.brand p,
.card-head p,
.metric-card span,
.room-meta,
.course-block span,
.current-course span,
.section-col span {
  color: var(--text-3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tag {
  height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fafafa;
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
}

.app-main {
  padding: 12px 20px 24px;
}

.ant-card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
}

.card-actions,
.schedule-tools,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-card {
  overflow: hidden;
}

.filter-grid {
  display: grid;
  grid-template-columns: 150px 82px 92px 150px 150px 132px minmax(140px, 1fr) minmax(140px, 1fr) 118px;
  gap: 10px;
  align-items: end;
  padding: 12px 14px 14px;
}

.form-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.form-item > span {
  color: var(--text-3);
  font-size: 12px;
}

.ant-input,
.ant-select {
  width: 100%;
  height: 32px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 11px;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ant-select {
  appearance: none;
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 13px, calc(100% - 10px) 13px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.ant-input:hover,
.ant-select:hover {
  border-color: var(--primary-hover);
}

.ant-input:focus,
.ant-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.12);
}

.ant-btn {
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 6px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.ant-btn-default:hover {
  color: var(--primary);
  border-color: var(--primary-hover);
}

.ant-btn-primary {
  color: #ffffff;
  border-color: var(--primary);
  background: var(--primary);
}

.ant-btn-primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  color: var(--text-2);
  background: transparent;
  font-size: 22px;
  cursor: pointer;
}

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

.icon {
  font-size: 15px;
  line-height: 1;
}

.ant-checkbox {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  white-space: nowrap;
}

.ant-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.metric-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--card);
}

.metric-card strong {
  font-size: 26px;
  line-height: 1;
  font-weight: 600;
}

.workbench {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
  height: calc(100vh - 252px);
  min-height: 520px;
}

.room-panel,
.schedule-panel {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.schedule-panel {
  display: flex;
  flex-direction: column;
}

.compact-head {
  min-height: 56px;
}

.mini-select {
  width: 102px;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-height: 420px;
  max-height: calc(100vh - 352px);
  overflow: auto;
  padding: 10px;
}

.room-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--card);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.room-card:hover,
.room-card.active {
  color: var(--primary);
  border-color: #91caff;
  background: var(--primary-bg);
}

.room-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.room-meta {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 10px;
  border-top: 1px solid var(--border-light);
  color: var(--text-2);
}

.schedule-head {
  align-items: flex-start;
}

.schedule-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 780px;
}

.schedule-tools .ant-input:first-child {
  width: min(360px, 34vw);
}

.schedule-tools .ant-input:nth-child(3) {
  width: min(220px, 24vw);
}

.current-course {
  margin: 10px 12px 0;
}

.current-ok,
.current-busy,
.empty-state {
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: #fafafa;
}

.current-ok {
  border-color: var(--success-border);
  background: var(--success-bg);
}

.current-busy {
  display: grid;
  gap: 2px;
  border-color: var(--warning-border);
  background: var(--warning-bg);
}

.current-ok strong,
.current-ok span,
.current-busy strong,
.current-busy span {
  display: block;
}

.schedule-scroll {
  flex: 1;
  min-height: 0;
  padding: 10px 12px 12px;
  overflow: auto;
}

.schedule-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 12px;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid var(--border-light);
  border-top: 0;
  border-left: 0;
  padding: 6px;
  vertical-align: top;
}

.schedule-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 44px;
  background: #fafafa;
  text-align: left;
  font-weight: 600;
  border-top: 1px solid var(--border-light);
}

.schedule-table th span,
.schedule-table th strong,
.section-col span,
.section-col strong {
  display: block;
}

.schedule-table th span,
.section-col span {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 400;
}

.schedule-table td {
  height: 72px;
}

.section-col {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 92px;
  background: #fafafa;
  border-left: 1px solid var(--border-light);
  box-shadow: 1px 0 0 var(--border-light);
}

.schedule-table thead .section-col {
  z-index: 4;
}

.course-block {
  margin-bottom: 4px;
  padding: 5px 6px;
  border: 1px solid var(--success-border);
  border-radius: 4px;
  background: var(--success-bg);
}

.course-block:last-child {
  margin-bottom: 0;
}

.course-block strong,
.course-block span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-block strong {
  margin-bottom: 2px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 600;
}

.course-block span {
  color: var(--text-3);
  font-size: 11px;
  white-space: nowrap;
}

.empty-state {
  color: var(--text-3);
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}

.modal-mask[hidden] {
  display: none;
}

.modal {
  width: min(560px, 100%);
  overflow: hidden;
}

.import-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px;
}

.file-item,
.import-result,
.modal-actions {
  grid-column: 1 / -1;
}

.import-result {
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: #fafafa;
  color: var(--text-2);
}

.import-result.success {
  color: #237804;
  border-color: var(--success-border);
  background: var(--success-bg);
}

.import-result.error {
  color: var(--error);
  border-color: #ffccc7;
  background: #fff2f0;
}

.modal-actions {
  justify-content: flex-end;
}

@media (max-width: 1280px) {
  .filter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .workbench {
    grid-template-columns: 320px minmax(0, 1fr);
  }
}

@media (max-width: 960px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .workbench {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .schedule-panel {
    height: min(760px, 78vh);
    min-height: 520px;
  }

  .room-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: none;
  }

  .schedule-head {
    flex-direction: column;
  }

  .schedule-tools {
    width: 100%;
    justify-content: stretch;
  }

  .schedule-tools .ant-input:first-child,
  .schedule-tools .ant-input:nth-child(3) {
    width: auto;
    flex: 1 1 220px;
  }
}

@media (max-width: 720px) {
  .app-main {
    padding: 10px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    display: none;
  }

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

  .card-actions,
  .schedule-tools,
  .modal-actions {
    width: 100%;
  }

  .card-actions .ant-btn,
  .schedule-tools .ant-btn,
  .modal-actions .ant-btn {
    flex: 1;
  }

  .filter-grid,
  .metrics,
  .import-form {
    grid-template-columns: 1fr;
  }

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

  .metric-card {
    min-height: 50px;
  }

  .metric-card strong {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 18px;
  }

  .app-header {
    padding: 10px;
  }

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

  .pagination {
    flex-wrap: wrap;
  }
}
