:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #617085;
  --line: #d9e1ea;
  --soft: #f4f7fa;
  --paper: #ffffff;
  --blue: #2454c6;
  --blue-dark: #173d92;
  --green: #1f8a62;
  --amber: #c26a1b;
  --red: #bf3347;
  --shadow: 0 18px 45px rgba(26, 37, 52, 0.12);
}

* {
  box-sizing: border-box;
}

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

body.is-logged-out .app-shell,
body.is-logged-out .sidebar {
  display: none;
}

body.is-logged-out .site-header {
  position: relative;
  z-index: 30;
}

body.is-logged-out .site-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
}

body.public-station .site-header,
body.public-station .sidebar,
body.public-station .topbar,
body.public-station .site-footer {
  display: none;
}

body.public-station .app-shell {
  display: block;
  min-height: 100vh;
}

body.public-station .workspace {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px;
}

body.public-station {
  background: #f4f7fa;
}

body.public-station .panel {
  box-shadow: none;
}

body.public-station #stationView .panel-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

body.public-station #stationTitle {
  font-size: 28px;
}

body.public-station .primary {
  width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 78px;
  padding: 14px 28px;
  background: #731305;
  border-bottom: 0;
}

.site-header img {
  width: 64px;
  max-height: 48px;
  object-fit: contain;
}

.site-header strong {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border-radius: 8px;
  background: #ffffff;
  color: #731305;
  padding: 8px 14px;
  font-size: 23px;
  letter-spacing: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 138px);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 60px;
  padding: 16px 28px;
  background: #25282b;
  border-top: 0;
  color: #7a7f83;
  font-size: 14px;
}

.site-footer nav {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.site-footer a {
  color: #7a7f83;
  font-weight: 800;
  text-decoration: none;
}

.sidebar {
  background: rgb(37, 40, 43);
  color: #f7fbff;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
}

.brand-logo {
  width: 56px;
  max-height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 5px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #f5b942;
  color: #102034;
  font-weight: 800;
}

.brand p,
.brand strong {
  margin: 0;
  display: block;
}

.brand p {
  color: #aebbd0;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
  padding-top: 0;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c8d3e3;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  background: #3a3f44;
  color: #fff;
}

.side-panel {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.side-panel label,
.mini-label {
  color: #aebbd0;
  font-size: 13px;
  font-weight: 700;
}

.side-panel select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #33383d;
  color: #fff;
  padding: 11px 12px;
}

.side-panel.compact {
  margin-top: auto;
}

.user-chip {
  display: grid;
  gap: 2px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  background: #33383d;
}

.user-chip span {
  color: #aebbd0;
  font-size: 13px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #d8e3f1;
  font-size: 14px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #61d394;
}

.workspace {
  min-width: 0;
  padding: 28px;
  background: #ffffff;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 19px;
}

.top-actions,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.form-error {
  display: none;
  margin: -6px 0 0;
  padding: 10px 12px;
  border: 1px solid #f3cbd2;
  border-radius: 8px;
  background: #fff0f2;
  color: var(--red);
  font-weight: 800;
}

.form-error.visible {
  display: block;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(24, 33, 47, 0.06);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-button input {
  display: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(24, 33, 47, 0.06);
}

.metric-card {
  padding: 18px;
}

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

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 330px);
}

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

.panel {
  padding: 18px;
  min-width: 0;
}

.panel.wide {
  grid-column: span 1;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-tools {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-control {
  min-width: 190px;
}

.panel-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.stacked-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 84, 198, 0.12);
}

.primary,
.secondary,
.danger,
.table-action {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 800;
}

.primary {
  background: var(--blue);
  color: #fff;
}

.primary:hover {
  background: var(--blue-dark);
}

.secondary {
  background: #eef3f8;
  color: #26374d;
  border-color: var(--line);
}

.secondary:hover {
  background: #e0e8f1;
}

.danger,
.table-action.danger {
  background: #fff0f2;
  color: var(--red);
  border-color: #f3cbd2;
}

.full {
  width: 100%;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

.rank {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #edf4ff;
  color: var(--blue);
  font-weight: 900;
}

.score-fields {
  display: grid;
  gap: 10px;
}

.score-exercise-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 100px 112px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.score-exercise-row strong {
  display: block;
}

.score-exercise-row span,
.no-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.no-time {
  display: grid;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
}

.lock-message {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #b7dfc8;
  border-radius: 8px;
  background: #eefaf3;
  color: var(--green);
  font-weight: 800;
}

.lock-message.locked {
  border-color: #f3cbd2;
  background: #fff0f2;
  color: var(--red);
}

.score-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px;
  gap: 10px;
  align-items: end;
}

.score-row span {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) 110px 120px auto;
  gap: 10px;
  margin-bottom: 14px;
}

.exercise-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 140px 130px minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.radio-group {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.radio-group legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: auto;
  padding: 0;
}

.radio-group input {
  width: auto;
}

.station-number-list {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.station-number-list label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  align-items: center;
}

.status-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.status-actions span {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  padding: 8px 12px;
  font-weight: 800;
}

.exercise-description {
  grid-column: 1 / -1;
}

.exercise-form .form-actions {
  align-self: end;
}

.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.download-grid button {
  justify-content: center;
  min-height: 54px;
}

.criteria-list {
  display: grid;
  gap: 10px;
}

.station-links {
  margin-top: 22px;
}

.station-links-header {
  margin-top: 4px;
}

.station-link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.station-link-card {
  display: grid;
  gap: 9px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.station-link-card img {
  width: 140px;
  height: 140px;
  border: 1px solid var(--line);
}

.station-link-card a {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.criterion {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.criterion strong {
  display: block;
}

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

.criterion p {
  margin: 6px 0 0;
  color: #425166;
  font-size: 13px;
}

.table-action {
  min-height: 34px;
  padding: 7px 10px;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.empty-state {
  color: var(--muted);
  padding: 20px 10px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: #102034;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-weight: 700;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.login-screen {
  position: fixed;
  top: 78px;
  right: 0;
  bottom: 60px;
  left: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #ffffff;
}

.login-screen.hidden {
  display: none;
}

.login-card {
  display: grid;
  gap: 18px;
  width: min(440px, 100%);
  border-radius: 8px;
  background: #fff;
  padding: 26px;
  box-shadow: var(--shadow);
}

.hidden-panel {
  display: none;
}

.demo-logins {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.forgot-link {
  color: #731305;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

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

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

  .site-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  body.is-logged-out .site-header {
    align-items: center;
    flex-direction: row;
  }

  .sidebar {
    position: static;
    padding: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(3, 1fr);
  }

  .side-panel.compact {
    margin-top: 0;
  }

  .workspace {
    padding: 18px;
  }

  .metrics-grid,
  .content-grid,
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  body.public-station .workspace {
    padding: 10px;
  }

  body.public-station .panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    padding: 16px;
  }

  body.public-station #stationTitle {
    font-size: 24px;
    line-height: 1.15;
  }

  body.public-station input,
  body.public-station select,
  body.public-station button {
    min-height: 48px;
    font-size: 16px;
  }

  .metrics-grid,
  .content-grid,
  .dashboard-grid,
  .inline-form,
  .exercise-form {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-header,
  .panel-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 28px;
  }

  .hero-overlay strong {
    font-size: 22px;
  }

  .score-row,
  .score-exercise-row,
  .criterion,
  .station-number-list label {
    grid-template-columns: 1fr;
  }
}

@media print {
  .sidebar,
  .topbar,
  .metrics-grid,
  .panel:not(.wide),
  .toast {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .content-grid {
    display: block;
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 0;
  }
}
