:root {
  color-scheme: dark;
  --bg: #020806;
  --panel: rgba(6, 22, 13, 0.82);
  --panel-deep: rgba(2, 12, 7, 0.86);
  --field: rgba(1, 10, 6, 0.92);
  --line: rgba(78, 159, 99, 0.36);
  --line-hot: rgba(126, 255, 164, 0.9);
  --text: #e9f5eb;
  --muted: #8ba08e;
  --green: #7dffab;
  --green-strong: #39d875;
  --red: #ff6969;
  --shadow: rgba(0, 0, 0, 0.48);
  font-family:
    "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC",
    system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(0, 25, 12, 0.92), rgba(3, 11, 7, 0.86) 42%, rgba(19, 18, 6, 0.68)),
    linear-gradient(rgba(126, 255, 164, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(126, 255, 164, 0.045) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 34px 34px, 34px 34px;
  color: var(--text);
}

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

button {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease,
    background-color 180ms ease;
}

.hidden {
  display: none !important;
}

body.is-logged-in .auth-card {
  display: none !important;
}

body:not(.is-logged-in) #logoutButton {
  display: none !important;
}

body.is-logged-in .console-layout {
  grid-template-columns: 300px minmax(0, 1fr);
}

body:not(.is-admin) .admin-only {
  display: none !important;
}

body:not(.role-buyer) .buyer-only,
body:not(.role-companion) .companion-only {
  display: none !important;
}

.site-shell {
  width: min(1320px, calc(100vw - 48px));
  margin: 32px auto;
}

.command-header,
.panel {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 22px 70px var(--shadow);
}

.command-header::before,
.panel::before {
  content: "";
  position: absolute;
  left: -1px;
  bottom: -1px;
  border-top: 18px solid rgba(126, 255, 164, 0.14);
  border-left: 18px solid transparent;
}

.command-header::after,
.panel::after {
  content: "";
  position: absolute;
  right: -1px;
  top: -1px;
  border-bottom: 18px solid rgba(126, 255, 164, 0.14);
  border-right: 18px solid transparent;
}

.command-header {
  min-height: 102px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
  margin-bottom: 24px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
}

.delta-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-hot);
  color: var(--green);
  background: rgba(126, 255, 164, 0.1);
  font-size: 28px;
  font-weight: 900;
  box-shadow: 0 0 36px rgba(126, 255, 164, 0.14);
}

.brand-lockup h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.08;
  letter-spacing: 0;
}

.brand-lockup p,
.flow-line,
.note-line,
.empty-state,
.permission-card small {
  color: var(--muted);
  line-height: 1.6;
}

.brand-lockup p {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.user-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.user-strip strong {
  color: var(--green);
}

.console-layout {
  display: grid;
  grid-template-columns: 344px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.sidebar,
.main-stage {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel {
  padding: 22px;
}

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

.title-copy {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.title-copy small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.55;
}

.panel-title.compact {
  margin-top: 12px;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.panel-title span,
.create-badge {
  min-height: 28px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--green);
  background: var(--green);
  color: #021006;
  font-size: 13px;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-button,
.nav-button,
.primary-button,
.secondary-button,
.danger-button {
  min-height: 52px;
  border-radius: 0;
  font-weight: 950;
  letter-spacing: 0;
}

.tab-button {
  border: 1px solid var(--line);
  background: rgba(7, 28, 15, 0.66);
  color: var(--text);
}

.tab-button.active,
.nav-button.active,
.primary-button {
  border-color: var(--green);
  background: linear-gradient(135deg, #72efa0, var(--green-strong));
  color: #021006;
}

.tab-button:hover,
.nav-button:hover,
.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.create-badge:hover,
.game-tile:not(.disabled):hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

.tab-button:active,
.nav-button:active,
.primary-button:active,
.secondary-button:active,
.danger-button:active,
.create-badge:active,
.game-tile:not(.disabled):active {
  transform: translateY(1px) scale(0.99);
}

.button-ripple {
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
  border-radius: 999px;
  background: rgba(233, 245, 235, 0.42);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple-out 520ms ease-out forwards;
}

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

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  background: var(--field);
  color: var(--text);
  padding: 0 14px;
  font-size: 16px;
  font-weight: 800;
}

textarea {
  min-height: 132px;
  padding: 16px;
  line-height: 1.6;
  resize: vertical;
}

select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--text) 50%) calc(100% - 20px) 50% / 8px 8px no-repeat,
    linear-gradient(135deg, var(--text) 50%, transparent 50%) calc(100% - 14px) 50% / 8px 8px no-repeat,
    var(--field);
  padding-right: 48px;
}

input::placeholder,
textarea::placeholder {
  color: rgba(233, 245, 235, 0.42);
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-hot);
  box-shadow: 0 0 0 4px rgba(126, 255, 164, 0.08);
}

.primary-button,
.secondary-button,
.danger-button {
  padding: 0 16px;
  border: 1px solid var(--line);
}

.secondary-button {
  background: rgba(7, 28, 15, 0.58);
  color: var(--text);
}

.danger-button {
  border-color: rgba(255, 105, 105, 0.45);
  background: rgba(80, 14, 14, 0.22);
  color: var(--red);
}

.danger-button.small {
  min-height: 48px;
  padding: 0 14px;
}

.note-line {
  margin: 12px 0 0;
  font-size: 13px;
  font-weight: 700;
}

.side-nav {
  display: grid;
  gap: 9px;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(18, 50, 28, 0.62);
  color: var(--text);
  padding: 0 14px;
  text-align: left;
}

.nav-button b {
  color: inherit;
}

.permission-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: rgba(1, 10, 6, 0.54);
  padding: 14px;
}

.permission-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.permission-card strong {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-size: 20px;
}

.permission-card small {
  display: block;
  margin-top: 4px;
  font-weight: 750;
}

.support-card {
  display: grid;
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  align-self: start;
  overflow: hidden;
  padding: 14px;
  contain: layout paint;
}

.support-image {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  height: 280px;
  border: 1px solid rgba(126, 255, 164, 0.28);
  background: #f3f3f0;
  box-shadow: inset 0 0 0 1px rgba(126, 255, 164, 0.08);
  contain: strict;
}

.support-image img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain;
  object-position: center;
}

.support-card p {
  margin: 0;
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.6;
}

.view-panel,
.locked-panel {
  display: none;
  min-height: 310px;
}

.view-panel[hidden],
.locked-panel[hidden] {
  display: none !important;
}

.view-panel.active,
.locked-panel.active {
  display: block;
  animation: panel-in 260ms ease-out both;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: rgba(1, 10, 6, 0.58);
  padding: 14px;
}

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

.stat-card strong {
  color: var(--green);
  font-size: 28px;
  line-height: 1;
}

.flow-line {
  margin: 16px 0 14px;
  font-size: 14px;
  font-weight: 800;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

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

.order-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(1, 10, 6, 0.5);
  padding: 14px;
  animation: row-in 220ms ease-out both;
  transition:
    transform 170ms ease,
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.order-row:hover {
  transform: translateX(3px);
  border-color: rgba(126, 255, 164, 0.58);
  background: rgba(7, 28, 15, 0.66);
  box-shadow: inset 3px 0 0 rgba(126, 255, 164, 0.58);
}

.order-row h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.order-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.55;
}

.status-chip {
  min-width: 74px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-hot);
  color: var(--green);
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 950;
}

.status-chip.rejected {
  border-color: rgba(255, 105, 105, 0.55);
  color: var(--red);
}

.status-chip.approved {
  color: var(--green);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.row-actions .secondary-button,
.row-actions .danger-button {
  min-height: 48px;
}

.empty-state {
  margin: 0;
  font-weight: 800;
}

.error-text {
  color: var(--red);
}

.order-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.management-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.mini-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  border: 1px solid var(--line);
  background: rgba(1, 10, 6, 0.46);
  padding: 16px;
}

.user-row.selected {
  border-color: var(--line-hot);
  box-shadow: inset 3px 0 0 rgba(126, 255, 164, 0.72);
}

.message-text {
  white-space: pre-wrap;
  color: var(--text);
  margin-top: 8px;
}

.user-order-row {
  align-items: start;
}

.unread-dot {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 24px;
  border: 1px solid var(--green);
  color: #021006;
  background: var(--green);
  font-size: 12px;
  font-weight: 950;
}

.mail-grid {
  display: grid;
  grid-template-columns: minmax(230px, 0.9fr) minmax(0, 1.35fr);
  gap: 14px;
  align-items: stretch;
}

.mail-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.mail-item {
  display: grid;
  gap: 8px;
  min-height: 74px;
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(1, 10, 6, 0.58);
  color: var(--text);
  padding: 12px;
  text-align: left;
  animation: row-in 220ms ease-out both;
}

.mail-item:hover,
.mail-item.active {
  border-color: var(--line-hot);
  background: rgba(7, 28, 15, 0.76);
  box-shadow: inset 3px 0 0 rgba(126, 255, 164, 0.72);
}

.mail-item span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 15px;
  font-weight: 950;
}

.mail-item small,
.mail-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.mail-detail {
  min-height: 240px;
  border: 1px solid var(--line);
  background: rgba(1, 10, 6, 0.52);
  padding: 16px;
}

.game-picks {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.game-tile {
  min-height: 128px;
  display: grid;
  align-content: center;
  gap: 10px;
  text-align: left;
  padding: 20px;
  border: 1px solid var(--line);
  background: rgba(7, 28, 15, 0.5);
  color: var(--text);
}

.game-tile.active {
  border-color: var(--line-hot);
  box-shadow: inset 0 0 0 1px rgba(126, 255, 164, 0.46);
  animation: tile-lock 220ms ease-out both;
}

.game-tile.disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.game-tile strong {
  font-size: 22px;
}

.game-tile small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  font-weight: 800;
}

.wide {
  grid-column: 1 / -1;
}

.edit-notice {
  margin: 0;
  border: 1px solid rgba(126, 255, 164, 0.42);
  background: rgba(126, 255, 164, 0.08);
  color: var(--green);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.55;
}

.submit-notice {
  margin: 0;
  border: 1px solid rgba(126, 255, 164, 0.38);
  background: rgba(126, 255, 164, 0.07);
  color: var(--green);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.55;
}

.submit-notice.error {
  border-color: rgba(255, 105, 105, 0.46);
  background: rgba(80, 14, 14, 0.22);
  color: var(--red);
}

.action-result {
  margin: 0;
  border-top: 1px solid rgba(126, 255, 164, 0.35);
  padding: 12px 0 0;
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.5;
  animation: result-line-in 220ms ease-out both;
}

.action-result::before {
  content: "STATUS";
  display: inline-flex;
  margin-right: 10px;
  border: 1px solid rgba(126, 255, 164, 0.45);
  padding: 2px 7px;
  color: #04140a;
  background: var(--green);
  font-size: 11px;
  font-weight: 950;
  vertical-align: 1px;
}

.action-result.error {
  border-top-color: rgba(255, 105, 105, 0.45);
  color: var(--red);
}

.action-result.error::before {
  border-color: rgba(255, 105, 105, 0.62);
  background: rgba(255, 105, 105, 0.16);
  color: var(--red);
}

.mode-selector select {
  min-height: 58px;
  border-color: var(--line-hot);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ticket-dock {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.ticket-dock.flash {
  animation: dock-flash 900ms ease-out both;
}

.shot-hint {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.6;
}

.ticket-shell {
  width: min(960px, 100%);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.34);
}

canvas {
  width: 100%;
  display: block;
}

.result-dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
}

.result-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
}

.result-dialog__panel {
  position: relative;
  width: min(440px, 100%);
  border: 1px solid rgba(126, 255, 164, 0.5);
  background:
    linear-gradient(135deg, rgba(126, 255, 164, 0.08), transparent 44%),
    rgba(2, 18, 9, 0.98);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48), inset 0 0 0 1px rgba(126, 255, 164, 0.08);
  padding: 28px;
  display: grid;
  gap: 18px;
  animation: dialog-in 220ms ease-out both;
}

.result-dialog__panel::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, transparent 50%, rgba(126, 255, 164, 0.22) 50%);
}

.result-dialog__mark {
  width: 52px;
  height: 52px;
  border: 1px solid rgba(126, 255, 164, 0.68);
  display: grid;
  place-items: center;
  color: var(--green);
  font-size: 26px;
  font-weight: 950;
  box-shadow: inset 0 0 18px rgba(126, 255, 164, 0.08);
}

.result-dialog__panel h2 {
  margin: 0;
  font-size: 24px;
}

.result-dialog__panel p {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.6;
}

.result-dialog__panel .primary-button {
  justify-self: start;
  min-width: 110px;
}

.result-dialog.error .result-dialog__panel {
  border-color: rgba(255, 105, 105, 0.52);
  background:
    linear-gradient(135deg, rgba(255, 105, 105, 0.1), transparent 44%),
    rgba(18, 4, 4, 0.98);
}

.result-dialog.error .result-dialog__mark {
  border-color: rgba(255, 105, 105, 0.62);
  color: var(--red);
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ripple-out {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(18);
  }
}

@keyframes tile-lock {
  0% {
    box-shadow: inset 0 0 0 1px rgba(126, 255, 164, 0);
  }
  100% {
    box-shadow: inset 0 0 0 1px rgba(126, 255, 164, 0.46);
  }
}

@keyframes dock-flash {
  0% {
    filter: brightness(1);
  }
  28% {
    filter: brightness(1.22);
  }
  100% {
    filter: brightness(1);
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes result-line-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 1060px) {
  body.is-logged-in .console-layout,
  .console-layout {
    grid-template-columns: 1fr;
  }

  .stat-grid,
  .game-picks {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .site-shell {
    width: min(100vw - 24px, 1320px);
    margin: 12px auto;
  }

  body.is-logged-in .console-layout,
  .console-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    order: 1;
  }

  .main-stage {
    order: 2;
  }

  #createView {
    order: 99;
  }

  .command-header,
  .brand-lockup,
  .user-strip,
  .panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup h1 {
    font-size: 25px;
  }

  .stat-grid,
  .game-picks,
  .order-form,
  .mail-grid,
  .management-grid,
  .mini-form {
    grid-template-columns: 1fr;
  }

  .support-image {
    height: 260px;
  }

  .wide {
    grid-column: auto;
  }

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

  .row-actions {
    justify-content: flex-start;
  }
}
