:root {
  color-scheme: dark;
  --bg: #05070b;
  --surface: #10141c;
  --surface-2: #151b25;
  --surface-3: #1d2532;
  --line: #2a3444;
  --line-strong: #4a5a70;
  --text: #eef4ff;
  --muted: #9aa8ba;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.22);
  --teal: #2dd4bf;
  --red: #ef4444;
  --blue: #60a5fa;
  --green: #34d399;
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.36);
  --shadow-tight: 0 10px 24px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

button:hover {
  border-color: var(--line-strong);
  box-shadow: 0 5px 14px rgba(36, 48, 66, 0.08);
}

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

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

[hidden] {
  display: none !important;
}

.app {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 16px;
  width: min(100%, 1440px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.side,
.work {
  min-width: 0;
}

.work {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 1101px) {
  .side {
    position: sticky;
    top: 16px;
    align-self: start;
  }
}

.brand,
.panel,
.filters,
.result-area,
.toolbar {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 15px;
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(15, 127, 110, 0.25);
  border-radius: 7px;
  background: rgba(15, 127, 110, 0.1);
  color: #0d6b5f;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.icon-btn {
  width: 40px;
  padding: 0;
  font-size: 20px;
}

.panel,
.result-area {
  padding: 14px;
}

.section-head,
.result-head,
.allocation-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2,
.result-head h2 {
  margin: 0;
  font-size: 18px;
}

.section-head span,
.result-head p,
.status {
  color: var(--muted);
  font-size: 13px;
}

.result-head p {
  margin: 5px 0 0;
}

.logic-note {
  display: inline-block;
  margin-left: 10px;
  color: #0d6b5f;
}

.number-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 40px;
  gap: 8px;
  margin: 12px 0;
}

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

.num-btn {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 50px;
  padding: 7px 3px 5px;
  border-radius: 7px;
  border-width: 2px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
}

.num-main {
  position: relative;
  z-index: 4;
  display: block;
  margin-top: 0;
  font-size: 18px;
}

.num-money {
  position: relative;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 15px;
  margin-top: 3px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(23, 32, 51, 0.08);
  color: var(--text);
  font-size: 10px;
  font-weight: 800;
  opacity: 0;
}

.num-btn.with-amount .num-money {
  opacity: 1;
}

.num-btn[data-role]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 9px;
  right: 9px;
  z-index: 3;
  display: none;
  height: 5px;
  align-items: center;
  justify-content: center;
  border-radius: 0 0 999px 999px;
  color: #fff;
  box-shadow: none;
}

.num-btn.role-main::after,
.num-btn.role-second::after,
.num-btn.role-defense::after {
  display: inline-flex;
}

.num-btn.role-main::after {
  background: #c51f37;
}

.num-btn.role-second::after {
  background: #b7791f;
}

.num-btn.role-defense::after {
  background: #5b5f97;
}

.num-btn.wave-red {
  border-color: rgba(202, 32, 50, 0.38);
  background: rgba(202, 32, 50, 0.055);
}

.num-btn.wave-blue {
  border-color: rgba(23, 114, 198, 0.38);
  background: rgba(23, 114, 198, 0.055);
}

.num-btn.wave-green {
  border-color: rgba(35, 139, 69, 0.38);
  background: rgba(35, 139, 69, 0.06);
}

.num-btn.selected {
  border-color: #0b63ce;
  background: #dbeafe;
  box-shadow: inset 0 0 0 3px #1764d8, 0 9px 20px rgba(23, 100, 216, 0.28);
  color: #0e2852;
}

.num-btn.selected::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 3px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.88);
  pointer-events: none;
}

.num-btn.selected .num-main {
  color: #071b3a;
  font-weight: 900;
}

.num-btn.selected .num-money {
  background: #fff;
  color: #0e2852;
}

.num-btn.blocked {
  opacity: 0.38;
  box-shadow: none;
}

.num-btn.wave-red.selected {
  background: #fee2e2;
  border-color: #b91c1c;
  box-shadow: inset 0 0 0 3px #dc2626, 0 9px 20px rgba(202, 32, 50, 0.28);
}

.num-btn.wave-blue.selected {
  background: #dbeafe;
  border-color: #1d4ed8;
  box-shadow: inset 0 0 0 3px #2563eb, 0 9px 20px rgba(23, 114, 198, 0.28);
}

.num-btn.wave-green.selected {
  background: #dcfce7;
  border-color: #15803d;
  box-shadow: inset 0 0 0 3px #16a34a, 0 9px 20px rgba(35, 139, 69, 0.28);
}

.num-btn.role-main {
  outline: 2px solid rgba(197, 31, 55, 0.3);
  outline-offset: -4px;
}

.num-btn.role-second {
  outline: 2px solid rgba(183, 121, 31, 0.3);
  outline-offset: -4px;
}

.num-btn.role-defense {
  outline: 2px solid rgba(91, 95, 151, 0.32);
  outline-offset: -4px;
}

.manual-groups {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.manual-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 6px 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid #e4ebf2;
  border-radius: 8px;
  background: #fbfcfe;
}

.manual-row > span {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.manual-row input {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  font-weight: 700;
}

.manual-row input[readonly] {
  background: #eef3f7;
  color: #40516b;
  cursor: default;
}

.manual-row output {
  grid-column: 2;
  min-height: 14px;
  color: var(--muted);
  font-size: 11px;
}

.manual-row output.warn {
  color: #b45309;
  font-weight: 700;
}

.manual-profit-panel {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid #dde8f3;
  border-radius: 8px;
  background: #f7fbff;
}

.mobile-profit-panel {
  display: none;
}

.profit-dock {
  grid-column: 1 / -1;
  align-self: start;
  min-height: 300px;
  margin-top: -2px;
}

.manual-profit-section {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 6px 8px;
  align-items: start;
}

.manual-profit-section > strong {
  color: var(--text);
  font-size: 12px;
  line-height: 24px;
}

.profit-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 6px;
  min-width: 0;
}

.profit-chip {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 44px;
  padding: 5px 7px;
  border: 1px solid rgba(13, 107, 95, 0.24);
  border-radius: 7px;
  background: #fff;
  color: #0d6b5f;
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
}

.profit-num {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 30px;
  border-radius: 6px;
  background: #eef7f5;
  color: #172033;
  font-size: 15px;
  line-height: 1;
}

.profit-values {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.profit-amount,
.profit-net {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profit-amount {
  color: #536276;
  font-size: 10px;
  font-weight: 700;
}

.profit-net {
  color: #0d6b5f;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.profit-chip.loss {
  border-color: rgba(185, 28, 28, 0.24);
  color: #b91c1c;
}

.profit-chip.loss .profit-num {
  background: #fff1f2;
}

.profit-chip.loss .profit-net {
  color: #b91c1c;
}

.profit-empty {
  color: var(--muted);
  font-size: 11px;
  line-height: 24px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  padding: 9px 12px;
}

.hidden-pick-control {
  display: none !important;
}

.toolbar label,
.filter-inputs label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toolbar label {
  flex: 0 0 auto;
  gap: 3px;
  font-size: 11px;
}

.toolbar label:has(#groupCount),
.toolbar label:has(#budgetRange),
.toolbar label:has(#oddsAmount) {
  width: 82px;
}

.toolbar label:has(#budgetAmount) {
  width: 124px;
}

.toolbar label:has(#separators) {
  width: 132px;
}

.toolbar input,
.filter-inputs input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  color: var(--text);
  font-weight: 600;
}

.toolbar input {
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
}

.filters {
  display: grid;
  gap: 8px;
  padding: 9px 12px;
}

.filter-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.filter-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}

.filter-side-stack {
  display: grid;
  gap: 6px;
  align-self: start;
  width: 330px;
}

.filter-band {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid #e4ebf2;
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfcfe 0%, var(--surface-2) 100%);
}

.filter-inputs {
  display: grid;
  grid-template-columns: 1fr;
}

.filter-top .filter-inputs {
  flex: 0 0 auto;
}

.filter-top .filter-inputs:has(#headDigits) {
  width: 210px;
}

.filter-top .filter-inputs:has(#tailDigits) {
  width: 270px;
}

.filter-title {
  min-width: 44px;
  color: var(--text);
  font-weight: 800;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip-grid.compact {
  gap: 7px;
}

.zodiac-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  align-self: start;
  min-height: 96px;
}

.zodiac-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  gap: 7px;
  width: 100%;
}

.zodiac-grid .check-pill {
  justify-content: center;
  min-width: 0;
}

.wave-band,
.prefix-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  align-content: start;
  min-height: 38px;
}

.parity-band {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  width: 148px;
}

.wave-band .chip-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
}

.prefix-band .chip-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
}

.wave-band .check-pill,
.prefix-band .check-pill {
  justify-content: center;
  min-width: 0;
  min-height: 30px;
  padding: 0 6px;
  font-size: 12px;
  gap: 5px;
}

.parity-band .check-pill {
  justify-content: center;
  min-width: 0;
  min-height: 31px;
  padding: 0 7px;
}

.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
}

.check-pill:has(input:checked) {
  border-color: var(--accent);
  background: #eef5ff;
  box-shadow: inset 0 0 0 1px rgba(23, 100, 216, 0.12);
}

.check-pill input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.check-pill span {
  white-space: nowrap;
}

.check-pill.red {
  border-color: rgba(202, 32, 50, 0.32);
}

.check-pill.blue {
  border-color: rgba(23, 114, 198, 0.32);
}

.check-pill.green {
  border-color: rgba(35, 139, 69, 0.32);
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.swatch.red {
  background: var(--red);
}

.swatch.blue {
  background: var(--blue);
}

.swatch.green {
  background: var(--green);
}

.result-area {
  min-width: 0;
}

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

.allocation-panel {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid #e2e9f0;
  border-radius: 8px;
  background: #fbfcfe;
}

.allocation-title {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.allocation-title strong {
  color: var(--muted);
  font-size: 12px;
}

.allocation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 7px;
}

.tier-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.group-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.group-card {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 8px;
  border: 1px solid #d8e2ed;
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
}

.group-card strong {
  color: var(--text);
  font-size: 13px;
}

.group-card strong small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.group-card span {
  color: var(--muted);
  line-height: 1.35;
  word-break: break-all;
}

.group-card em {
  color: var(--teal);
  font-style: normal;
  font-weight: 800;
}

.tier-card {
  display: grid;
  gap: 3px;
  min-height: 92px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
}

.tier-card strong {
  color: var(--text);
  font-size: 13px;
}

.tier-card span {
  color: var(--muted);
}

.tier-card em {
  color: var(--teal);
  font-style: normal;
  font-weight: 800;
}

.tier-card.main {
  border-color: rgba(197, 31, 55, 0.28);
  background: rgba(197, 31, 55, 0.05);
}

.tier-card.second {
  border-color: rgba(183, 121, 31, 0.28);
  background: rgba(183, 121, 31, 0.05);
}

.tier-card.defense {
  border-color: rgba(91, 95, 151, 0.28);
  background: rgba(91, 95, 151, 0.05);
}

.allocation-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
}

.allocation-chip strong {
  font-size: 13px;
}

.allocation-chip.wave-red {
  border-color: rgba(202, 32, 50, 0.32);
  background: rgba(202, 32, 50, 0.06);
}

.allocation-chip.wave-blue {
  border-color: rgba(23, 114, 198, 0.32);
  background: rgba(23, 114, 198, 0.06);
}

.allocation-chip.wave-green {
  border-color: rgba(35, 139, 69, 0.32);
  background: rgba(35, 139, 69, 0.06);
}

textarea {
  width: 100%;
  min-height: 310px;
  margin-top: 12px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 14px;
}

.data-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.data-panel h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.data-note {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
}

.data-item {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.data-num {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 800;
}

.data-meta,
.data-money {
  color: var(--muted);
  font-size: 12px;
}

.data-money {
  color: var(--text);
}

.wave-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.summary-box {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 10px;
  border-radius: 7px;
  color: #fff;
}

.summary-box.red {
  background: var(--red);
}

.summary-box.blue {
  background: var(--blue);
}

.summary-box.green {
  background: var(--green);
}

.summary-box strong {
  font-size: 18px;
}

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  justify-content: space-between;
  min-height: 24px;
  padding-top: 10px;
}

#noticeText {
  color: var(--teal);
  font-weight: 700;
}

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

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

@media (max-width: 720px) {
  .app {
    display: block;
    padding: 10px;
  }

  .brand {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-bottom: 10px;
    padding: 12px;
  }

  .brand h1 {
    font-size: 22px;
  }

  .version-badge {
    display: none;
  }

  .panel,
  .filters,
  .result-area,
  .toolbar {
    border-radius: 8px;
    box-shadow: var(--shadow-tight);
  }

  .panel,
  .result-area,
  .filters,
  .toolbar {
    padding: 8px;
  }

  .work {
    gap: 10px;
    margin-top: 10px;
  }

  .toolbar {
    gap: 6px;
    padding: 8px;
  }

  .toolbar label:has(#groupCount),
  .toolbar label:has(#budgetRange),
  .toolbar label:has(#oddsAmount) {
    width: 74px;
  }

  .toolbar label:has(#budgetAmount) {
    width: 112px;
  }

  .toolbar label:has(#separators) {
    width: 116px;
  }

  .toolbar input {
    height: 31px;
    padding: 0 7px;
    font-size: 12px;
  }

  .filter-top {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
  }

  .filter-top .filter-inputs {
    min-height: 34px;
    padding: 5px 6px;
  }

  .filter-top .filter-inputs label {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    gap: 5px;
  }

  .filter-top .filter-inputs label span {
    font-size: 12px;
    white-space: nowrap;
  }

  .filter-top .filter-inputs:has(#headDigits) {
    width: auto;
    grid-column: 2;
    grid-row: 1;
  }

  .filter-top .filter-inputs:has(#tailDigits) {
    width: auto;
    grid-column: 2;
    grid-row: 2;
  }

  .filter-inputs input {
    height: 30px;
    padding: 0 7px;
    font-size: 12px;
  }

  .parity-band {
    width: auto;
    grid-column: 1;
    grid-row: 1 / span 2;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, minmax(30px, 1fr));
    gap: 5px;
    padding: 5px;
  }

  .parity-band .check-pill {
    min-height: 30px;
    padding: 0 5px;
    font-size: 12px;
  }

  .filter-bottom {
    grid-template-columns: 1fr;
  }

  .filter-side-stack {
    grid-template-columns: 1fr;
    width: 100%;
    gap: 6px;
  }

  .wave-band,
  .prefix-band {
    min-height: 36px;
    padding: 6px;
  }

  .wave-band .chip-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .prefix-band .chip-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  .wave-band .check-pill,
  .prefix-band .check-pill {
    min-height: 29px;
    padding: 0 4px;
    font-size: 11px;
    gap: 4px;
  }

  .swatch {
    width: 9px;
    height: 9px;
  }

  .zodiac-band {
    grid-template-columns: 1fr;
    min-height: 0;
    padding: 6px;
  }

  .zodiac-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 5px;
  }

  .zodiac-grid .check-pill {
    min-height: 28px;
    padding: 0 4px;
    font-size: 12px;
  }

  .filter-title {
    width: 100%;
    min-width: 0;
  }

  .number-grid {
    gap: 5px;
  }

  .num-btn {
    min-height: 48px;
    padding: 4px 2px;
  }

  .num-main {
    font-size: 16px;
  }

  .num-money {
    min-width: 24px;
    font-size: 9px;
  }

  .result-head {
    align-items: stretch;
    flex-direction: column;
  }

  .logic-note {
    display: block;
    margin: 4px 0 0;
  }

  .result-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

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

  .manual-groups > .manual-profit-panel {
    display: none;
  }

  .mobile-profit-panel {
    display: grid;
    margin-top: 8px;
  }

  .allocation-grid {
    grid-template-columns: repeat(auto-fit, minmax(76px, 1fr));
  }

  .manual-profit-section {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .profit-chips {
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  }

  .profit-chip {
    grid-template-columns: 30px minmax(0, 1fr);
    padding: 5px;
  }

  .profit-num {
    height: 28px;
    font-size: 14px;
  }

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

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

  textarea {
    min-height: 230px;
    font-size: 13px;
  }
}

@media (max-width: 430px) {
  .app {
    padding: 8px;
  }

  .number-actions {
    gap: 6px;
  }

  .number-actions button,
  .result-actions button {
    padding: 0 8px;
  }

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

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

/* Black theme */
body {
  background:
    radial-gradient(circle at 18% -8%, rgba(59, 130, 246, 0.12), transparent 28%),
    radial-gradient(circle at 88% 6%, rgba(45, 212, 191, 0.08), transparent 26%),
    var(--bg);
}

button,
input,
textarea,
.check-pill,
.manual-row,
.profit-chip,
.group-card,
.tier-card,
.allocation-chip,
.data-item {
  background: #111722;
  color: var(--text);
}

button:hover {
  background: #172033;
  border-color: var(--line-strong);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.36);
}

button.primary {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  color: #ffffff;
}

input,
textarea {
  background: #0b1018;
  color: var(--text);
}

input[readonly],
.manual-row input[readonly] {
  background: #161f2c;
  color: #b7c4d6;
}

.brand,
.panel,
.filters,
.result-area,
.toolbar {
  background: linear-gradient(180deg, #121823 0%, #0f141d 100%);
  border-color: #283446;
}

.version-badge {
  border-color: rgba(45, 212, 191, 0.36);
  background: rgba(45, 212, 191, 0.11);
  color: #67e8f9;
}

.logic-note,
#noticeText,
.group-card em,
.tier-card em,
.profit-net {
  color: var(--teal);
}

.num-money {
  background: rgba(238, 244, 255, 0.12);
  color: var(--text);
}

.num-btn.wave-red {
  border-color: rgba(239, 68, 68, 0.46);
  background: rgba(239, 68, 68, 0.09);
}

.num-btn.wave-blue {
  border-color: rgba(96, 165, 250, 0.48);
  background: rgba(96, 165, 250, 0.1);
}

.num-btn.wave-green {
  border-color: rgba(52, 211, 153, 0.48);
  background: rgba(52, 211, 153, 0.1);
}

.num-btn.selected {
  border-color: #f8fafc;
  background: #1d4ed8;
  color: #ffffff;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.72), 0 10px 22px rgba(59, 130, 246, 0.34);
}

.num-btn.selected .num-main {
  color: #ffffff;
}

.num-btn.selected .num-money {
  background: #f8fafc;
  color: #0f172a;
}

.num-btn.selected::before {
  border-color: rgba(255, 255, 255, 0.48);
}

.num-btn.wave-red.selected {
  border-color: #fecaca;
  background: #991b1b;
  box-shadow: inset 0 0 0 3px rgba(254, 202, 202, 0.78), 0 10px 22px rgba(239, 68, 68, 0.34);
}

.num-btn.wave-blue.selected {
  border-color: #bfdbfe;
  background: #1d4ed8;
  box-shadow: inset 0 0 0 3px rgba(191, 219, 254, 0.78), 0 10px 22px rgba(96, 165, 250, 0.34);
}

.num-btn.wave-green.selected {
  border-color: #bbf7d0;
  background: #047857;
  box-shadow: inset 0 0 0 3px rgba(187, 247, 208, 0.78), 0 10px 22px rgba(52, 211, 153, 0.32);
}

.num-btn.blocked {
  opacity: 0.34;
}

.manual-row,
.manual-profit-panel,
.filter-band,
.allocation-panel,
.data-panel {
  border-color: #273346;
  background: #0d131d;
}

.manual-profit-panel,
.allocation-panel,
.data-panel {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.profit-num {
  background: #1b2636;
  color: var(--text);
}

.profit-amount,
.data-meta,
.data-money {
  color: #a9b7ca;
}

.profit-chip.loss {
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

.profit-chip.loss .profit-num,
.check-pill:has(input:checked),
.toolbar input:focus,
.filter-inputs input:focus {
  background: #172033;
}

.profit-chip.loss .profit-net {
  color: #fca5a5;
}

.check-pill {
  border-color: #2a3547;
}

.check-pill:has(input:checked) {
  border-color: #60a5fa;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.28), 0 0 0 2px rgba(96, 165, 250, 0.1);
}

.check-pill.red {
  border-color: rgba(239, 68, 68, 0.46);
}

.check-pill.blue {
  border-color: rgba(96, 165, 250, 0.48);
}

.check-pill.green {
  border-color: rgba(52, 211, 153, 0.48);
}

.group-card,
.tier-card,
.allocation-chip,
.data-item {
  border-color: #283446;
}

.tier-card.main {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(248, 113, 113, 0.34);
}

.tier-card.second {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(251, 191, 36, 0.34);
}

.tier-card.defense {
  background: rgba(129, 140, 248, 0.1);
  border-color: rgba(165, 180, 252, 0.34);
}

.allocation-chip.wave-red {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.42);
}

.allocation-chip.wave-blue {
  background: rgba(96, 165, 250, 0.1);
  border-color: rgba(96, 165, 250, 0.42);
}

.allocation-chip.wave-green {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.42);
}

textarea {
  background: #070b12;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
}

.allocation-panel.marquee-panel {
  margin-top: 10px;
  padding: 0;
  border: 0;
  background: transparent !important;
  box-shadow: none;
  overflow: hidden;
}

.notice-marquee {
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  background: transparent;
}

.notice-marquee span {
  display: inline-block;
  min-width: max-content;
  padding-left: 100%;
  color: #ff3131;
  font-size: 14px;
  font-weight: 900;
  line-height: 28px;
  animation: notice-marquee-scroll 16s linear infinite;
}

@keyframes notice-marquee-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

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

.dialog-card {
  display: grid;
  gap: 14px;
  width: min(100%, 340px);
  padding: 18px;
  border: 1px solid #2f3b4e;
  border-radius: 8px;
  background: #101722;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.48);
}

.dialog-card h3 {
  margin: 0;
  font-size: 18px;
}

.dialog-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.dialog-card input {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  font-weight: 800;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
