:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --surface-raised: #ffffff;
  --input: #ffffff;
  --table-head: #f6f7fa;
  --row-line: #e9ebf0;
  --track: #e7eaf0;
  --avatar-bg: #edf0f5;
  --line: #dde1e9;
  --line-strong: #c9cfda;
  --text: #171b23;
  --muted: #707889;
  --muted-strong: #555e70;
  --violet: #6b5ce7;
  --violet-hover: #5748cf;
  --violet-soft: #eeecff;
  --teal: #168d7d;
  --teal-soft: #e3f5f1;
  --link: #5646d5;
  --green: #087c69;
  --amber: #b16208;
  --red: #b4232d;
  --focus: rgba(107, 92, 231, .2);
  --shadow: 0 18px 48px rgba(28, 35, 50, .07);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080a0f;
  --surface: #0d1016;
  --surface-soft: #11151d;
  --surface-raised: #141923;
  --input: #0d1016;
  --table-head: #121720;
  --row-line: #202633;
  --track: #252c3a;
  --avatar-bg: #171d27;
  --line: #242a37;
  --line-strong: #343a49;
  --text: #f5f7fb;
  --muted: #9199aa;
  --muted-strong: #b0b7c5;
  --violet: #7c6cff;
  --violet-hover: #9184ff;
  --violet-soft: #201d3c;
  --teal: #2ab29e;
  --teal-soft: #102c2a;
  --link: #a99fff;
  --green: #43c7aa;
  --amber: #f0ad5f;
  --red: #ff7c86;
  --focus: rgba(124, 108, 255, .28);
  --shadow: 0 22px 60px rgba(0, 0, 0, .28);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI Variable", "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: relative;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-bottom: 1px solid var(--line);
}

.topbar::before {
  position: absolute;
  inset: 0 auto auto 0;
  width: 29%;
  height: 2px;
  background: var(--violet);
  content: "";
}

.topbar::after {
  position: absolute;
  inset: 0 0 auto auto;
  width: 11%;
  height: 2px;
  background: var(--teal);
  content: "";
}

.topbarInner {
  width: min(1540px, 100%);
  min-height: 164px;
  margin: 0 auto;
  padding: 12px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(356px, 420px);
  align-items: center;
  gap: 24px;
}

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

.crewGroups {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.crewShortcuts {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.crewLabel {
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.crewStationList {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  padding: 5px 3px;
  overflow-x: auto;
  scrollbar-width: none;
}

.crewStationList::-webkit-scrollbar {
  display: none;
}

.crewStationButton {
  position: relative;
  display: inline-flex;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  padding: 2px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--avatar-bg);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.crewStationButton::after {
  position: absolute;
  inset: 2px;
  border: 1px solid color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.crewStationButton img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.crewStationButton:hover {
  z-index: 1;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--focus);
  transform: translateY(-2px);
}

.crewStationButton:focus-visible,
.themeToggle:focus-visible,
.searchForm button:focus-visible,
.resultTools button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.crewStationButton:disabled {
  cursor: default;
  opacity: .48;
  transform: none;
}

.searchForm {
  display: grid;
  min-width: 0;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) 82px;
  gap: 8px;
}

.searchForm input,
#filterInput {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--input);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.searchForm input {
  height: 44px;
  padding: 0 14px;
}

.searchForm input::placeholder,
#filterInput::placeholder {
  color: var(--muted);
}

.searchForm input:focus,
#filterInput:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--focus);
}

.searchForm button,
.resultTools button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.searchForm button {
  height: 44px;
  border-color: var(--violet);
  background: var(--violet);
  color: #fff;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--violet) 24%, transparent);
}

.searchForm button:hover {
  border-color: var(--violet-hover);
  background: var(--violet-hover);
}

.searchForm button:disabled,
.resultTools button:disabled {
  cursor: default;
  opacity: .48;
  box-shadow: none;
}

.themeToggle {
  display: inline-flex;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.themeToggle:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

#themeIcon {
  font: 21px/1 "Segoe UI Symbol", sans-serif;
}

.appShell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 30px 24px 64px;
}

.statusBand,
.resultTools,
.tableBand {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.statusBand {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 520px);
  align-items: center;
  gap: 28px;
  padding: 20px 22px;
}

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

.stationBox img {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--avatar-bg);
  object-fit: cover;
}

.stationIdentity {
  min-width: 0;
}

.stationIdentity strong,
.stationIdentity span {
  display: block;
}

.sectionIndex {
  margin-bottom: 4px;
  color: var(--violet);
  font: 700 10px/1.2 ui-monospace, "Cascadia Mono", monospace;
  letter-spacing: 0;
}

.stationIdentity strong {
  overflow: hidden;
  font-size: 18px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stationIdentity #stationMeta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.progressBox {
  display: grid;
  gap: 9px;
}

.progressHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.progressHead strong {
  color: var(--text);
  font: 700 12px/1 ui-monospace, "Cascadia Mono", monospace;
}

.progressTrack {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--track);
}

#progressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width .18s ease;
}

.resultTools {
  display: grid;
  gap: 16px;
  margin-top: 16px;
  padding: 20px 22px;
}

.resultToolsHeader {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.resultHeading strong {
  display: block;
  font-size: 20px;
  line-height: 1.25;
}

.resultTools button {
  min-height: 40px;
  padding: 0 15px;
}

.resultTools button:not(:disabled):hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-soft);
}

.chips {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-width: 0;
  min-height: 68px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric strong {
  overflow: hidden;
  margin-top: 6px;
  font: 800 15px/1.2 ui-monospace, "Cascadia Mono", monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric:nth-child(3) strong {
  color: var(--teal);
}

.metric:nth-child(5) strong {
  color: var(--amber);
}

.filterWrap {
  display: block;
}

#filterInput {
  height: 44px;
  padding: 0 14px;
}

.tableBand {
  margin-top: 16px;
  overflow: hidden;
}

.tableScroll {
  overflow: auto;
}

.resultTable {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  table-layout: fixed;
}

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

.resultTable th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head);
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.resultTable th:hover {
  color: var(--violet);
}

.resultTable th:nth-child(1),
.resultTable th:nth-child(6) {
  width: 112px;
}

.resultTable th:nth-child(2),
.resultTable th:nth-child(5) {
  width: 164px;
}

.resultTable th:nth-child(4) {
  width: 96px;
}

.resultTable td {
  color: var(--muted-strong);
  font-size: 13px;
}

.resultTable tbody tr {
  transition: background .12s ease;
}

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

.resultTable tbody tr:last-child td {
  border-bottom: 0;
}

.resultTable td:nth-child(3) {
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
}

.resultTable a {
  color: var(--link);
  font-weight: 800;
  text-decoration: none;
}

.resultTable a:hover {
  text-decoration: underline;
}

.emptyCell {
  height: 230px;
  padding: 48px 16px;
  color: var(--muted);
}

.emptyMessage {
  position: sticky;
  left: 16px;
  display: block;
  width: min(calc(100vw - 80px), 1380px);
  text-align: center;
}

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

.permanent {
  color: var(--green);
  font-weight: 800;
}

.soon {
  color: var(--amber);
  font-weight: 800;
}

.error {
  color: var(--red);
  font-weight: 800;
}

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1420px) {
  .topbarInner {
    min-height: 0;
    grid-template-columns: 1fr minmax(340px, 460px);
    align-items: center;
    padding-block: 18px;
  }

  .crewGroups {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .topbarActions {
    grid-column: 2;
    grid-row: 1;
  }

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

@media (max-width: 720px) {
  .topbarInner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
    padding: 18px 16px;
  }

  .topbarActions {
    order: 1;
  }

  .crewGroups {
    order: 2;
  }

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

  .crewStationButton {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .appShell {
    padding: 20px 14px 40px;
  }

  .statusBand {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 18px;
  }

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

  .resultTools {
    padding: 18px;
  }
}

@media (max-width: 440px) {
  .searchForm {
    grid-template-columns: minmax(0, 1fr) 68px;
  }

  .themeToggle {
    width: 42px;
    height: 44px;
    flex-basis: 42px;
  }

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

  .resultToolsHeader {
    align-items: center;
  }

  .resultHeading strong {
    font-size: 18px;
  }
}
