:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --text: #202623;
  --muted: #66736d;
  --line: #dde3df;
  --primary: #176b5d;
  --primary-dark: #0f5146;
  --accent: #c95f38;
  --ok: #177245;
  --todo: #925315;
  --danger: #a93838;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-right: auto;
  font-weight: 800;
  color: var(--primary-dark);
}

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.home-logo-wrap {
  display: flex;
  justify-content: center;
  margin: 10px 0 14px;
}

.home-logo {
  width: min(220px, 62vw);
  height: auto;
  object-fit: contain;
}

.container {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 18px 14px 64px;
}

h1 {
  margin: 8px 0 18px;
  font-size: 2rem;
  line-height: 1.1;
}

h2 {
  margin: 0 0 14px;
  font-size: 1.2rem;
}

.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(32, 38, 35, 0.06);
}

.panel {
  margin: 14px 0;
  padding: 16px;
}

.auth-panel {
  max-width: 440px;
  margin: 0 auto;
}

.grid {
  display: grid;
  gap: 12px;
}

.contestant-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}

small,
.muted {
  display: block;
  color: var(--muted);
}

.pill,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
}

.pill {
  background: #e8f0ed;
  color: var(--primary-dark);
}

.status.ok {
  background: #e7f5ec;
  color: var(--ok);
}

.status.todo {
  background: #fff0db;
  color: var(--todo);
}

.stack {
  display: grid;
  gap: 14px;
}

.vote-categories {
  display: grid;
  gap: 12px;
}

.vote-category {
  display: grid;
  gap: 12px;
}

.category-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.category-heading h2 {
  margin: 0;
}

.info-button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  border-radius: 999px;
  background: #e9eeeb;
  color: var(--primary-dark);
}

.info-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(20, 26, 23, 0.46);
}

.info-dialog[hidden] {
  display: none;
}

.dialog-body {
  width: min(92vw, 520px);
  max-height: 82vh;
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(32, 38, 35, 0.26);
}

.modal-open {
  overflow: hidden;
}

.info-content {
  color: var(--text);
}

.info-content ul {
  margin: 12px 0;
  padding-left: 20px;
}

.info-content li + li {
  margin-top: 6px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input,
select,
button,
.primary,
.secondary,
.ghost {
  min-height: 46px;
  border-radius: 8px;
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

button,
.primary,
.secondary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

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

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

.secondary,
.ghost,
button:not(.primary) {
  background: #e9eeeb;
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 10px;
  margin-bottom: 6px;
}

.tabs a {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 999px;
  background: #e9eeeb;
  font-weight: 700;
}

.inline-form,
.row-form,
.vote-row,
.link-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.inline-form:first-of-type,
.row-form:first-of-type,
.vote-row:first-of-type,
.link-card:first-of-type {
  border-top: 0;
}

.chief-assignment-row {
  margin-left: 18px;
  padding-left: 12px;
  border-left: 3px solid var(--line);
  background: #fafbf9;
}

.qr-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-image {
  width: 160px;
  height: 160px;
  object-fit: contain;
}

.link-field {
  align-self: center;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.check input {
  width: 20px;
  min-height: 20px;
}

.action-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  margin: 0 -14px;
  padding: 12px 14px;
  background: rgba(246, 247, 244, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.sticky-actions > * {
  flex: 1;
}

.notice,
.error {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
}

.notice {
  background: #e7f5ec;
  color: var(--ok);
}

.error {
  background: #fdeaea;
  color: var(--danger);
}

.vote-row span,
.row-form span {
  min-width: 0;
}

@media (min-width: 720px) {
  .container {
    padding: 28px 24px 80px;
  }

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

  .vote-categories {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .inline-form {
    grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
    align-items: end;
  }

  .row-form,
  .vote-row,
  .link-card {
    grid-template-columns: minmax(180px, 1.2fr) repeat(2, minmax(120px, 1fr)) auto;
    align-items: center;
  }

  .link-card {
    grid-template-columns: 180px minmax(260px, 1fr) auto;
  }

  .qr-image {
    width: 140px;
    height: 140px;
  }
}
