:root {
  color-scheme: light;
  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-strong: #eef4f8;
  --line: #d9e1e8;
  --line-strong: #c3d0da;
  --text: #17212b;
  --muted: #647284;
  --subtle: #8794a3;
  --accent: #0b7c75;
  --accent-strong: #075f58;
  --accent-soft: #e4f4f1;
  --accent-line: #b8ded8;
  --ink: #223142;
  --gold: #ad7b18;
  --red: #b94c43;
  --shadow: 0 14px 38px rgba(31, 47, 62, 0.08);
  --shadow-soft: 0 8px 22px rgba(31, 47, 62, 0.06);
  --radius: 8px;
  --sidebar-width: 278px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(11, 124, 117, 0.08), transparent 30rem),
    linear-gradient(180deg, #fbfcfd 0, var(--bg) 24rem),
    var(--bg);
  color: var(--text);
  font: 14px/1.48 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-gate.is-hidden {
  display: none;
}

.login-panel {
  width: min(920px, 100%);
  display: grid;
  gap: 20px;
}

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

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.18;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 24px 18px;
  background: rgba(255, 255, 255, 0.86);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
  z-index: 10;
}

.brand-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-card p,
.status,
.panel-head span,
.candidate-card span,
.rank-meta,
.criterion-note,
.detail-meta {
  color: var(--muted);
}

.brand-card p {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.35;
}

.role-nav {
  display: grid;
  gap: 8px;
}

.nav-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 700;
  text-align: left;
}

.nav-tab:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.nav-tab.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.nav-tab.active::before {
  content: "";
  position: absolute;
  left: -18px;
  width: 4px;
  height: 24px;
  border-radius: 0 999px 999px 0;
  background: var(--accent);
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 82px;
  padding: 18px 28px;
  background: rgba(250, 252, 253, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.event-switcher {
  display: grid;
  gap: 6px;
  min-width: 280px;
}

.eyebrow {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.actions > * {
  width: auto;
}

.actions button,
.actions .button {
  min-width: 116px;
}

#languageButton {
  min-width: 92px;
}

.layout {
  display: block;
  padding: 28px;
}

.workspace-section {
  max-width: 1440px;
  margin: 0 auto;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.panel-head span {
  font-size: 12px;
}

input,
select,
textarea,
button,
.button {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input,
select,
textarea {
  box-shadow: inset 0 1px 0 rgba(23, 33, 43, 0.02);
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(11, 124, 117, 0.14);
  border-color: var(--accent);
}

button,
.button {
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  text-align: center;
  text-decoration: none;
  font-weight: 750;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.actions > * {
  flex: 0 0 auto;
  width: auto;
}

.actions button,
.actions .button {
  min-width: 116px;
}

.role-nav .nav-tab {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.role-nav .nav-tab:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.role-nav .nav-tab.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.role-nav .nav-tab:not(.active):not(:hover) {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 8px 18px rgba(11, 124, 117, 0.16);
}

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

button:disabled {
  cursor: not-allowed;
  background: #aeb9c2;
  border-color: #aeb9c2;
  box-shadow: none;
}

.secondary-button,
#logoutButton {
  background: #fff;
  color: var(--ink);
  border-color: var(--line-strong);
}

.secondary-button:hover,
#logoutButton:hover {
  background: var(--surface-strong);
  color: var(--ink);
  border-color: var(--line-strong);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.token-field {
  grid-template-columns: auto minmax(220px, 360px);
  align-items: center;
  gap: 12px;
}

.token-field span {
  color: var(--muted);
  font-size: 12px;
}

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

.candidate-rail {
  position: sticky;
  top: 110px;
  max-height: calc(100vh - 136px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.candidate-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.candidate-card {
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease, box-shadow 120ms ease;
}

.candidate-card:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 8px 18px rgba(31, 47, 62, 0.07);
}

.candidate-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.candidate-card strong {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
}

.candidate-card span,
.rank-meta,
.criterion-note,
.detail-meta {
  font-size: 12px;
}

.score-form,
.judge-entry-form,
.event-form,
.admin-grid form,
.password-form,
.login-form,
.restore-form {
  display: grid;
  gap: 12px;
}

.judge-entry-form {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  align-items: end;
  margin-bottom: 18px;
}

.judge-entry-form .form-title,
.judge-entry-form .status {
  grid-column: 1 / -1;
}

.form-title {
  display: grid;
  gap: 4px;
  padding-bottom: 2px;
}

.judge-progress {
  margin-bottom: 14px;
}

.progress-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.progress-card div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.progress-card span {
  color: var(--muted);
  font-size: 12px;
}

.progress-bar,
.bar-track {
  overflow: hidden;
  border-radius: 999px;
  background: #e6edf2;
}

.progress-bar {
  height: 9px;
}

.bar-track {
  height: 7px;
}

.progress-bar span,
.bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #49a67e);
}

.done-badge {
  display: inline-block;
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(255, 255, 255, 0.72);
  font-size: 11px;
}

.criterion-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px;
  gap: 14px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid #edf1f4;
}

.criterion-row:first-child {
  padding-top: 4px;
}

.criterion-row:last-child {
  border-bottom: 0;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  display: grid;
  align-content: space-between;
  gap: 8px;
  min-height: 100px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
  box-shadow: var(--shadow-soft);
}

.stat-card strong {
  color: var(--ink);
  font-size: 23px;
  line-height: 1.18;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
}

.suggestion-stat {
  gap: 6px;
}

.suggestion-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.suggestion-counts span {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
}

.suggestion-counts strong {
  font-size: 11px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(440px, 0.92fr) minmax(520px, 1.08fr);
  gap: 18px;
  align-items: start;
}

.dashboard-radar {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
}

.dashboard-radar .panel-head {
  grid-column: 2;
  grid-row: 1;
  margin-bottom: 0;
}

.dashboard-radar svg {
  grid-column: 1;
  grid-row: 1;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 6 / 5;
}

.ranking-panel,
.detail-panel {
  min-width: 0;
}

.ranking {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  background: #fff;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.rank-row:hover {
  border-color: var(--accent);
  background: #fbfdfd;
  box-shadow: 0 10px 22px rgba(11, 124, 117, 0.1);
}

.rank-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 850;
}

.rank-score {
  min-width: 64px;
  text-align: right;
  font-weight: 850;
  font-size: 19px;
}

.rank-detail,
.criterion-mini {
  grid-column: 2 / -1;
}

.rank-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.criterion-mini {
  display: grid;
  gap: 6px;
}

.mini-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 7px;
}

.mini-bar {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.candidate-detail {
  display: grid;
  gap: 16px;
}

.detail-section {
  display: grid;
  gap: 11px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.candidate-detail .detail-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.criterion-detail {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.radar-card {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ffffff 0%, #f7fbfa 100%);
}

.radar-card svg {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 6 / 5;
}

.radar-grid,
.radar-axis {
  fill: none;
  stroke: #d9e2e7;
  stroke-width: 1;
}

.radar-area {
  fill: rgba(11, 124, 117, 0.22);
  stroke: var(--accent);
  stroke-width: 2;
}

.radar-dot {
  fill: var(--accent-strong);
}

.radar-label {
  fill: var(--muted);
  font-size: 9px;
  dominant-baseline: middle;
}

.distribution {
  display: grid;
  gap: 5px;
}

.distribution-row {
  display: grid;
  grid-template-columns: minmax(72px, max-content) 1fr 34px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.comment-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.comment-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.comment-card p {
  color: var(--muted);
}

.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.keyword {
  padding: 5px 9px;
  border: 1px solid rgba(11, 124, 117, 0.18);
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: calc(11px * var(--weight));
  font-weight: 700;
}

.admin-grid,
.security-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 18px;
}

.event-form {
  max-width: 760px;
}

.judge-links {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.judge-link {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.4fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.judge-link code {
  overflow-wrap: anywhere;
  color: var(--accent-strong);
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  width: auto;
  min-width: 82px;
  padding-inline: 10px;
}

.backup-actions {
  display: grid;
  gap: 12px;
}

.restore-form {
  grid-template-columns: minmax(0, 1fr) 160px;
  align-items: center;
}

.compact-field {
  width: min(180px, 100%);
  gap: 4px;
  font-size: 12px;
}

.compact-field select {
  min-height: 34px;
  padding: 6px 9px;
}

.share-preview {
  max-height: 560px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.status-pill {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.is-hidden {
  display: none !important;
}

.locked {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
}

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

  .sidebar {
    position: sticky;
    height: auto;
    padding: 16px 20px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .role-nav {
    display: flex;
    overflow-x: auto;
  }

  .nav-tab {
    justify-content: center;
    min-width: 112px;
    width: auto;
  }

  .nav-tab.active::before {
    display: none;
  }

  .topbar {
    top: 113px;
  }

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

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

  .detail-panel {
    min-height: 260px;
  }
}

@media (max-width: 900px) {
  .topbar,
  .section-head,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .layout {
    padding: 20px 16px 28px;
  }

  .event-switcher,
  .actions > *,
  .actions button,
  .actions .button {
    width: 100%;
    min-width: 0;
  }

  .topbar {
    position: static;
  }

  .scoring-grid,
  .judge-entry-form,
  .admin-grid,
  .security-grid,
  .login-grid,
  .restore-form,
  .login-form,
  .password-form,
  .judge-link {
    grid-template-columns: 1fr;
  }

  .candidate-rail {
    position: static;
    max-height: none;
  }

  .candidate-list {
    max-height: 360px;
  }

  .token-field {
    grid-template-columns: 1fr;
  }

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

  .criterion-row,
  .radar-card,
  .dashboard-radar {
    grid-template-columns: 1fr;
  }

  .dashboard-radar .panel-head,
  .dashboard-radar svg {
    grid-column: 1;
    grid-row: auto;
  }
}

@media (max-width: 560px) {
  h2 {
    font-size: 21px;
  }

  .brand-card {
    grid-template-columns: 38px 1fr;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .summary-stats {
    grid-template-columns: 1fr;
  }

  .rank-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .rank-score {
    grid-column: 2;
    text-align: left;
  }

  .rank-detail,
  .criterion-mini {
    grid-column: 1 / -1;
  }

  .row-actions {
    flex-direction: column;
  }

  .row-actions button {
    width: 100%;
  }
}
