:root {
  --bg: #0f0d18;
  --surface: #1b1728;
  --surface-2: #241f35;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f1ff;
  --muted: #b5abc9;
  --accent: linear-gradient(135deg, #6d7cff 0%, #9d42ff 100%);
  --success: #34d399;
  --warning: #f59e0b;
  --control-bg: rgba(255, 255, 255, 0.06);
  --control-border: rgba(255, 255, 255, 0.08);
  --control-height: 56px;
  --control-radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(109, 124, 255, 0.22), transparent 30%),
    linear-gradient(180deg, #120f1c 0%, #0d0b14 100%);
  color: var(--text);
}

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

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.panel,
.metric-card,
.table-card,
.detail-card {
  background: rgba(27, 23, 40, 0.92);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.auth-card {
  width: min(440px, 100%);
  padding: 32px;
}

.eyebrow {
  color: #b08cff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

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

.form-stack {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.field-hint {
  color: rgba(244, 241, 255, 0.62);
  font-size: 12px;
  line-height: 1.45;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(4, 3, 12, 0.72);
  padding: 24px;
}

.confirm-modal {
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #191524;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  padding: 24px;
}

.confirm-modal p {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.upload-row {
  display: grid;
  gap: 10px;
  align-items: center;
}

.upload-status {
  min-height: 18px;
  font-size: 13px;
}

.content-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
}

.content-counters div {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 12px;
}

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

.file-picker {
  position: relative;
  display: flex;
  min-height: 56px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 14px;
  color: var(--text);
  cursor: pointer;
}

.file-picker:hover {
  border-color: rgba(109, 124, 255, 0.55);
  background: rgba(255, 255, 255, 0.06);
}

.file-picker__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-picker__button {
  flex: 0 0 auto;
  border-radius: 10px;
  background: #ffffff;
  color: #0f0d18;
  padding: 8px 12px;
  font-weight: 700;
  line-height: 1;
}

.file-picker__name {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conditional-field[hidden] {
  display: none;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--control-radius);
  font-size: 15px;
  line-height: 1.2;
}

input,
select {
  min-height: var(--control-height);
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.native-select {
  display: none !important;
}

.custom-select {
  position: relative;
}

.custom-select__trigger {
  all: unset;
  box-sizing: border-box;
  display: flex;
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--control-radius);
  font-size: 15px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.custom-select__trigger:hover,
.custom-select.is-open .custom-select__trigger {
  border-color: rgba(109, 124, 255, 0.55);
}

.custom-select__trigger:focus {
  outline: none;
  border-color: rgba(109, 124, 255, 0.95);
  box-shadow: 0 0 0 3px rgba(109, 124, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.custom-select__label {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  text-align: left;
  color: var(--text);
}

.custom-select__label.is-placeholder {
  color: rgba(244, 241, 255, 0.56);
}

.custom-select__icon {
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(244, 241, 255, 0.72);
  border-bottom: 2px solid rgba(244, 241, 255, 0.72);
  transform: rotate(0deg);
  transition: transform 160ms ease, border-color 160ms ease;
}

.custom-select.is-open .custom-select__icon {
  transform: rotate(225deg);
  border-color: rgba(255, 255, 255, 0.92);
}

.custom-select__menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  padding: 8px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #26242d;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.34);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.custom-select__menu[hidden] {
  display: none;
}

.custom-select.is-open .custom-select__menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.custom-select__options {
  display: grid;
  gap: 4px;
  max-height: 240px;
  overflow: auto;
}

.custom-select__option {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 14px;
  border-radius: 14px;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.custom-select__option-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  object-fit: contain;
}

.custom-select__option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.custom-select__option.is-active {
  background: rgba(255, 255, 255, 0.08);
}

.custom-select__option.is-selected {
  background: #3a3a46;
  color: #ffffff;
}

.button,
button {
  border: 0;
  border-radius: 14px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 14px 18px;
  background: var(--accent);
  color: white;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  max-width: 100%;
  text-align: center;
}

.button.secondary,
button.secondary {
  background: rgba(255, 255, 255, 0.08);
}

.error {
  margin-top: 16px;
  color: #ffb4b4;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  min-width: 0;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--border);
  background: rgba(12, 10, 19, 0.86);
}

.brand {
  margin-bottom: 32px;
}

.sidebar-nav {
  display: grid;
  gap: 10px;
}

.nav-link {
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--muted);
}

.nav-link.active,
.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.content {
  padding: 24px;
  display: grid;
  gap: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

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

.metric-card,
.table-card,
.detail-card,
.panel {
  padding: 20px;
}

.metric-value {
  margin-top: 12px;
  font-size: 32px;
  font-weight: 800;
}

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

.table th,
.table td {
  text-align: left;
  padding: 14px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.draft {
  background: rgba(245, 158, 11, 0.14);
  color: #f8c76f;
}

.badge.published {
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
}

.badge.unpublished {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
}

.badge.archived {
  background: rgba(248, 113, 113, 0.14);
  color: #fecaca;
}

.badge.audit {
  background: rgba(96, 165, 250, 0.14);
  color: #bfdbfe;
}

pre {
  max-width: 520px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.grid-two {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.grid-two > * {
  min-width: 0;
}

.grid-two > label {
  align-self: start;
  align-content: start;
}

.grid-two.equal {
  grid-template-columns: 1fr 1fr;
}

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

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

.list-item {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.list-item.readiness-flash {
  animation: readinessFlash 3s ease-out;
}

@keyframes readinessFlash {
  0%,
  70% {
    border-color: rgba(255, 99, 132, 0.75);
    background: rgba(255, 99, 132, 0.18);
    box-shadow: 0 0 0 1px rgba(255, 99, 132, 0.24), 0 0 28px rgba(255, 99, 132, 0.2);
  }
  100% {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.03);
    box-shadow: none;
  }
}

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

.form-panel {
  max-width: 920px;
  width: 100%;
}

.field-title {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.date-time-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
}

.tab-area {
  display: block;
  background: transparent;
}

.tabs {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 0;
  background: transparent;
}

.tab-button {
  flex: 0 0 auto;
  width: auto;
  min-width: 170px;
  height: 80px;
  min-height: 80px;
  padding: 0 26px;
  background: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.tab-button.is-active {
  background: var(--accent);
}

.tab-panels {
  margin-top: 72px;
  background: transparent;
}

[data-tab-panel] {
  margin: 0;
}

[data-tab-panel][hidden] {
  display: none;
}

.actions-row,
.actions-inline,
.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.actions-inline form,
.actions-row form,
.section-head form {
  display: inline-flex;
}

.actions-row {
  margin-top: 8px;
}

.section-head {
  justify-content: space-between;
}

.filters-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) minmax(160px, 220px) auto;
  gap: 12px;
  margin-bottom: 18px;
}

.monitoring-filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(120px, 160px) minmax(120px, 160px) minmax(150px, 180px) auto;
  gap: 12px;
  align-items: end;
}

.monitoring-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.monitoring-table {
  min-width: 980px;
}

.monitoring-table code {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.latency-warn {
  color: #fde68a;
  font-weight: 800;
}

.latency-bad {
  color: #fecaca;
  font-weight: 800;
}

.monitoring-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.monitoring-list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.monitoring-list-item span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.table-card {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-card::-webkit-scrollbar {
  height: 8px;
}

.table-card::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.alert {
  padding: 14px 16px;
  border-radius: 16px;
}

.error-box {
  background: rgba(255, 99, 132, 0.12);
  border: 1px solid rgba(255, 99, 132, 0.24);
  color: #ffd4dd;
}

.warning-box {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.24);
  color: #fde68a;
}

.info-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  grid-template-columns: none;
  cursor: pointer;
}

.checkbox-row input {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  display: inline-grid;
  place-items: center;
}

.checkbox-row input::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  transform: scale(0);
  transition: transform 120ms ease-in-out;
  background: linear-gradient(135deg, #6d7cff 0%, #9d42ff 100%);
}

.checkbox-row input:checked {
  border-color: rgba(157, 66, 255, 0.8);
  background: rgba(157, 66, 255, 0.16);
}

.checkbox-row input:checked::before {
  transform: scale(1);
}

.checkbox-row span {
  color: var(--text);
}

.checkbox-row .field-hint {
  flex-basis: 100%;
  margin-left: 32px;
  color: rgba(244, 241, 255, 0.62);
}

code {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 8px;
  border-radius: 10px;
}

.qr-link-chip {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 10px;
  padding: 6px 10px;
  overflow: hidden;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qr-card-prizes {
  order: 2;
}

.qr-card-tasks {
  order: 1;
}

.qr-preview {
  display: inline-flex;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.qr-preview img {
  width: 180px;
  height: 180px;
  display: block;
  background: white;
  padding: 8px;
  border-radius: 12px;
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 20px;
  }

  .brand {
    margin-bottom: 18px;
  }

  .sidebar-nav {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .content {
    padding: 20px;
  }

  .metrics,
  .grid-two,
  .grid-two.equal {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head,
  .info-card {
    align-items: stretch;
    flex-direction: column;
  }

  .filters-row {
    grid-template-columns: 1fr;
  }

  .monitoring-filters,
  .monitoring-split {
    grid-template-columns: 1fr;
  }

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

  .tab-button {
    width: 100%;
    min-width: 0;
    height: 64px;
    min-height: 64px;
    padding: 0 16px;
    white-space: normal;
  }

  .tab-panels {
    margin-top: 28px;
  }
}

@media (max-width: 720px) {
  body {
    background: linear-gradient(180deg, #120f1c 0%, #0d0b14 100%);
  }

  .auth-card,
  .panel,
  .metric-card,
  .table-card,
  .detail-card {
    border-radius: 18px;
  }

  .auth-card,
  .metric-card,
  .table-card,
  .detail-card,
  .panel {
    padding: 16px;
  }

  .sidebar,
  .content {
    padding: 16px;
  }

  .topbar {
    gap: 14px;
  }

  .topbar h1 {
    font-size: 28px;
    line-height: 1.15;
  }

  .metrics {
    gap: 12px;
  }

  .metric-value {
    font-size: 28px;
  }

  .tabs {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .tab-button {
    height: 56px;
    min-height: 56px;
  }

  .actions-row,
  .actions-inline,
  .section-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .actions-row > *,
  .actions-inline > *,
  .section-head > *,
  .actions-row form,
  .actions-inline form,
  .section-head form,
  .actions-row .button,
  .actions-inline .button,
  .section-head .button,
  .actions-row button,
  .actions-inline button,
  .section-head button {
    width: 100%;
  }

  .custom-select__menu {
    max-height: 280px;
    overflow: auto;
  }

  .date-time-card {
    padding: 14px;
  }

  .checkbox-row {
    align-items: flex-start;
  }

  .checkbox-row .field-hint {
    margin-left: 0;
  }

  .confirm-modal {
    padding: 18px;
  }
}

@media (max-width: 480px) {
  input,
  textarea,
  select,
  .custom-select__trigger {
    border-radius: 12px;
    font-size: 14px;
    padding: 13px 14px;
  }

  .button,
  button {
    min-height: 48px;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
  }

  .topbar h1 {
    font-size: 24px;
  }

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

  .list-item {
    padding: 12px;
  }

  .table {
    min-width: 640px;
  }
}
