:root {
  color-scheme: dark;
  --bg: #0f0b14;
  --panel: #181220;
  --panel-strong: #21172f;
  --line: #3a2c4f;
  --text: #f2f5f8;
  --muted: #b9adc9;
  --accent: #9f7ac8;
  --accent-strong: #76569c;
  --price: #2dd4bf;
  --danger: #fb7185;
  --warn: #fbbf24;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(118, 86, 156, 0.34), transparent 32%),
    linear-gradient(rgba(15, 11, 20, 0.86), rgba(15, 11, 20, 0.94)),
    url("https://images.unsplash.com/photo-1446776811953-b23d57bd21aa?auto=format&fit=crop&w=1800&q=80");
  background-size: cover;
  background-position: center;
  color: var(--text);
  font-family:
    "Segoe UI Variable", "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.workspace {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.site-footer {
  width: min(1280px, 100%);
  margin: 24px auto 0;
  text-align: center;
}

.site-footer a {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  line-height: 1;
}

h2 {
  font-size: 1rem;
  font-weight: 500;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.title-divider {
  width: 2px;
  height: 0.8em;
  background: var(--accent);
}

.app-version {
  color: var(--muted);
  font-size: 0.42em;
  font-weight: 500;
}

.calculator-panel {
  display: block;
  position: relative;
  z-index: 200;
}

.login-form {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.login-form input {
  min-height: 38px;
}

.login-form .ghost-action {
  min-height: 38px;
}

.user-badge {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(17, 13, 23, 0.72);
  color: var(--muted);
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 600;
}

.user-badge.is-login-none {
  border-color: rgba(251, 113, 133, 0.55);
  color: var(--danger);
}

.user-badge.is-login-discord,
.user-badge.is-login-twitch {
  border-color: rgba(45, 212, 191, 0.55);
  color: var(--price);
}

.user-badge.is-login-admin {
  border-color: rgba(251, 191, 36, 0.6);
  color: var(--warn);
}

.twitch-status {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(24, 18, 32, 0.78);
  color: var(--muted);
  padding: 10px 14px;
  backdrop-filter: blur(10px);
  box-shadow: inset 0 3px 0 var(--accent);
}

.twitch-status-main {
  display: grid;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.twitch-status p {
  margin: 0;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.twitch-status-divider {
  width: 1px;
  align-self: stretch;
  background: var(--line);
}

.twitch-follow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
}

.twitch-follow-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #100b16;
  padding: 0 16px;
  text-decoration: none;
  font-weight: 600;
}

.twitch-follow-button:hover {
  background: #b894df;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(185, 173, 201, 0.14);
}

.twitch-status.is-online,
.twitch-status.is-game-online {
  border-color: rgba(45, 212, 191, 0.6);
  color: var(--text);
}

.twitch-status.is-online .twitch-dot,
.twitch-status.is-game-online .game-dot {
  background: var(--price);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.14);
}

.twitch-status.is-offline .twitch-dot,
.twitch-status:not(.is-game-online) .game-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.14);
}

.fallback-login-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.fallback-login-form input,
.fallback-login-form .ghost-action {
  min-height: 38px;
}

.login-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(15, 11, 20, 0.72);
  padding: 20px;
  backdrop-filter: blur(8px);
}

.login-modal-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(24, 18, 32, 0.96);
  box-shadow: inset 0 3px 0 var(--accent), 0 18px 70px rgba(0, 0, 0, 0.35);
  padding: 18px;
}

.login-modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.tab-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: rgba(24, 18, 32, 0.7);
  color: var(--muted);
  padding: 0 18px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 400;
}

.tab-button.is-active {
  background: rgba(24, 18, 32, 0.92);
  color: var(--text);
  box-shadow: inset 0 3px 0 var(--accent);
}

.version-section {
  border: 1px solid var(--line);
  background: rgba(24, 18, 32, 0.92);
  backdrop-filter: blur(10px);
}

.interactive-section {
  border: 0;
  background: transparent;
  backdrop-filter: blur(10px);
}

.interactive-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr);
  gap: 18px;
  min-height: 420px;
}

.interactive-column + .interactive-column {
  border-left: 0;
}

.interactive-column {
  background: rgba(24, 18, 32, 0.74);
}

.interactive-heading {
  align-items: flex-start;
}

.interactive-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 300;
  line-height: 1.35;
}

.interactive-heading a {
  color: var(--price);
  font-weight: 600;
}

.admin-editor {
  display: grid;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.poll-option-editor {
  display: grid;
  gap: 8px;
}

.poll-option-fields {
  display: grid;
  gap: 8px;
}

.poll-option-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.compact-action {
  min-height: 34px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 500;
}

.poll-list,
.reward-list {
  display: grid;
  gap: 12px;
  padding: 16px 18px 18px;
}

.poll-card,
.reward-card {
  border: 1px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 6px;
  background: #110d17;
  padding: 14px;
}

.poll-card {
  border-top-width: 2px;
}

.poll-card.is-closed,
.reward-card.is-closed {
  opacity: 0.58;
}

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

.poll-card h3,
.reward-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.35;
}

.reward-points {
  color: var(--price);
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
}

.poll-status-leds {
  display: inline-flex;
  gap: 7px;
  padding-top: 2px;
}

.status-led {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  opacity: 0.38;
}

.status-led-red {
  background: var(--danger);
  box-shadow:
    0 0 0 3px rgba(251, 113, 133, 0.12),
    0 0 10px rgba(251, 113, 133, 0.65),
    0 0 18px rgba(251, 113, 133, 0.38);
}

.status-led-green {
  background: var(--price);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.08);
}

.status-led.is-bright {
  opacity: 1;
  filter: brightness(1.45) saturate(1.2);
}

.status-led.is-muted {
  opacity: 0.28;
}

.poll-options {
  display: grid;
  gap: 10px;
}

.poll-option {
  display: grid;
  gap: 7px;
}

.poll-option.is-selected {
  color: var(--price);
}

.poll-option-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.25;
}

.poll-option-row span:last-child {
  color: var(--muted);
  white-space: nowrap;
}

.poll-bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(185, 173, 201, 0.14);
}

.poll-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.poll-hint,
.reward-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.poll-hint a {
  color: var(--price);
}

.poll-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.reward-card {
  display: grid;
  gap: 10px;
  border-top-color: var(--reward-color, var(--accent));
  box-shadow: inset 3px 0 0 var(--reward-color, var(--accent));
  padding: 0;
}

.reward-card-link {
  display: grid;
  gap: 10px;
  min-height: 100%;
  color: inherit;
  padding: 14px;
  text-decoration: none;
}

.reward-card-link:hover h3 {
  color: var(--reward-color, var(--accent));
}

.reward-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reward-icon {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(242, 245, 248, 0.18);
  border-radius: 6px;
  background: var(--reward-color, var(--accent));
}

.reward-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reward-status {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 500;
  text-align: right;
}

.reward-card small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.reward-admin {
  grid-template-columns: 1fr;
}

.reward-card .poll-admin-actions {
  margin: 0;
  padding: 0 14px 14px;
}

.version-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  padding: 16px 18px 18px;
}

.version-list article {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #110d17;
  padding: 14px;
}

.version-list h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}

.version-list ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.price-form,
.deal-section {
  border: 1px solid var(--line);
  background: rgba(24, 18, 32, 0.92);
  backdrop-filter: blur(10px);
}

.price-form {
  position: relative;
  z-index: 210;
  overflow: visible;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  align-items: end;
  gap: 16px;
  min-height: 92px;
  padding: 18px 20px;
}

.status-message {
  margin: 0;
  border: 1px solid var(--line);
  border-top: 0;
  background: rgba(24, 18, 32, 0.78);
  color: var(--muted);
  padding: 10px 20px;
  font-size: 0.82rem;
  font-weight: 500;
}

.status-message.positive {
  color: var(--price);
}

.status-message.negative {
  color: var(--danger);
}

.status-message.warning {
  color: var(--warn);
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #110d17;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(159, 122, 200, 0.18);
}

.input-pair {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #110d17;
}

.input-pair input {
  border: 0;
  background: transparent;
}

.input-pair span {
  padding-right: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.commodity-picker,
.location-picker {
  position: relative;
  z-index: 300;
}

.commodity-picker-button,
.location-picker-button {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #110d17;
  color: var(--text);
  padding: 0 12px;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
}

.commodity-picker-panel,
.location-picker-panel {
  position: absolute;
  z-index: 9999;
  top: calc(100% + 6px);
  left: 0;
  width: min(420px, 92vw);
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #110d17;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  padding: 8px;
  scrollbar-color: var(--accent) #110d17;
}

.commodity-picker-panel {
  max-height: 420px;
}

.commodity-search,
.location-search {
  width: 100%;
  min-height: 34px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #110d17;
  color: #f2f5f8;
  padding: 0 9px;
  font-size: 0.82rem;
}

.commodity-search::placeholder,
.location-search::placeholder {
  color: var(--muted);
}

.commodity-options {
  display: grid;
  gap: 3px;
}

.commodity-option {
  display: grid;
  gap: 2px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #f2f5f8;
  padding: 7px 8px;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
}

.commodity-option small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

.commodity-option:hover {
  border-color: var(--line);
  background: rgba(159, 122, 200, 0.14);
  color: var(--accent);
}

.location-tree {
  display: grid;
  gap: 2px;
}

.location-group {
  color: var(--text);
  font-size: 0.84rem;
}

.location-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  border-radius: 5px;
  padding: 9px 10px;
  font-weight: 500;
  list-style: none;
}

.location-group summary::-webkit-details-marker {
  display: none;
}

.location-group summary i::before {
  content: "⌄";
  display: inline-block;
  color: var(--accent);
  font-style: normal;
  transform: rotate(-90deg);
  transition: transform 0.12s ease;
}

.location-group[open] > summary i::before {
  transform: rotate(0deg);
}

.location-group summary:hover {
  background: rgba(159, 122, 200, 0.12);
}

.location-group summary span {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-parent,
.level-category,
.level-subgroup {
  margin-left: 17px;
  border-left: 1px solid rgba(159, 122, 200, 0.24);
  padding-left: 10px;
}

.level-parent > summary,
.level-category > summary,
.level-subgroup > summary {
  border-right: 1px solid rgba(159, 122, 200, 0.24);
}

.level-category > summary {
  color: var(--muted);
  font-size: 0.8rem;
}

.level-subgroup > summary {
  color: var(--text);
  font-size: 0.78rem;
}

.location-options {
  display: grid;
  gap: 3px;
  padding: 4px 0 8px 17px;
}

.location-option {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #f2f5f8;
  padding: 0 8px;
  text-align: left;
  cursor: pointer;
  font-weight: 500;
}

.location-option:hover {
  border-color: var(--line);
  background: rgba(159, 122, 200, 0.14);
  color: var(--accent);
}

.commodity-empty,
.location-empty {
  color: var(--muted);
  padding: 8px;
  font-weight: 500;
}

.commodity-option.is-filtered,
.location-group.is-filtered,
.location-option.is-filtered {
  display: none;
}

.primary-action,
.ghost-action {
  min-height: 44px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.primary-action {
  border: 0;
  background: var(--accent);
  color: #110d17;
}

.form-action {
  width: 100%;
}

.primary-action:hover {
  background: var(--accent-strong);
  color: var(--text);
}

.ghost-action {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  padding: 0 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.deal-section {
  margin-top: 18px;
}

.user-management {
  border-top: 1px solid var(--line);
}

.role-select {
  min-height: 36px;
  max-width: 150px;
}

.latest-section {
  margin-top: 18px;
  position: relative;
  z-index: 1;
  border: 1px solid var(--line);
  background: rgba(24, 18, 32, 0.9);
  backdrop-filter: blur(10px);
}

.compact-heading {
  padding-block: 14px;
}

.test-status {
  color: var(--warn);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: right;
}

.latest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  padding: 14px 18px 18px;
}

.price-card,
.empty-card {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #110d17;
  padding: 11px 12px;
}

.price-card h3 {
  min-width: 0;
  margin: 0 0 9px;
  overflow: hidden;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-card ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.price-card li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.28;
}

.location-stack,
.price-stack {
  display: grid;
  gap: 2px;
}

.price-stack {
  grid-template-columns: auto auto;
  align-items: center;
}

.location-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-age {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 400;
}

.price-label {
  flex: 0 0 auto;
  color: var(--price);
  white-space: nowrap;
}

.trend-indicator {
  font-size: 0.62rem;
  line-height: 1;
}

.trend-up {
  color: var(--price);
}

.trend-same {
  color: var(--text);
}

.trend-down {
  color: var(--danger);
}

.price-card p,
.empty-card {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 500;
}

.database-toggle-wrap {
  display: flex;
  justify-content: flex-start;
  margin-top: 18px;
}

.is-hidden {
  display: none;
}

.is-tab-hidden {
  display: none;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

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

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

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

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

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

td {
  font-weight: 500;
}

.positive {
  color: var(--price);
}

.negative {
  color: var(--danger);
}

.warning {
  color: var(--warn);
}

@media (max-width: 900px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .login-form {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .twitch-status {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .twitch-status-divider {
    display: none;
  }

  .twitch-follow {
    width: 100%;
    justify-content: space-between;
  }

  .fallback-login-form {
    justify-content: stretch;
  }

  .price-form {
    grid-template-columns: 1fr 1fr;
  }

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

  .interactive-layout {
    grid-template-columns: 1fr;
  }

  .interactive-column + .interactive-column {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 580px) {
  .login-form {
    align-items: stretch;
  }

  .fallback-login-form {
    grid-template-columns: 1fr;
  }

  .price-form {
    grid-template-columns: 1fr;
  }

  .poll-option-input {
    grid-template-columns: 1fr;
  }
}
