:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #627084;
  --line: #d8dee8;
  --panel: #f7f8fb;
  --accent: #146c5f;
  --accent-dark: #0d4d43;
  --danger: #a62639;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef1f5;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.search-panel,
.results-panel,
.same-class-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(23, 32, 42, 0.08);
}

.search-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
}

.results-panel {
  min-width: 0;
  overflow: hidden;
}

.same-class-panel {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
}

.same-class-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

.table-wrap.compact {
  max-height: 420px;
}

.same-class-table {
  min-width: 1060px;
}

.same-class-table th:nth-child(1),
.same-class-table td:nth-child(1),
.same-class-table th:nth-child(2),
.same-class-table td:nth-child(2) {
  position: static;
  min-width: 0;
  max-width: none;
  box-shadow: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
}

form {
  display: grid;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  font: 1rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 95, 0.14);
}

.actions {
  display: flex;
  gap: 10px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: progress;
  opacity: 0.68;
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
}

button.secondary:hover {
  background: var(--panel);
}

button.copy-sms {
  min-height: 34px;
  border: 1px solid var(--line);
  background: #273343;
  padding: 0 12px;
  white-space: nowrap;
}

button.copy-sms:hover {
  background: #17202a;
}

.status {
  margin: auto 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status.error {
  color: var(--danger);
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  height: 100%;
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f6f9;
  color: #3d4a5c;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

th:nth-child(1),
td:nth-child(1),
th:nth-child(2),
td:nth-child(2) {
  position: sticky;
  z-index: 2;
  background: var(--white);
  box-shadow: 1px 0 0 var(--line), 10px 0 16px rgba(23, 32, 42, 0.06);
}

th:nth-child(1),
td:nth-child(1) {
  left: 0;
  min-width: 210px;
  max-width: 240px;
}

th:nth-child(2),
td:nth-child(2) {
  left: 210px;
  min-width: 220px;
  max-width: 260px;
}

th:nth-child(1),
th:nth-child(2) {
  z-index: 3;
  background: #f3f6f9;
}

td {
  color: #273343;
  font-size: 0.92rem;
}

.muted {
  color: var(--muted);
}

.no-match-row td:nth-child(2) {
  color: var(--danger);
  font-weight: 800;
}

.other-matches-row td {
  background: #fbfcfe;
}

.other-matches-row td:nth-child(2) {
  position: static;
  min-width: 0;
  max-width: none;
  box-shadow: none;
}

details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

.nested-table-wrap {
  width: 100%;
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.nested-table {
  min-width: 980px;
}

.nested-table th,
.nested-table td {
  padding: 10px 12px;
}

.nested-table th {
  position: static;
  background: #f7f8fb;
}

.nested-table th:nth-child(2),
.nested-table td:nth-child(2) {
  position: static;
  min-width: 0;
  max-width: none;
  box-shadow: none;
}

.course-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 560px;
}

.course-tag {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--tag-border);
  border-radius: 8px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-size: 0.82rem;
  line-height: 1.25;
}

.course-title,
.class-code {
  padding: 6px 8px;
}

.course-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.class-code {
  flex: 0 0 auto;
  border-left: 1px solid var(--tag-border);
  background: var(--tag-code-bg);
  font-weight: 800;
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .same-class-panel {
    grid-column: auto;
  }

  textarea {
    min-height: 240px;
  }

}
