:root {
  --paper: #fff8dc;
  --surface: #fffdf4;
  --ink: #201a16;
  --muted: #6c6257;
  --line: #e6d9b8;
  --yellow: #ffd339;
  --yellow-deep: #e5a900;
  --red: #d92027;
  --green: #11795b;
  --blue: #1e5f9f;
  --shadow: 0 18px 44px rgba(53, 41, 18, 0.12);
  font-family: "Noto Sans TC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(201, 34, 39, 0.08) 0 1px, transparent 1px 34px),
    linear-gradient(180deg, #fff7cd 0%, #f7ead0 46%, #f4efe3 100%);
  color: var(--ink);
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding: 10px 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 68px);
  line-height: 0.95;
  max-width: 820px;
}

.subtitle {
  color: var(--muted);
  max-width: 720px;
  margin-top: 12px;
  font-size: 16px;
}

.sync-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-dot::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b6aa90;
}

.status-dot.online::before {
  background: var(--green);
}

.status-dot.error::before {
  background: var(--red);
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) minmax(520px, 1.45fr);
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.control-panel,
.content-panel {
  background: rgba(255, 253, 244, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
  min-height: 118px;
  border-radius: 8px;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1;
}

.jackpot-card strong {
  font-size: clamp(32px, 3.8vw, 54px);
  white-space: nowrap;
}

.experiment-card {
  display: grid;
  gap: 14px;
}

.experiment-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.metric-filter {
  display: grid;
  gap: 6px;
  min-width: 190px;
}

.metric-filter span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-filter select {
  width: 100%;
  min-height: 38px;
}

.experiment-metrics {
  display: grid;
  grid-template-columns: 0.8fr 1fr 1.25fr;
  gap: 14px;
}

.experiment-metrics > div {
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

.experiment-metrics > div:first-child {
  border-left: 0;
  padding-left: 0;
}

.experiment-metrics strong {
  font-size: clamp(24px, 2.4vw, 38px);
}

.experiment-metrics small {
  line-height: 1.45;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.content-panel {
  border-radius: 8px;
}

.control-panel {
  padding: 18px;
  position: sticky;
  top: 16px;
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head h2,
.section-head h2 {
  font-size: 22px;
}

.panel-head p,
.section-head p,
.table-toolbar p,
.generated-toolbar p {
  color: var(--muted);
  margin-top: 5px;
  font-size: 14px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field span {
  font-weight: 700;
  font-size: 13px;
}

select,
input[type="number"] {
  width: 100%;
  border: 1px solid #cbbd9d;
  background: #fff;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--ink);
}

.strategy-explain {
  border: 1px solid var(--line);
  background: #fffaf0;
  border-radius: 6px;
  padding: 12px;
  margin: -2px 0 14px;
}

.strategy-explain strong {
  display: block;
  font-size: 15px;
}

.strategy-explain p {
  margin: 6px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.strategy-explain dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 10px;
  margin: 0;
  font-size: 12px;
}

.strategy-explain dt {
  color: var(--muted);
}

.strategy-explain dd {
  margin: 0;
  font-weight: 900;
}

.package-panel {
  border: 1px solid var(--line);
  background: #fffaf0;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 14px;
}

.package-panel.disabled {
  opacity: 0.58;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  margin-bottom: 10px;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.package-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.package-fields .field {
  margin-bottom: 0;
}

.package-summary {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

input[type="range"] {
  accent-color: var(--red);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.primary-btn,
.secondary-btn,
.wide-btn,
.icon-btn,
.danger-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 800;
}

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

.secondary-btn,
.icon-btn {
  background: #fff;
  border-color: #cbbd9d;
  color: var(--ink);
}

.wide-btn {
  width: 100%;
  margin-top: 10px;
  background: var(--yellow);
  border-color: var(--yellow-deep);
  color: var(--ink);
}

.cold-quick-btn {
  background: #201a16;
  border-color: #201a16;
  color: #fff;
}

.danger-btn {
  background: #fff3f1;
  border-color: #f0b5ad;
  color: #a51f25;
}

.risk-note {
  border-left: 4px solid var(--red);
  padding: 10px 0 10px 12px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.content-panel {
  min-height: 760px;
  overflow: hidden;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.data-badge {
  align-self: start;
  background: #201a16;
  color: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 14px 18px;
  font-weight: 800;
  color: var(--muted);
}

.tab.active {
  color: var(--ink);
  background: var(--yellow);
}

.tab-panel {
  display: none;
  padding: 20px;
}

.tab-panel.active {
  display: block;
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.insight-strip div {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 13px;
}

.insight-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.insight-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.sequence-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.sequence-panel article {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 13px;
  min-height: 104px;
}

.sequence-panel span,
.sequence-panel small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.sequence-panel strong {
  display: block;
  margin: 6px 0;
  font-size: 18px;
  line-height: 1.25;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px;
}

.number-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
}

.number-cell {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 11px;
  min-height: 118px;
  display: grid;
  gap: 9px;
  position: relative;
  overflow: hidden;
}

.number-cell::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: var(--heat, 0%);
  background: linear-gradient(0deg, rgba(217, 32, 39, 0.18), rgba(255, 211, 57, 0.12));
  pointer-events: none;
}

.number-top,
.ticket-top,
.record-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: relative;
}

.num-token,
.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid #111;
  font-weight: 900;
}

.num-token.secondary,
.ball.secondary {
  background: var(--red);
  color: #fff;
  border-color: #7a1115;
}

.score {
  font-size: 12px;
  color: var(--muted);
}

.number-cell dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  margin: 0;
  position: relative;
  font-size: 12px;
}

.number-cell dt {
  color: var(--muted);
}

.number-cell dd {
  margin: 0;
  font-weight: 800;
}

.secondary-wrap {
  margin-top: 22px;
}

.secondary-wrap h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

.generated-toolbar,
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.inline-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  white-space: nowrap;
}

.inline-filter span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inline-filter select {
  width: 160px;
  min-height: 38px;
}

.ticket-list,
.records-list,
.strategy-grid {
  display: grid;
  gap: 12px;
}

.ticket-card,
.record-card,
.strategy-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 14px;
}

.ticket-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.ticket-meta,
.record-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.reason-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.reason-list span,
.record-status {
  border-radius: 999px;
  padding: 5px 8px;
  background: #f5eed8;
  font-size: 12px;
  color: #554a3b;
}

.record-status.win {
  background: #e3f5ec;
  color: var(--green);
}

.record-status.pending {
  background: #fff0bd;
  color: #765600;
}

.record-status.miss {
  background: #f5eeee;
  color: #8b2f35;
}

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

.strategy-card strong {
  display: block;
  font-size: 20px;
  margin: 8px 0;
}

.strategy-card dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 10px;
  margin: 0;
  font-size: 13px;
}

.strategy-card dt {
  color: var(--muted);
}

.strategy-card dd {
  margin: 0;
  font-weight: 800;
}

.empty-state {
  border: 1px dashed #cbbd9d;
  border-radius: 8px;
  padding: 26px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .experiment-card {
    grid-column: 1 / -1;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }
}

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

  .topbar,
  .section-head,
  .generated-toolbar,
  .table-toolbar {
    display: grid;
  }

  .inline-filter {
    margin-left: 0;
    justify-content: space-between;
  }

  .inline-filter select {
    width: min(220px, 100%);
  }

  .summary-grid,
  .insight-strip,
  .sequence-panel {
    grid-template-columns: 1fr;
  }

  .experiment-head,
  .experiment-metrics {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metric-filter {
    min-width: 0;
  }

  .experiment-metrics > div {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 12px;
  }

  .experiment-metrics > div:first-child {
    border-top: 0;
    padding-top: 0;
  }

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

  .package-fields {
    grid-template-columns: 1fr;
  }
}
