:root {
  color-scheme: dark;
  --bg: #090006;
  --bg-2: #15040c;
  --panel: #12050a;
  --panel-2: #1b070d;
  --panel-3: #0b0306;
  --text: #fff8ee;
  --muted: #a99aa1;
  --line: #5a171d;
  --line-soft: rgba(129, 32, 38, 0.52);
  --gold: #f2c94c;
  --gold-soft: rgba(242, 201, 76, 0.16);
  --accent: #33d17a;
  --accent-soft: rgba(51, 209, 122, 0.14);
  --accent-2: #f2c94c;
  --accent-2-soft: rgba(242, 201, 76, 0.16);
  --danger: #ff4d55;
  --danger-soft: rgba(255, 77, 85, 0.16);
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% -8%, rgba(110, 18, 25, 0.36), transparent 34%),
    linear-gradient(180deg, #16030a 0%, var(--bg) 42%, #050003 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

body.dialog-open {
  overflow: hidden;
}

.site-login-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 8%, rgba(242, 201, 76, 0.14), transparent 24%),
    radial-gradient(circle at 12% 18%, rgba(151, 30, 42, 0.34), transparent 36%),
    linear-gradient(145deg, #22060d 0%, #0c0105 48%, #030002 100%);
}

.site-login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.site-login-card {
  position: relative;
  isolation: isolate;
  width: min(520px, 100%);
  overflow: hidden;
  padding: 34px;
  border: 1px solid rgba(242, 201, 76, 0.42);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(41, 8, 15, 0.98), rgba(13, 2, 6, 0.99));
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.site-login-card::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.site-login-glow {
  position: absolute;
  z-index: -1;
  width: 260px;
  height: 260px;
  right: -120px;
  top: -140px;
  border-radius: 50%;
  background: rgba(242, 201, 76, 0.12);
  filter: blur(18px);
}

.site-login-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(242, 201, 76, 0.18);
}

.site-login-logo,
.system-dialog-logo {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border: 1px solid rgba(242, 201, 76, 0.34);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(242, 201, 76, 0.16), rgba(92, 18, 27, 0.22));
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
}

.site-login-logo img,
.system-dialog-logo img {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.site-login-brand p {
  margin: 0 0 5px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.site-login-brand h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(24px, 5vw, 32px);
  letter-spacing: 0.02em;
}

.site-login-intro {
  display: grid;
  gap: 6px;
  margin: 26px 0 20px;
}

.site-login-intro strong {
  color: var(--text);
  font-size: 20px;
}

.site-login-intro span {
  color: var(--muted);
  font-size: 14px;
}

.site-login-form {
  display: grid;
  gap: 16px;
}

.site-login-form label {
  gap: 9px;
  color: #d8c7cb;
  font-size: 14px;
  font-weight: 700;
}

.site-login-form input {
  min-height: 52px;
  border-color: rgba(242, 201, 76, 0.26);
  border-radius: 12px;
  background: rgba(5, 0, 2, 0.72);
  font-size: 16px;
}

.site-login-form input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(242, 201, 76, 0.12);
}

.site-login-message {
  min-height: 22px;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.site-login-message.error {
  color: #ff8d94;
}

.site-login-message.success {
  color: #63e69b;
}

.site-login-submit {
  min-height: 52px;
  border: 1px solid rgba(242, 201, 76, 0.76);
  border-radius: 12px;
  background: linear-gradient(135deg, #f6d65f, #d6a928);
  color: #210b06;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 14px 30px rgba(214, 169, 40, 0.18);
}

.site-login-submit:hover {
  background: linear-gradient(135deg, #ffe27c, #e7bb3b);
}

.site-login-submit:disabled {
  cursor: wait;
  opacity: 0.72;
}

.site-login-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
  color: rgba(255, 248, 238, 0.48);
  font-size: 12px;
}

.site-login-footer span {
  color: var(--accent);
  font-size: 8px;
}

.site-login-footer p {
  margin: 0;
}

.system-dialog {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
}

.system-dialog-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 36%, rgba(116, 21, 31, 0.26), transparent 42%),
    rgba(2, 0, 1, 0.82);
  backdrop-filter: blur(9px);
}

.system-dialog-card {
  position: relative;
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  border: 1px solid rgba(242, 201, 76, 0.38);
  border-radius: 20px;
  background:
    linear-gradient(155deg, rgba(47, 9, 17, 0.99), rgba(13, 2, 6, 0.995) 62%);
  box-shadow:
    0 34px 100px rgba(0, 0, 0, 0.72),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
  animation: system-dialog-in 160ms ease-out;
}

.system-dialog-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.system-dialog-card.tone-danger::before {
  background: linear-gradient(90deg, transparent, var(--danger), transparent);
}

.system-dialog-card.tone-success::before {
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.system-dialog-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 26px;
  border-bottom: 1px solid rgba(242, 201, 76, 0.16);
  background: linear-gradient(90deg, rgba(92, 17, 26, 0.34), transparent);
}

.system-dialog-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
}

.system-dialog-brand div:last-child {
  display: grid;
  gap: 4px;
}

.system-dialog-brand span {
  color: var(--gold);
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.system-dialog-brand small {
  color: var(--muted);
  font-size: 12px;
}

.system-dialog-content {
  padding: 26px 28px 20px;
}

.system-dialog-eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.system-dialog-content h2 {
  margin: 0;
  color: var(--text);
  font-size: clamp(23px, 3.2vw, 30px);
  line-height: 1.25;
}

.system-dialog-body {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.system-dialog-lead {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid rgba(242, 201, 76, 0.2);
  border-radius: 12px;
  background: rgba(242, 201, 76, 0.075);
  color: #fff4df;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.65;
}

.system-dialog-body ul {
  display: grid;
  gap: 11px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.system-dialog-body li {
  position: relative;
  padding-left: 20px;
  color: #c9b9be;
  font-size: 14px;
  line-height: 1.65;
}

.system-dialog-body li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(242, 201, 76, 0.1);
}

.system-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 26px 24px;
}

.system-dialog-actions button {
  min-width: 126px;
  min-height: 46px;
  border-radius: 11px;
  font-weight: 900;
}

.system-dialog-cancel {
  border: 1px solid rgba(255, 248, 238, 0.18);
  background: rgba(255, 255, 255, 0.055);
  color: #e8dce0;
}

.system-dialog-confirm {
  border: 1px solid rgba(242, 201, 76, 0.72);
  background: linear-gradient(135deg, #f6d65f, #d6a928);
  color: #210b06;
}

.tone-danger .system-dialog-confirm {
  border-color: rgba(255, 106, 113, 0.74);
  background: linear-gradient(135deg, #ff6b73, #d73540);
  color: #fff8f8;
}

.tone-success .system-dialog-confirm {
  border-color: rgba(99, 230, 155, 0.72);
  background: linear-gradient(135deg, #63e69b, #27ad68);
  color: #04190d;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1720px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 12px 0 46px;
  display: flex;
  flex-direction: column;
}

.topbar {
  order: 1;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 24px;
  margin-bottom: 10px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #130207 0%, #070003 100%);
  box-shadow: inset 0 -1px 0 rgba(255, 77, 85, 0.12), var(--shadow);
}

.topbar::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: -1px -1px auto;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(227, 64, 88, 0.65) 8%,
    #ff4d6a 50%,
    rgba(227, 64, 88, 0.65) 92%,
    transparent 100%
  );
  box-shadow: 0 0 12px rgba(227, 64, 88, 0.45);
  pointer-events: none;
}

.brand-mark {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.topbar-title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100% - 520px));
  text-align: center;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: center;
}

.top-action,
.start-action,
.stop-action,
.back-action {
  align-self: center;
  min-width: 120px;
}

.back-action {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: #3b0f14;
  color: var(--text);
}

.back-action:hover {
  background: #52151a;
}

.stop-action {
  min-width: 74px;
  background: var(--danger);
  color: #1f0707;
}

.start-action {
  min-width: 74px;
  background: var(--accent);
  color: #03140a;
}

.start-action:hover {
  background: #63e69b;
}

.stop-action:hover {
  background: #ff7d7d;
}

.run-status {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  min-width: 128px;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #16050b;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.run-status span {
  line-height: 1.1;
}

.run-status small {
  display: block;
  color: rgba(255, 248, 238, 0.64);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
}

.run-status.active {
  border-color: rgba(51, 209, 122, 0.55);
  background: var(--accent-soft);
  color: var(--accent);
}

.run-status.connected {
  border-color: rgba(242, 201, 76, 0.5);
  background: var(--gold-soft);
  color: var(--gold);
  cursor: pointer;
}

.run-status:disabled {
  opacity: 1;
  cursor: wait;
}

.login-script-card .forward-head p {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.08;
  letter-spacing: 0;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(242, 201, 76, 0.22);
}

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

.control-band,
.data-band,
.panel,
.metric-grid article {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.control-band {
  order: 7;
  display: grid;
  grid-template-columns: 170px repeat(4, minmax(120px, 1fr)) 190px 150px 150px;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, #16050b 0%, #0d0306 100%);
}

.section-label {
  display: grid;
  align-content: center;
  gap: 4px;
}

.section-label strong {
  font-size: 15px;
  color: var(--gold);
}

.section-label span {
  color: var(--muted);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

.login-page {
  order: 4;
}

.login-control {
  margin-top: 14px;
}

.strategy-band {
  order: 7;
  margin-top: 14px;
}

.url-field {
  grid-column: span 3;
}

.open-platform {
  align-self: end;
  min-width: 130px;
}

.mode-switch {
  display: grid;
  align-content: end;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.mode-switch div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-button {
  background: #2b0b10;
  color: var(--muted);
  border: 1px solid var(--line-soft);
}

.mode-button.active {
  background: var(--gold);
  color: #170906;
}

.mode-button.danger.active {
  background: var(--danger);
  color: #1a0707;
  box-shadow: 0 0 0 3px var(--danger-soft);
}

label {
  position: relative;
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

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

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

.suffix {
  position: absolute;
  right: 12px;
  bottom: 11px;
  color: var(--muted);
}

.checkbox-label {
  align-content: end;
  grid-template-columns: 20px 1fr;
  gap: 9px;
  min-height: 58px;
}

.checkbox-label input {
  min-height: 20px;
  width: 20px;
  accent-color: var(--gold);
  align-self: center;
}

.data-band {
  order: 7;
  margin-top: 14px;
  border-radius: 8px;
}

.forward-band {
  order: 6;
  margin-top: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-script-card textarea {
  min-height: 300px;
}

.login-script-card .forward-actions button {
  min-width: 150px;
}

.choice-url-field {
  display: grid;
  gap: 8px;
  margin: 18px 18px 0;
  color: var(--muted);
  font-size: 13px;
}

.choice-url-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090205;
  color: var(--text);
  padding: 0 12px;
  outline: none;
  font-size: 14px;
}

.choice-url-field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.forward-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  flex-wrap: wrap;
}

.forward-head > div:first-child {
  min-width: 160px;
}

.forward-head h2 {
  margin: 0;
  font-size: 17px;
  white-space: nowrap;
}

.forward-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.forward-actions {
  display: flex;
  gap: 10px;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

textarea {
  width: calc(100% - 36px);
  min-height: 132px;
  margin: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090205;
  color: var(--text);
  padding: 12px;
  resize: vertical;
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

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

.monitor-form {
  display: grid;
  grid-template-columns: minmax(220px, 0.55fr) minmax(260px, 0.75fr) minmax(0, 1fr);
  gap: 14px;
  padding: 18px;
  align-items: end;
}

.monitor-form .forward-result {
  margin: 0;
  align-self: stretch;
}

.forward-result {
  margin: 0 18px 18px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-3);
  color: var(--muted);
  font-size: 13px;
}

.forward-grid {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
}

.forward-grid strong {
  color: var(--text);
}

.forward-grid code {
  color: var(--accent);
  white-space: normal;
  overflow-wrap: anywhere;
}

.upload-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
}

.upload-box h2,
.panel h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.upload-box p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(520px, 100%);
}

.upload-actions input {
  flex: 1;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: linear-gradient(180deg, #48c989 0%, #38b777 100%);
  color: #07120d;
  font-weight: 700;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  background: #54c894;
}

.secondary-action {
  background: #3b0f14;
  color: var(--text);
}

.secondary-action:hover {
  background: #52151a;
}

.danger-action {
  background: var(--danger);
  color: #210808;
}

.danger-action:hover {
  background: #ff7d7d;
}

.metric-grid,
.sub-metric-grid,
.platform-grid {
  display: grid;
  gap: 10px;
  margin: 10px 0;
}

.metric-grid {
  order: 3;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
}

.sub-metric-grid {
  order: 4;
  grid-template-columns: repeat(7, minmax(116px, 1fr));
  margin-top: 0;
}

.platform-grid {
  order: 5;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-top: 0;
}

.metric-grid article,
.sub-metric-grid article,
.platform-grid article {
  min-height: 82px;
  border-radius: 8px;
  padding: 14px;
}

.metric-grid article {
  min-height: 104px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1a060c 0%, #0b0205 100%);
}

.sub-metric-grid article {
  min-height: 64px;
  border: 1px solid var(--line);
  background: #11050a;
}

.platform-grid article {
  min-height: 74px;
  border: 1px solid var(--line);
  background: #100409;
}

.metric-grid span,
.sub-metric-grid span,
.platform-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.metric-grid strong,
.sub-metric-grid strong,
.platform-grid strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(26px, 2.35vw, 38px);
  line-height: 1;
  letter-spacing: 0;
  color: var(--gold);
}

body[data-run-mode="live"] .metric-grid article {
  border-color: rgba(255, 77, 85, 0.5);
}

body[data-run-mode="live"] .mode-button.danger.active {
  background: var(--danger);
}

.sub-metric-grid strong {
  margin-top: 7px;
  font-size: 18px;
}

.platform-grid strong {
  margin-top: 8px;
  font-size: 22px;
}

.secondary-only strong {
  color: var(--muted);
}

.workspace {
  order: 6;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(300px, 1fr);
  align-items: stretch;
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  border-radius: 8px;
  overflow: hidden;
}

.table-panel {
  grid-column: 1;
  grid-row: 1;
}

.recent-panel {
  grid-column: 2;
  grid-row: 1;
  /* flex 纵向列 + 事件框 flex-basis:0：事件框不参与撑高，让【左边桌台的自然高度】
     决定整行高度（桌台 15 行到底、不留空白），事件框缩到同高、内部滚动。 */
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.recent-panel > .panel-head {
  flex: 0 0 auto;
}

.period-panel,
.panel.wide {
  grid-column: 1 / -1;
}

.snapshot-panel {
  display: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #240a10 0%, var(--panel-2) 100%);
}

.panel h2 {
  color: #ff7278;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-weight: 650;
  background: #18060b;
}

td {
  color: #e9edf2;
}

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

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

/* 结算文字颜色（中式惯例）：赢=红、输=绿、和局/其它=白 */
.recent-panel .event-row > b.settle-win {
  color: var(--danger);
}
.recent-panel .event-row > b.settle-lose {
  color: var(--accent);
}
.recent-panel .event-row > b.settle-tie {
  color: var(--text);
}

.state-list,
.event-list,
.audit-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.state-list {
  grid-template-columns: repeat(var(--table-columns, 3), minmax(0, 1fr));
  align-items: start;
  gap: 12px;
}

.recent-panel .event-list {
  /* flex:1 1 0 —— basis:0 让事件框不参与撑高（否则 48 行会把整行拉高、左边桌台留空白），
     再 flex-grow 吃满 recent-panel 里标题之外的高度 = 左边桌台自然高度，内容超出内部滚动。 */
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
  align-content: start;
  overscroll-behavior: contain;
}

.table-column {
  min-width: 0;
}

.table-column h3 {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #18060b;
  color: var(--gold);
  font-size: 14px;
  letter-spacing: 0;
}

.table-column > div {
  display: grid;
  gap: 8px;
}

.state-row,
.event-row {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e0307;
}

.state-row {
  grid-template-columns: minmax(66px, 0.8fr) minmax(82px, 1fr) 56px;
  align-items: center;
}

.state-row div,
.event-row div {
  display: grid;
  gap: 4px;
}

.state-row .count-stack {
  min-width: 82px;
  justify-items: start;
}

.state-row strong,
.event-row strong {
  font-size: 15px;
}

.state-row .true-count {
  color: var(--text);
  font-size: 15px;
  line-height: 1.2;
}

.state-row .true-count.positive {
  color: var(--accent);
}

.state-row .true-count.negative {
  color: var(--danger);
}

.state-row span,
.event-row span,
.event-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.signal-on,
.signal-off,
.signal-near {
  min-width: 48px;
  text-align: center;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 12px;
}

.signal-on {
  color: #111317;
  background: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-2-soft);
}

.signal-off {
  color: var(--muted);
  background: #2b0b10;
}

.signal-near {
  color: #241807;
  background: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-2-soft);
}

.event-row {
  grid-template-columns: 104px 1fr auto;
  align-items: center;
}

.recent-panel .event-row {
  grid-template-columns: minmax(72px, 0.72fr) minmax(0, 1fr);
  align-items: start;
  gap: 8px 12px;
}

.recent-panel .event-row > div,
.recent-panel .event-row > p,
.recent-panel .event-row > b {
  min-width: 0;
}

.recent-panel .event-row > b {
  grid-column: 2;
  justify-self: start;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}

.recent-panel .event-row > p {
  overflow-wrap: anywhere;
}

.discovery-row {
  grid-template-columns: 96px 1fr auto;
}

.event-row b {
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.ledger-card {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(59, 16, 22, 0.86), rgba(14, 3, 7, 0.96));
}

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

.ledger-card h3 {
  margin: 0;
  font-size: 14px;
  color: var(--accent-2);
}

.ledger-card span,
.ledger-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.ledger-card strong {
  color: var(--gold);
}

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

.ledger-grid div {
  min-width: 0;
}

.ledger-grid b {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.audit-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e0307;
}

.audit-row > span {
  color: var(--accent-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.audit-row strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
}

.audit-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.empty-row {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #0b0306;
  font-size: 13px;
}

@media (max-width: 1180px) {
  .control-band,
  .metric-grid,
  .sub-metric-grid,
  .platform-grid {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
  }

  .section-label {
    grid-column: 1 / -1;
  }

  .url-field {
    grid-column: span 2;
  }

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

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

  .state-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-panel,
  .recent-panel,
  .period-panel,
  .panel.wide {
    grid-column: auto;
    grid-row: auto;
  }

  .recent-panel {
    display: block;
  }

  .recent-panel .event-list {
    flex: none;
    min-height: 360px;
    max-height: 62vh;
    overflow: auto;
  }
}

@media (max-width: 760px) {
  .site-login-shell {
    align-items: center;
    padding: 16px 12px;
  }

  .site-login-card {
    padding: 24px 20px;
    border-radius: 18px;
  }

  .site-login-logo {
    width: 58px;
    height: 58px;
    border-radius: 15px;
  }

  .site-login-brand {
    gap: 12px;
    padding-bottom: 20px;
  }

  .site-login-brand h1 {
    font-size: 24px;
  }

  .system-dialog {
    align-items: end;
    padding: 12px;
  }

  .system-dialog-card {
    width: 100%;
    max-height: calc(100vh - 24px);
    border-radius: 18px;
  }

  .system-dialog-brand {
    padding: 18px 20px;
  }

  .system-dialog-logo {
    width: 50px;
    height: 50px;
  }

  .system-dialog-content {
    padding: 22px 20px 16px;
  }

  .system-dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 16px 20px 20px;
  }

  .system-dialog-actions button {
    min-width: 0;
  }

  .app-shell {
    width: min(100vw - 24px, 1520px);
    padding-top: 4px;
  }

  .topbar,
  .topbar-actions,
  .upload-box,
  .upload-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-title {
    position: static;
    transform: none;
    width: auto;
    text-align: left;
  }

  .brand-mark {
    position: static;
    transform: none;
    width: 48px;
    height: 48px;
  }

  .back-action {
    position: static;
    transform: none;
  }

  .control-band,
  .metric-grid,
  .sub-metric-grid,
  .platform-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .url-field {
    grid-column: 1 / -1;
  }

  .metric-grid article {
    min-height: 92px;
  }

  .state-row,
  .event-row,
  .audit-row {
    grid-template-columns: 1fr;
  }

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

  .recent-panel .event-list {
    min-height: 420px;
    max-height: 58vh;
    padding: 12px;
  }

  .secondary-only {
    display: none;
  }
}

/* 桌台选择勾选框：默认全选，取消后该桌不参与监控与下注 */
.table-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.table-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.table-id-line {
  display: flex;
  align-items: center;
  gap: 7px;
}

.table-column h3 .group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.state-row.table-disabled {
  opacity: 0.45;
  filter: grayscale(0.7);
}

/* 下注时间线：临时信号行（等开盘/待下注）虚线+淡化，与已下注行区分 */
.event-row.signal-row {
  border-style: dashed;
  opacity: 0.72;
}

/* 策略设置保存按钮 */
.save-settings-btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #d4a017, #b8860b);
  color: #1a1206;
  font-weight: 700;
  font-size: 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s;
}
.save-settings-btn:hover { filter: brightness(1.1); }
.save-settings-btn:disabled { opacity: 0.6; cursor: default; }
