:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --line: #dbe3ee;
  --text: #1f2937;
  --muted: #64748b;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Segoe UI", Arial, sans-serif;
}

.app {
  min-height: 100vh;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.25;
}

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

.topbar p,
.panel-head p,
.drop-hint,
.preview-panel p {
  color: var(--muted);
  font-size: 13px;
}

.panel-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}

.panel-meta span:last-child {
  color: #334155;
  font-weight: 800;
}

.status-pill {
  min-width: 150px;
  padding: 9px 14px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
  text-align: center;
}

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

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

.drop-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.drop-card,
.panel,
.controls,
.progress-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.drop-card {
  min-height: 78px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.drop-card:hover,
.drop-card.dragging {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.drop-card input[type="file"] {
  display: none;
}

.drop-title {
  font-weight: 800;
  font-size: 15px;
}

.controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
}

.controls label,
.filter-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

input,
select {
  height: 34px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

#prefixInput {
  width: 126px;
}

#schoolNameInput {
  width: 230px;
}

#schoolCodeInput {
  width: 110px;
}

button {
  height: 34px;
  border: 0;
  background: #475569;
  color: #fff;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

button.primary {
  background: var(--green);
}

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

.progress-panel {
  padding: 10px 12px;
}

.progress-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.progress-track {
  height: 9px;
  background: #e2e8f0;
  overflow: hidden;
}

#progressBar {
  width: 0;
  height: 100%;
  background: var(--blue);
  transition: width 0.2s;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 178px;
}

.rule-dashboard {
  overflow: visible;
}

.rule-dashboard-head {
  align-items: flex-start;
}

.rule-filters {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.inline-check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
}

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

.metric-card {
  min-height: 86px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 5px 12px;
  align-items: center;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  grid-row: 1 / 3;
  grid-column: 2;
  font-size: 27px;
  line-height: 1;
  color: #0f172a;
}

.metric-card.ok {
  border-color: #86efac;
  background: #f0fdf4;
}

.metric-card.error {
  border-color: #fecaca;
  background: #fef2f2;
}

.metric-card.warn-card {
  border-color: #fed7aa;
  background: #fff7ed;
}

.audit-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(620px, 1.6fr);
  gap: 12px;
}

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

.audit-title {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.audit-title h3 {
  margin: 0;
  font-size: 14px;
}

.audit-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.audit-table-wrap {
  height: 270px;
}

.audit-table-wrap table {
  font-size: 12px;
}

.audit-table-wrap th,
.audit-table-wrap td {
  padding: 6px 8px;
}

.room-audit-block .audit-table-wrap {
  height: 270px;
}

.allocation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 230px;
}

.allocation-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #1e3a8a;
  background: #dbeafe;
  font-weight: 800;
}

.allocation-chip.actual {
  color: #166534;
  background: #dcfce7;
}

.allocation-chip.mismatch {
  color: #991b1b;
  background: #fee2e2;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

.status-tag.pending {
  color: #92400e;
  background: #fef3c7;
}

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

.mixed-room-row {
  background: #fffbeb !important;
}

.room-link {
  height: 28px;
  padding: 0 9px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
}

.room-link:hover,
.room-link.active {
  background: var(--blue);
  color: #fff;
}

.room-focus {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 4px solid #94a3b8;
  background: #f8fafc;
  color: #475569;
  font-size: 13px;
  line-height: 1.7;
}

.room-focus.ok {
  border-left-color: var(--green);
  background: #f0fdf4;
}

.room-focus.error {
  border-left-color: var(--red);
  background: #fef2f2;
}

.panel {
  min-width: 0;
  padding: 14px;
  overflow: hidden;
}

pre {
  margin: 10px 0 0;
  padding: 12px;
  height: 132px;
  overflow: auto;
  background: #f8fafc;
  border: 1px solid #edf2f7;
  font-family: Consolas, "Microsoft YaHei UI", monospace;
  font-size: 13px;
  white-space: pre-wrap;
}

.workbench {
  flex: 0 0 auto;
  height: min(72vh, 760px);
  max-height: 760px;
  min-height: 360px;
  display: grid;
  grid-template-rows: minmax(220px, 420px) 8px minmax(160px, 1fr);
}

.workbench.maximized {
  height: min(78vh, 620px);
  max-height: 620px;
  grid-template-rows: minmax(360px, 1fr) 0 0;
}

.workbench.maximized .splitter,
.workbench.maximized .mapping-panel {
  display: none;
}

.splitter {
  cursor: row-resize;
  background: linear-gradient(90deg, transparent, #cbd5e1 18%, #cbd5e1 82%, transparent);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex: 0 0 auto;
}

.preview-panel,
.mapping-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.preview-panel {
  max-height: 520px;
}

.preview-tools {
  display: flex;
  align-items: end;
  gap: 8px;
}

.preview-tabs {
  display: flex;
  align-items: center;
  height: 34px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
}

.preview-tabs button {
  height: 32px;
  min-width: 72px;
  background: transparent;
  color: #475569;
  border-right: 1px solid #cbd5e1;
  padding: 0 12px;
}

.preview-tabs button:last-child {
  border-right: 0;
}

.preview-tabs button.active {
  background: var(--blue);
  color: #fff;
}

.preview-tabs button:disabled {
  background: transparent;
  color: #94a3b8;
  cursor: not-allowed;
}

#previewFilter {
  width: 230px;
}

#roomFilter {
  width: 150px;
}

.table-wrap {
  width: 100%;
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  border: 1px solid #e2e8f0;
  background: #fff;
  scrollbar-gutter: stable;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border: 1px solid #e2e8f0;
  padding: 7px 9px;
  white-space: nowrap;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f1f5f9;
  color: #334155;
  font-weight: 800;
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

.mapping-panel .table-wrap {
  height: auto;
}

#mappingTable select,
#mappingTable input {
  width: 100%;
  height: 30px;
}

.warn {
  color: var(--amber);
}

.error-text {
  color: var(--red);
}

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

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

  .preview-tools {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

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