:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f0f4f5;
  --text: #20242a;
  --muted: #68717d;
  --line: #dfe5e8;
  --line-strong: #cbd5d9;
  --teal: #0f766e;
  --teal-soft: #d9f0ec;
  --blue: #2563eb;
  --amber: #b45309;
  --rose: #be123c;
  --shadow: 0 16px 36px rgba(20, 29, 39, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), rgba(255, 255, 255, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
}

.topbar,
main {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 0 18px;
}

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

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 10px);
  grid-template-rows: repeat(3, 10px);
  gap: 4px;
  width: 52px;
  height: 52px;
  padding: 9px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark span {
  border-radius: 3px;
  background: var(--teal);
}

.brand-mark span:nth-child(2) {
  grid-column: 2 / 4;
  background: var(--blue);
}

.brand-mark span:nth-child(3) {
  grid-column: 1 / 4;
  background: var(--amber);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 750;
}

h2 {
  font-size: 18px;
  line-height: 1.35;
}

.brand p,
.section-heading p,
.result-heading p {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.5;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
}

.icon-button:hover,
.text-button:hover {
  border-color: var(--teal);
  background: #fbfefe;
}

.icon-button:active,
.text-button:active {
  transform: translateY(1px);
}

svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

main {
  display: grid;
  gap: 16px;
  padding-bottom: 40px;
}

.filter-band,
.stats-band,
.chart-band,
.result-band {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
}

.filter-band {
  display: grid;
  grid-template-columns: minmax(280px, 1.25fr) minmax(520px, 2fr);
  gap: 18px;
  align-items: end;
  padding: 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

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

.search-box {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.search-box:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 36px 0 12px;
}

select:focus,
input:focus {
  outline: none;
}

select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.stats-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: var(--radius);
}

.stat-block {
  min-height: 88px;
  padding: 18px;
  background: var(--surface);
}

.stat-block span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-block strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.chart-band,
.result-band {
  border-radius: var(--radius);
  overflow: hidden;
}

.section-heading,
.result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.date-chart {
  display: grid;
  grid-template-columns: repeat(10, minmax(72px, 1fr));
  gap: 10px;
  min-height: 174px;
  padding: 18px;
  overflow-x: auto;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.06), rgba(255, 255, 255, 0) 120px),
    var(--surface);
}

.date-bar {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 8px;
  min-width: 72px;
  height: 138px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
}

.bar-track {
  display: flex;
  align-items: end;
  justify-content: center;
  min-height: 86px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  min-height: 4px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(180deg, var(--teal), #3b82f6);
}

.bar-count {
  font-weight: 700;
  line-height: 1;
}

.bar-date {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.text-button {
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  white-space: nowrap;
}

.table-shell {
  position: relative;
  overflow-x: auto;
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6faf9;
  color: #3e4a54;
  font-size: 13px;
  font-weight: 700;
}

td {
  line-height: 1.45;
}

tbody tr:hover {
  background: #fbf7ef;
}

.date-cell {
  white-space: nowrap;
  font-weight: 700;
}

.time-cell {
  white-space: nowrap;
  color: var(--teal);
  font-weight: 700;
}

.course-cell strong {
  display: block;
  max-width: 300px;
  overflow-wrap: anywhere;
}

.course-cell span,
.teacher-cell,
.code-cell {
  color: var(--muted);
  font-size: 13px;
}

.room-cell strong {
  display: block;
  white-space: nowrap;
}

.room-cell span {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 220px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--text);
  font-size: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100% - 36px));
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #172026;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.is-loading tbody {
  opacity: 0.56;
}

@media (max-width: 1040px) {
  .filter-band {
    grid-template-columns: 1fr;
  }

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

  .filter-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  main {
    width: min(1280px, calc(100% - 20px));
  }

  .topbar {
    align-items: center;
    gap: 10px;
    padding: 14px 0 12px;
    position: relative;
  }

  h1 {
    font-size: 24px;
  }

  .brand {
    gap: 10px;
    flex: 1 1 auto;
  }

  .brand > div {
    min-width: 0;
  }

  .brand p,
  .section-heading p,
  .result-heading p {
    font-size: 13px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    padding: 8px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .top-actions {
    flex: 0 0 auto;
  }

  main {
    gap: 12px;
    padding-bottom: 24px;
  }

  .filter-band {
    gap: 12px;
    padding: 12px;
  }

  .result-band {
    order: 3;
  }

  .chart-band {
    order: 4;
  }

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

  .search-box,
  select {
    min-height: 46px;
  }

  .search-box input,
  select {
    font-size: 16px;
  }

  .stat-block {
    min-height: 76px;
    padding: 14px;
  }

  .stat-block strong {
    margin-top: 6px;
    font-size: 24px;
  }

  .section-heading,
  .result-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
  }

  .date-chart {
    grid-template-columns: repeat(10, 58px);
    gap: 8px;
    min-height: 128px;
    padding: 12px;
  }

  .date-bar {
    min-width: 58px;
    height: 104px;
    gap: 6px;
  }

  .bar-track {
    min-height: 58px;
  }

  .table-shell {
    overflow-x: visible;
    background: #f7f8fa;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
    border-collapse: separate;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 8px 22px rgba(20, 29, 39, 0.06);
  }

  tbody tr:hover {
    background: var(--surface);
  }

  td {
    min-width: 0;
    padding: 0;
    border-bottom: 0;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.2;
  }

  .date-cell,
  .time-cell {
    white-space: normal;
  }

  .course-cell,
  .teacher-cell,
  .code-cell {
    grid-column: 1 / -1;
  }

  .course-cell {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }

  .course-cell strong {
    max-width: none;
    font-size: 16px;
    line-height: 1.45;
  }

  .room-cell strong {
    white-space: normal;
  }

  .teacher-cell,
  .code-cell {
    font-size: 14px;
    line-height: 1.5;
  }

  .text-button {
    width: 100%;
    min-height: 42px;
  }

  .empty-state {
    min-height: 180px;
    padding: 24px 14px;
  }
}

@media (max-width: 520px) {
  .topbar {
    display: block;
  }

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

  .top-actions {
    flex-direction: row;
    gap: 6px;
    margin-top: 10px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .filter-grid,
  .search-fields {
    grid-template-columns: 1fr;
  }

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

  .brand-mark {
    display: none;
  }

  h1 {
    font-size: 22px;
  }

  .brand p {
    max-width: 240px;
  }

  .section-heading,
  .result-heading {
    padding: 12px;
  }

  tbody {
    padding: 10px;
  }

  tbody tr {
    grid-template-columns: 1fr;
  }

  .course-cell,
  .teacher-cell,
  .code-cell {
    grid-column: auto;
  }

  .date-chart {
    grid-template-columns: repeat(10, 54px);
  }
}
