:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e8eef5;
  --muted: #8b9cb3;
  --accent: #3d9eff;
  --accent-dim: #2563a8;
  --success: #34d399;
  --warning: #fbbf24;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.app-header {
  padding: 1rem 1.25rem;
  background: linear-gradient(165deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--surface2);
  position: sticky;
  top: 0;
  z-index: 40;
}

.app-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.app-header p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.app-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.app-header-titles {
  flex: 1 1 240px;
  min-width: 0;
}

.main-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: var(--bg);
  border-bottom: 1px solid var(--surface2);
  position: sticky;
  top: 0;
  z-index: 30;
}

.main-tabs::-webkit-scrollbar {
  display: none;
}

.main-tabs button {
  flex: 0 0 auto;
  padding: 0.55rem 1rem;
  border: 1px solid var(--surface2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
}

.main-tabs button[aria-selected="true"] {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}

.api2026-config {
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  background: var(--surface);
  max-width: 40rem;
}

.api2026-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.api2026-field input {
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  width: 100%;
}

.api2026-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.api2026-load-btn {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--accent-dim);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}

.api2026-load-btn:hover {
  border-color: var(--accent);
}

.api2026-status {
  font-size: 0.8rem;
  color: var(--accent);
  word-break: break-word;
}

.api2026-hint {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
}

.api2026-hint .api2026-test-url {
  display: block;
  margin-top: 0.35rem;
  word-break: break-all;
  font-size: 0.68rem;
  color: var(--muted);
}

.api2026-student-table-wrap {
  margin-top: 0.25rem;
}

.api2026-student-list-scroll {
  max-height: min(70vh, 28rem);
  overflow: auto;
  padding-right: 0.25rem;
}

.api2026-student-table {
  font-size: 0.82rem;
}

.api2026-student-table tbody tr.api2026-student-row {
  cursor: pointer;
}

.api2026-student-table tbody tr.api2026-student-row:hover {
  background: rgba(61, 158, 255, 0.12);
}

.api2026-student-table tbody tr.api2026-student-row:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.panel {
  display: none;
  padding: 1rem 1.25rem 4rem;
  max-width: 960px;
  margin: 0 auto;
}

.panel.active {
  display: block;
}

.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sub-tabs button {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  max-width: 100%;
  text-align: left;
}

.sub-tabs button.active {
  border-color: var(--accent);
  background: var(--surface2);
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  word-break: break-word;
}

.breadcrumb span {
  color: var(--accent);
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--surface2);
}

th {
  background: var(--surface2);
  color: var(--muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:active {
  background: var(--surface2);
}

button.link-name {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0;
  text-align: left;
}

.class-section {
  margin-bottom: 1.5rem;
}

.class-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--success);
  font-weight: 600;
}

.pct-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.75rem;
  background: var(--surface2);
  color: var(--warning);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fade 0.2s ease;
}

@media (min-width: 600px) {
  .modal-backdrop {
    align-items: center;
    padding: 1rem;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 85dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--surface2);
  padding: 1.25rem;
  animation: slide 0.25s ease;
}

@media (min-width: 600px) {
  .modal {
    border-radius: var(--radius);
  }
}

@keyframes slide {
  from {
    transform: translateY(12px);
    opacity: 0.9;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.modal .detail-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.85rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--surface2);
}

.modal .detail-row dt {
  color: var(--muted);
  margin: 0;
}

.modal .detail-row dd {
  margin: 0;
}

.modal-close {
  float: right;
  margin: -0.25rem -0.25rem 0.5rem 0.5rem;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

/* Embedded in another app (iframe): no header/tabs; student detail is view-only; close returns to idle inside iframe */
html.siminar-embed .app-header,
html.siminar-embed .main-tabs,
html.siminar-embed #year-banner,
html.siminar-embed #app-main {
  display: none !important;
}

.embed-idle-panel {
  display: none;
}

html.siminar-embed .embed-idle-panel:not([hidden]) {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

html.siminar-embed .modal-backdrop.modal-embed {
  background: var(--bg);
  align-items: stretch;
  padding: 0;
}

html.siminar-embed .modal-backdrop.modal-embed .modal {
  max-width: none;
  width: 100%;
  max-height: none;
  min-height: 100dvh;
  border-radius: 0;
  border: none;
  animation: none;
}

@media (min-width: 600px) {
  html.siminar-embed .modal-backdrop.modal-embed {
    align-items: stretch;
    padding: 0;
  }
  html.siminar-embed .modal-backdrop.modal-embed .modal {
    border-radius: 0;
  }
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  background: var(--surface);
}

.card h4 {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
}

.card .meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.muted-num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.reg-children {
  margin-top: 0.5rem;
  font-size: 0.82rem;
}

.reg-children ul {
  margin: 0.25rem 0 0 1rem;
  padding: 0;
}

.reg-note {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-style: italic;
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.loading {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
}

.error-banner {
  margin: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: #4a2020;
  border: 1px solid #7f2d2d;
  color: #fecaca;
  font-size: 0.875rem;
}

.api-note {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--surface2);
}

.year-banner {
  margin: 0 1rem 0.5rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #c4d4e8;
  background: #1e2a3d;
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

.year-banner strong {
  color: var(--text);
  font-weight: 600;
}

.students-tab-note {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.85rem;
  line-height: 1.45;
}

.student-trace-h3 {
  font-size: 0.88rem;
  font-weight: 600;
  margin: 0.85rem 0 0.45rem;
  color: var(--text);
}

#panel-students .parent-sem-count strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.students-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.students-toolbar label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.students-toolbar select {
  flex: 1 1 200px;
  min-width: 0;
  max-width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  cursor: pointer;
}

.students-toolbar select:focus {
  outline: none;
  border-color: var(--accent);
}

.mono {
  font-family: ui-monospace, "Cascadia Mono", "Segoe UI Mono", monospace;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.class-mismatch {
  margin-top: 0.35rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.08);
  border-radius: 6px;
  border-left: 3px solid var(--warning);
}

#panel-relation.panel {
  max-width: 1100px;
}

.relation-band-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

details.relation-grade {
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

details.relation-grade[open] {
  border-color: var(--accent-dim);
}

.relation-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  font-size: 0.95rem;
}

.relation-summary::-webkit-details-marker {
  display: none;
}

.relation-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5rem;
  color: var(--muted);
  transition: transform 0.15s ease;
}

details.relation-grade[open] > .relation-summary::before {
  transform: rotate(90deg);
}

.relation-band-label {
  min-width: 2.5rem;
}

.relation-band-meta {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.relation-inner-table {
  border-top: 1px solid var(--surface2);
  margin: 0;
}

.relation-inner-table th,
.relation-inner-table td {
  font-size: 0.82rem;
  vertical-align: top;
}

.relation-sibling-cell,
.relation-parent-cell {
  max-width: 14rem;
  word-break: break-word;
}

.relation-parent-sep {
  color: var(--muted);
  font-weight: 400;
}

details.relation-grade--other {
  border-style: dashed;
}

.parents-table-wrap td.num-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 1%;
}

.parent-seminar-cell {
  min-width: 14rem;
  max-width: 28rem;
  vertical-align: top;
}

.parent-seminar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.parent-seminar-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
  align-items: baseline;
  font-size: 0.78rem;
  line-height: 1.35;
  margin-bottom: 0.4rem;
}

.parent-seminar-line:last-child {
  margin-bottom: 0;
}

.parent-seminar-title {
  flex: 1 1 10rem;
  min-width: 0;
}

.parent-seminar-meta {
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 0.72rem;
  white-space: nowrap;
}

.reg-badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.reg-badge--ok {
  background: rgba(52, 211, 153, 0.15);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.reg-badge--late {
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.reg-badge--muted {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--surface2);
}

.parent-detail-children {
  margin: 0.25rem 0 0 1.1rem;
  padding: 0;
  font-size: 0.88rem;
}
