:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --text: #17211c;
  --muted: #68746e;
  --line: #d9e0dc;
  --green: #0f766e;
  --green-dark: #0b5f59;
  --mint: #dff3ee;
  --gold: #b7791f;
  --gold-soft: #fff4d8;
  --red: #d40000;
  --red-soft: #ffe0dc;
  --blue: #2563eb;
  --shadow: 0 16px 40px rgba(26, 38, 32, 0.08);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

.daily-panel {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

textarea {
  font: inherit;
}

.app-shell {
  width: min(1880px, calc(100vw - 20px));
  margin: 0 auto;
  padding: 16px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
  letter-spacing: 0;
}

.file-button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.file-button,
.primary-button {
  background: var(--green);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.2);
}

.file-button:hover,
.primary-button:hover:not(:disabled) {
  background: var(--green-dark);
}

.ghost-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.ghost-button:hover:not(:disabled) {
  border-color: #b9c7c0;
}

#ratioToggle[aria-pressed="true"] {
  border-color: #9fd6cd;
  background: var(--mint);
  color: var(--green-dark);
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.file-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(280px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 38px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input[type="search"],
input[type="text"] {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input[type="date"] {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input:disabled,
textarea:disabled {
  background: #f0f2f1;
  color: #8c9691;
}

select:disabled {
  background: #f0f2f1;
  color: #8c9691;
}

.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.filter-band {
  display: grid;
  grid-template-columns: minmax(260px, 25%) auto 1fr;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 14px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #98a39e;
  flex: 0 0 auto;
}

.status-line.good {
  background: var(--mint);
  border-color: #b9dfd6;
  color: var(--green-dark);
}

.status-line.good .status-dot {
  background: var(--green);
}

.status-line.warn {
  background: var(--gold-soft);
  border-color: #f3d58b;
  color: #7a4a0a;
}

.status-line.warn .status-dot {
  background: var(--gold);
}

.status-line.bad {
  background: var(--red-soft);
  border-color: #f7bbb7;
  color: var(--red);
}

.status-line.bad .status-dot {
  background: var(--red);
}

.member-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  margin: -4px 0 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.member-status-line.good {
  background: var(--mint);
  border-color: #b9dfd6;
  color: var(--green-dark);
}

.member-status-line.good .status-dot {
  background: var(--green);
}

.member-status-line.warn {
  background: var(--gold-soft);
  border-color: #f3d58b;
  color: #7a4a0a;
}

.member-status-line.warn .status-dot {
  background: var(--gold);
}

.member-status-line.bad {
  background: var(--red-soft);
  border-color: #f7bbb7;
  color: var(--red);
}

.member-status-line.bad .status-dot {
  background: var(--red);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1.05;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.metric.primary {
  background: #10241f;
  color: #fff;
}

.metric.primary span {
  color: #bfe0d7;
}

.work-area {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.55fr);
  gap: 12px;
  margin-top: 12px;
}

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

.history-filter-band {
  grid-column: 1 / -1;
  grid-row: 2;
  margin-top: 0;
}

.bill-history-panel {
  grid-column: 1 / -1;
  grid-row: 3;
  margin-top: 0;
}

.detail-panel {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 12px;
  margin-top: 12px;
}

.analytics-grid.secondary {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
}

.panel,
.history-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-actions select {
  min-height: 34px;
  width: 112px;
  padding-left: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 210px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: text;
}

.badge.muted {
  background: #edf0ee;
  color: var(--muted);
}

.badge.bill-state {
  border: 1px solid transparent;
}

.badge.bill-state.paid,
.bill-status.paid {
  background: #dff3ee;
  color: #0b5f59;
  border-color: #a6d9ce;
}

.badge.bill-state.pending,
.bill-status.pending {
  background: #fff4d8;
  color: #8a560f;
  border-color: #f0cf80;
}

.badge.bill-state.settled,
.bill-status.settled {
  background: #e9efff;
  color: #1d4ed8;
  border-color: #bac9ff;
}

.badge.bill-state.bad,
.bill-status.bad {
  background: #fde7e5;
  color: #b42318;
  border-color: #f3b3ae;
}

.badge.bill-state.neutral,
.bill-status.neutral {
  background: #edf0ee;
  color: var(--muted);
  border-color: #d8dfdb;
}

.formula-stack {
  display: grid;
  gap: 8px;
}

.formula-block {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.formula-block.total {
  border-color: #b9dfd6;
  background: #f2fbf8;
}

.formula-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.formula-title span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.formula-title strong {
  font-size: 22px;
  line-height: 1.1;
}

.formula-block p {
  margin-top: 6px;
  color: #35423c;
  font-family:
    "Cascadia Mono",
    Consolas,
    "Microsoft YaHei",
    monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.formula-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

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

.formula-field {
  min-height: 46px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.formula-field.range-warn {
  border-color: #f0c76a;
  background: #fff8e5;
  box-shadow: inset 0 0 0 1px rgba(183, 121, 31, 0.12);
}

.formula-field.range-bad {
  border-color: #efaaa4;
  background: #fff2f1;
  box-shadow: inset 0 0 0 1px rgba(180, 35, 24, 0.12);
}

.formula-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.formula-field strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.formula-field .field-hint {
  display: block;
  margin-top: 5px;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}

.formula-field.range-warn strong {
  color: #8a5208;
}

.formula-field.range-bad strong {
  color: var(--red);
}

.formula-field em {
  display: none;
  margin-top: 6px;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.25;
}

.formula-panel.show-ratios .formula-field em {
  display: block;
}

.formula-field em.field-meta {
  color: var(--muted);
  font-weight: 700;
}

.formula-field em.field-warning {
  color: #7a4a0a;
}

.formula-field.range-bad em.field-warning {
  color: var(--red);
}

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

.detail-list div {
  min-height: 54px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-list dd {
  margin: 5px 0 0;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.alert-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.alert {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.alert.good {
  background: var(--mint);
  color: var(--green-dark);
}

.alert.warn {
  background: var(--gold-soft);
  color: #7a4a0a;
}

.alert.bad {
  background: var(--red-soft);
  color: var(--red);
}

.commission-guide {
  margin-top: 10px;
  max-height: 260px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid #bde3da;
  border-radius: 8px;
  background: #eefaf6;
  color: var(--green-dark);
}

.commission-guide h3 {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.25;
}

.commission-guide ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.commission-guide li {
  font-size: 13px;
  line-height: 1.45;
}

.member-guide {
  margin: -4px 0 10px;
  max-height: 160px;
}

.reply-panel textarea,
.note-panel textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
  color: var(--text);
  line-height: 1.55;
}

.note-panel textarea {
  min-height: 118px;
}

.comparison-list,
.month-summary {
  display: grid;
  gap: 10px;
}

.comparison-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(90px, auto) minmax(90px, auto);
  gap: 12px;
  align-items: center;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

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

.comparison-row strong,
.comparison-row em {
  text-align: right;
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.comparison-row em.up {
  color: var(--green-dark);
}

.comparison-row em.down {
  color: var(--red);
}

.comparison-row em.flat {
  color: var(--muted);
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.mini-metric {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

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

.mini-metric strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.month-lines {
  display: grid;
  gap: 8px;
}

.month-lines div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

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

.month-lines strong {
  text-align: right;
  font-size: 13px;
}

.empty-block {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 14px;
}

.history-panel {
  margin-top: 12px;
  padding: 14px;
}

.bill-history-panel {
  margin-top: 0;
}

.member-panel {
  margin-bottom: 8px;
}

.member-import-button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 800;
}

.member-controls {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(260px, 1fr) minmax(150px, 220px);
  gap: 8px;
  margin-bottom: 8px;
}

.member-summary {
  margin-bottom: 8px;
}

.member-mini-metrics {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  background: #fff;
}

.bill-history-panel table {
  --history-agent-col: 92px;
  --history-bill-col: 92px;
  --history-status-col: 96px;
  min-width: 1840px;
  table-layout: auto;
}

.bill-history-panel .table-wrap {
  max-height: min(82vh, 880px);
  overflow: auto;
  overscroll-behavior: contain;
}

.bill-history-panel th,
.bill-history-panel td {
  padding: 7px 6px;
  font-size: 12px;
  user-select: text;
}

.bill-history-panel th button {
  user-select: none;
}

.bill-history-panel td {
  overflow: visible;
  text-overflow: clip;
}

.bill-history-panel th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f7faf8;
  box-shadow: 0 1px 0 var(--line);
  height: 42px;
  line-height: 1.15;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  vertical-align: middle;
}

.bill-history-panel th button[data-history-sort] {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  cursor: pointer;
  white-space: normal;
}

.bill-history-panel th.num button[data-history-sort] {
  justify-content: flex-end;
  text-align: right;
}

.bill-history-panel th button[data-history-sort]::after {
  content: attr(data-sort-mark);
  color: var(--green-dark);
  font-weight: 900;
  white-space: pre;
}

.bill-history-panel th button[data-history-sort]:hover,
.bill-history-panel th button[data-history-sort].active {
  color: var(--green-dark);
}

.bill-history-panel th:nth-child(1),
.bill-history-panel td:nth-child(1) {
  position: sticky;
  left: 0;
  width: var(--history-agent-col);
  min-width: var(--history-agent-col);
  max-width: var(--history-agent-col);
}

.bill-history-panel th:nth-child(2),
.bill-history-panel td:nth-child(2) {
  position: sticky;
  left: var(--history-agent-col);
  width: var(--history-bill-col);
  min-width: var(--history-bill-col);
  max-width: var(--history-bill-col);
}

.bill-history-panel th:nth-child(3),
.bill-history-panel td:nth-child(3) {
  position: sticky;
  left: calc(var(--history-agent-col) + var(--history-bill-col));
  width: var(--history-status-col);
  min-width: var(--history-status-col);
  max-width: var(--history-status-col);
}

.bill-history-panel th:nth-child(-n + 3) {
  z-index: 6;
}

.bill-history-panel tbody td:nth-child(-n + 3) {
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.bill-history-panel tbody tr:hover td:nth-child(-n + 3),
.bill-history-panel tbody tr.selected td:nth-child(-n + 3) {
  background: #edf8f5;
}

.bill-history-panel tbody tr.history-total-row td:nth-child(-n + 3) {
  background: #edf7f3;
}

.bill-history-panel .bill-status {
  min-width: 52px;
  min-height: 24px;
  padding: 0 6px;
  font-size: 12px;
}

.bill-history-panel .anomaly-pill,
.bill-history-panel .note-mark {
  min-height: 22px;
  padding: 0 7px;
}

.history-total-row td {
  background: #edf7f3;
  border-bottom-color: #b8ded5;
  font-weight: 800;
}

.history-total-row td:first-child {
  color: var(--green-dark);
}

.member-total-row td {
  background: #edf7f3;
  border-bottom-color: #b8ded5;
  font-weight: 800;
  cursor: default;
}

.member-total-row td:first-child {
  color: var(--green-dark);
}

.member-table {
  --member-status-col: 72px;
  --member-id-col: 96px;
  min-width: 2860px;
  table-layout: fixed;
}

.member-col-id {
  width: var(--member-id-col);
}

.member-col-account {
  width: 150px;
}

.member-col-nick {
  width: 150px;
}

.member-col-agent {
  width: 120px;
}

.member-col-status {
  width: var(--member-status-col);
}

.member-col-parents {
  width: 168px;
}

.member-col-money {
  width: 100px;
}

.member-col-money-wide {
  width: 128px;
}

.member-col-time {
  width: 118px;
}

.member-col-remark {
  width: 118px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bill-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.anomaly-pill,
.note-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.anomaly-pill.ok {
  background: #edf0ee;
  color: var(--muted);
}

.anomaly-pill.warn {
  background: var(--red-soft);
  color: var(--red);
}

.note-mark {
  background: #e9efff;
  color: #1d4ed8;
}

.muted-text {
  color: var(--muted);
}

.anomaly-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 180px;
}

.anomaly-more {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf0ee;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7faf8;
  color: var(--muted);
  font-size: 12px;
}

th button[data-member-sort] {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 24px;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}

th.num button[data-member-sort] {
  justify-content: flex-end;
  text-align: right;
}

.member-table-wrap {
  max-height: min(76vh, 760px);
  overscroll-behavior: contain;
}

.member-table th {
  z-index: 3;
  height: 32px;
  line-height: 1.15;
  white-space: normal;
  vertical-align: middle;
}

.member-table th,
.member-table td {
  padding: 4px 5px;
  font-size: 11px;
}

.member-table th.num,
.member-table td.num {
  overflow: visible;
  text-overflow: clip;
}

.member-table th:first-child,
.member-table td:first-child {
  position: sticky;
  left: 0;
  width: var(--member-status-col);
  min-width: var(--member-status-col);
  max-width: var(--member-status-col);
}

.member-table th:nth-child(2),
.member-table td:nth-child(2) {
  position: sticky;
  left: var(--member-status-col);
  width: var(--member-id-col);
  min-width: var(--member-id-col);
  max-width: var(--member-id-col);
}

.member-table th:nth-child(-n + 2) {
  z-index: 7;
}

.member-table tbody td:nth-child(-n + 2) {
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.member-table tbody tr:hover td:nth-child(-n + 2),
.member-table tbody tr.selected td:nth-child(-n + 2) {
  background: #edf8f5;
}

.member-table tbody tr.member-total-row td:nth-child(-n + 2),
.member-table tbody tr.member-total-row:hover td:nth-child(-n + 2) {
  background: #edf7f3;
}

.daily-controls {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(320px, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.daily-config-field textarea {
  width: 100%;
  min-height: 74px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  background: #fff;
  color: var(--text);
}

.daily-table {
  min-width: 1540px;
  table-layout: fixed;
}

.daily-col-channel {
  width: 130px;
}

.daily-col-id {
  width: 110px;
}

.daily-col-level {
  width: 84px;
}

.daily-col-money {
  width: 90px;
}

.daily-col-money-wide {
  width: 116px;
}

.daily-table th,
.daily-table td {
  padding: 6px 7px;
  font-size: 12px;
}

.daily-table th {
  height: 42px;
  line-height: 1.15;
  white-space: normal;
}

.daily-table th.num,
.daily-table td.num {
  overflow: visible;
  text-overflow: clip;
}

.daily-table th button[data-daily-sort] {
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  justify-content: flex-start;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: normal;
}

.daily-table th.num button[data-daily-sort] {
  justify-content: flex-end;
  text-align: right;
}

.daily-missing-row td {
  background: #fff7e8;
}

.strong-num {
  font-weight: 900;
}

.member-parents-cell {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.member-load-row td,
.table-pager-row td {
  padding: 10px;
  text-align: center;
  background: #fbfcfb;
}

.member-load-row button {
  min-width: 260px;
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  white-space: normal;
}

.table-pager > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-pager-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.table-pager-buttons .small-button {
  min-width: 34px;
  min-height: 30px;
  padding: 0 9px;
}

.table-pager-buttons .small-button.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.table-pager-buttons .small-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table-pager-ellipsis {
  color: var(--muted);
  font-weight: 900;
  padding: 0 2px;
}

.member-detail-panel {
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.member-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.member-detail-head span,
.member-detail-item span,
.member-detail-wide span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.member-detail-head strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
  line-height: 1.15;
}

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

.member-detail-grid + .member-detail-grid,
.member-detail-wide {
  margin-top: 6px;
}

.member-detail-item,
.member-detail-wide {
  min-height: 52px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.member-detail-item strong,
.member-detail-wide strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.member-field-hint {
  display: block;
  margin-top: 4px;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

.risk-panel {
  margin-bottom: 8px;
}

.risk-import-button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 800;
}

.risk-controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(150px, 220px) minmax(150px, 240px);
  gap: 8px;
  margin-bottom: 8px;
}

.risk-mini-metrics {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.risk-segment-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.risk-segment-card {
  padding: 10px;
  border: 1px solid #b7e3da;
  border-radius: 8px;
  background: #f2fbf8;
  box-shadow: inset 4px 0 0 var(--green);
}

.risk-segment-card.empty {
  opacity: 0.72;
  background: #fbfcfb;
  box-shadow: inset 4px 0 0 #cbd5d1;
}

.risk-segment-card > div {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.risk-segment-card strong {
  color: var(--green-dark);
  font-size: 15px;
  font-weight: 900;
}

.risk-segment-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.risk-segment-card dl {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
}

.risk-segment-card dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.risk-segment-card dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.risk-high-summary {
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff5f5;
  color: #7f1d1d;
}

.risk-high-summary-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.risk-high-summary-head strong {
  font-size: 14px;
  font-weight: 900;
}

.risk-high-summary-head span {
  color: #991b1b;
  font-size: 12px;
  font-weight: 800;
}

.risk-high-pair-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding-right: 2px;
}

.risk-high-pair-card {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid #fecaca;
  border-radius: 7px;
  background: #fff;
  box-shadow: inset 3px 0 0 #dc2626;
}

.risk-high-pair-ids {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-bottom: 5px;
}

.risk-high-pair-ids strong {
  color: var(--red);
  font-size: 13px;
  font-weight: 900;
}

.risk-high-pair-ids em {
  color: #991b1b;
  font-style: normal;
  font-weight: 900;
}

.risk-high-pair-card span,
.risk-high-pair-more {
  display: inline-block;
  margin-right: 8px;
  color: #7f1d1d;
  font-size: 12px;
  font-weight: 800;
}

.risk-high-pair-more {
  padding: 8px 10px;
  border: 1px dashed #fca5a5;
  border-radius: 7px;
  background: #fff;
}

.risk-selected-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 34px;
  margin: -2px 0 8px;
  padding: 6px 8px;
  border: 1px solid #b7e3da;
  border-radius: 8px;
  background: #eefaf7;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.risk-selected-tags div {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.risk-selected-tags span {
  color: var(--muted);
}

.risk-selected-tags strong {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff;
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px #cfe7e1;
  font-size: 12px;
  font-weight: 900;
}

.risk-selected-tags strong.required {
  color: var(--green-dark);
  background: #fff;
  box-shadow: inset 0 0 0 1px #cfe7e1;
}

.multi-filter {
  position: relative;
}

.multi-filter-button {
  width: 100%;
  min-height: 52px;
  justify-content: space-between;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  box-shadow: none;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}

.multi-filter-button::after {
  content: "";
  width: 0;
  height: 0;
  margin-left: auto;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
}

.multi-filter.disabled .multi-filter-button {
  color: #a3adac;
  cursor: not-allowed;
}

.multi-filter-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  display: none;
  width: min(360px, 92vw);
  max-height: 390px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(10, 35, 32, 0.18);
}

.multi-filter.open .multi-filter-menu {
  display: block;
}

.multi-filter-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #f7faf8;
}

.multi-filter-actions button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
}

.multi-filter-actions button:hover {
  color: var(--green-dark);
  border-color: #9ed8cf;
}

.multi-filter-options {
  max-height: 330px;
  overflow: auto;
  padding: 4px;
}

.multi-filter-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
}

.multi-filter-option:hover {
  background: #edf8f5;
}

.multi-filter-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}

.multi-filter-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.multi-filter-option em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.risk-filter-head {
  overflow: visible;
  padding: 0;
}

.risk-filter-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 2px 0;
}

.risk-header-filter {
  width: 100%;
}

.risk-header-filter .multi-filter-button {
  justify-content: flex-start;
  min-height: 26px;
  padding: 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-header-filter .risk-required-button {
  color: var(--green-dark);
}

.risk-header-filter .multi-filter-button::after {
  flex: 0 0 auto;
  margin-left: 4px;
  border-top-color: var(--green-dark);
}

.risk-header-filter .risk-required-button::after {
  border-top-color: var(--green-dark);
}

.risk-header-filter .multi-filter-menu {
  top: calc(100% + 2px);
  right: 0;
  left: auto;
  width: 310px;
  text-align: left;
}

.risk-header-filter .multi-filter-menu.is-fixed {
  position: fixed;
  right: auto;
  bottom: auto;
  z-index: 1000;
  max-height: var(--risk-menu-max-height, 390px);
}

.risk-header-filter .multi-filter-menu.is-fixed .multi-filter-options {
  max-height: calc(var(--risk-menu-max-height, 390px) - 46px);
}

.risk-table-wrap {
  max-height: min(88vh, 980px);
  overscroll-behavior: contain;
}

.risk-table {
  --risk-time-col: 150px;
  min-width: 1570px;
  table-layout: fixed;
}

.risk-col-time {
  width: var(--risk-time-col);
}

.risk-col-venue {
  width: 110px;
}

.risk-col-game {
  width: 190px;
}

.risk-col-stack {
  width: 130px;
}

.risk-col-money {
  width: 108px;
}

.risk-col-type {
  width: 190px;
}

.risk-col-note {
  width: 210px;
}

.risk-col-operator {
  width: 92px;
}

.risk-table th,
.risk-table td {
  padding: 6px 7px;
  font-size: 12px;
  vertical-align: middle;
}

.risk-table th {
  z-index: 3;
  height: 58px;
  line-height: 1.15;
  white-space: normal;
}

.risk-table th button[data-risk-sort] {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  cursor: pointer;
  white-space: normal;
}

.risk-table th.num button[data-risk-sort] {
  justify-content: flex-end;
  text-align: right;
}

.risk-table th button[data-risk-sort]:hover,
.risk-table th button[data-risk-sort].active {
  color: var(--green-dark);
}

.risk-table th:nth-child(3),
.risk-table td:nth-child(3) {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.risk-table th:first-child,
.risk-table td:first-child {
  position: sticky;
  left: 0;
  width: var(--risk-time-col);
  min-width: var(--risk-time-col);
  max-width: var(--risk-time-col);
}

.risk-table th:first-child {
  z-index: 7;
}

.risk-table tbody td:first-child {
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.risk-table tbody tr:hover td:first-child,
.risk-table tbody tr.selected td:first-child {
  background: #edf8f5;
}

.risk-table tbody tr.member-total-row td:first-child,
.risk-table tbody tr.member-total-row:hover td:first-child {
  background: #edf7f3;
}

.risk-stack-cell {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.risk-stack-cell span {
  display: block;
  min-height: 22px;
  line-height: 22px;
}

.risk-stack-cell span.risk-duplicate-bet {
  color: var(--red);
  font-weight: 900;
}

.risk-stack-cell span.risk-high-player,
.risk-player-detail .risk-high-player {
  color: var(--red);
  font-weight: 900;
}

.risk-suspect-cell,
.risk-type-marked {
  background: #fff1ef;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.risk-suspect-line {
  display: block;
  min-height: 22px;
  line-height: 22px;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.risk-suspect-same-agent {
  color: #1f2937;
}

.risk-suspect-bet-near {
  color: #f97316;
}

.risk-suspect-different-agent-near {
  color: #7c2d12;
  background: #ffedd5;
  border-radius: 5px;
  padding: 0 4px;
}

.risk-suspect-different-agent-high {
  color: #fff;
  background: #b91c1c;
  border-radius: 5px;
  padding: 0 5px;
  box-shadow: inset 0 0 0 1px #7f1d1d;
}

.risk-suspect-cash {
  color: #d00000;
}

.risk-suspect-self {
  color: #b91c1c;
}

.risk-suspect-default {
  color: var(--red);
}

.risk-suspect-muted {
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.risk-high-note {
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fef2f2;
  color: #991b1b;
  font-weight: 900;
}

.risk-note-cell {
  background: #fffdf7;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.risk-note-cell textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 6px 7px;
  border: 1px solid #d7e0dc;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  line-height: 1.25;
  resize: vertical;
}

.risk-note-cell textarea:focus {
  outline: 2px solid #9ed8cf;
  border-color: var(--green);
}

.risk-inferred-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  min-height: 18px;
  margin-left: 5px;
  border-radius: 999px;
  background: #fff2a8;
  color: #7a3b00;
  font-size: 11px;
  font-weight: 900;
}

.risk-infer-note {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #f2d57a;
  border-radius: 8px;
  background: #fff9db;
  color: #7a3b00;
  font-size: 13px;
  font-weight: 800;
}

.risk-total-row td {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.risk-detail-panel {
  background: #fbfcfb;
}

.risk-detail-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.warn-badge {
  background: #fff1ef;
  color: var(--red);
  border-color: #f5b3aa;
}

.risk-player-detail {
  margin-top: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.risk-player-detail table {
  min-width: 640px;
}

.risk-player-detail th,
.risk-player-detail td {
  padding: 7px 8px;
  font-size: 12px;
}

.collusion-panel {
  margin-top: 8px;
}

.collusion-import-button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 800;
}

.collusion-guide {
  max-height: 150px;
}

.collusion-controls {
  grid-template-columns: minmax(240px, 1fr) minmax(150px, 220px);
}

.collusion-mini-metrics {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.collusion-table-wrap {
  max-height: min(78vh, 820px);
  overscroll-behavior: contain;
}

.collusion-table {
  min-width: 1500px;
  table-layout: fixed;
}

.collusion-col-score {
  width: 74px;
}

.collusion-col-risk {
  width: 86px;
}

.collusion-col-pair {
  width: 240px;
}

.collusion-col-num {
  width: 90px;
}

.collusion-col-money {
  width: 112px;
}

.collusion-col-victim {
  width: 190px;
}

.collusion-col-tags {
  width: 360px;
}

.collusion-table th,
.collusion-table td {
  padding: 7px 8px;
  font-size: 12px;
  vertical-align: middle;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.collusion-table th {
  height: 44px;
}

.collusion-table th button[data-collusion-sort] {
  width: 100%;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
  justify-content: flex-start;
}

.collusion-table th.num button[data-collusion-sort] {
  justify-content: flex-end;
  text-align: right;
}

.collusion-table th button[data-collusion-sort]:hover,
.collusion-table th button[data-collusion-sort].active {
  color: var(--green-dark);
}

.collusion-table tbody tr.selected td {
  background: #d9f0e9;
  box-shadow: inset 0 1px 0 #7bd1bf, inset 0 -1px 0 #7bd1bf;
}

.collusion-score {
  color: #b91c1c;
  font-weight: 900;
}

.collusion-level,
.collusion-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  margin: 2px 4px 2px 0;
  border-radius: 6px;
  padding: 0 7px;
  font-size: 12px;
  font-weight: 900;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}

.collusion-level.high {
  background: #b91c1c;
  color: #fff;
}

.collusion-level.warn {
  background: #fee2e2;
  color: #b91c1c;
}

.collusion-level.review {
  background: #fff4d8;
  color: #92400e;
}

.collusion-level.muted {
  background: #eef3f0;
  color: var(--muted);
}

.collusion-tag {
  background: #e6f3ef;
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px #c4e3db;
}

.collusion-pair {
  display: grid;
  gap: 4px;
}

.collusion-pair strong,
.collusion-victim strong {
  color: var(--text);
  font-weight: 900;
}

.collusion-pair span,
.collusion-victim span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.collusion-victim {
  margin: 1px 0;
}

.collusion-detail-panel {
  margin-bottom: 8px;
}

.collusion-detail-note {
  margin-top: 8px;
  padding: 9px 10px;
  border: 1px solid #b7e3da;
  border-radius: 8px;
  background: #eefaf7;
  color: var(--green-dark);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 700;
}

.collusion-hand-detail table {
  min-width: 1260px;
}

.collusion-action-details {
  max-width: 1120px;
}

.collusion-action-details summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid #b7e3da;
  border-radius: 8px;
  background: #eefaf7;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
}

.collusion-action-details summary::-webkit-details-marker {
  display: none;
}

.collusion-action-details summary::before {
  content: "▶";
  font-size: 10px;
  transform: translateY(-1px);
}

.collusion-action-details[open] summary::before {
  content: "▼";
}

.collusion-action-details summary em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}

.collusion-action-details[open] summary {
  margin-bottom: 7px;
}

.collusion-action-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: stretch;
  gap: 8px;
  max-width: 1120px;
}

.collusion-action-street {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: stretch;
  gap: 6px;
  min-width: 150px;
  padding: 7px;
  border: 1px solid #d8e4df;
  border-radius: 8px;
  background: #f8fbfa;
}

.collusion-action-street > strong {
  display: grid;
  gap: 2px;
  min-height: 42px;
  padding-bottom: 5px;
  border-bottom: 1px solid #e2ebe8;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.35;
}

.collusion-action-street > strong small {
  color: #9a6a00;
  font-size: 11px;
  font-weight: 900;
}

.collusion-action-street > strong em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.collusion-action-street > div {
  display: grid;
  align-content: start;
  gap: 6px;
}

.collusion-action-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "id pos"
    "cards cards"
    "action action";
  align-items: start;
  gap: 4px 6px;
  max-width: 100%;
  min-height: 58px;
  padding: 7px;
  border-radius: 6px;
  background: #f5f8f7;
  color: var(--text);
  box-shadow: inset 0 0 0 1px #d8e4df;
  font-size: 12px;
  line-height: 1.25;
}

.collusion-action-chip b {
  grid-area: id;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.collusion-action-chip i {
  grid-area: pos;
  justify-self: end;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 108, 96, 0.1);
  color: var(--green-dark);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.collusion-action-chip u {
  grid-area: cards;
  padding: 1px 4px;
  border-radius: 4px;
  background: #ffffff;
  color: #111827;
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px #d8e4df;
}

.collusion-action-chip u.collusion-card-boxes {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  justify-self: start;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.collusion-card-boxes .collusion-card {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 21px;
  padding: 0 3px;
  border: 1px solid #d8e4df;
  border-radius: 4px;
  background: #fff;
  color: #1f2937;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

.collusion-card-boxes .collusion-card.red {
  color: var(--red);
}

.collusion-action-chip > span {
  grid-area: action;
  color: #9a6a00;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.collusion-action-chip.pair {
  background: #fff1f1;
  box-shadow: inset 0 0 0 1px #fecaca;
}

.collusion-action-chip.pair b {
  color: var(--red);
}

.collusion-action-chip.strong {
  background: #fff7ed;
  box-shadow: inset 0 0 0 1px #fdba74;
}

.collusion-action-chip.strong.pair {
  background: #fee2e2;
  box-shadow: inset 0 0 0 1px #ef4444;
}

.collusion-action-chip.pressure-fold {
  background: #fff4d8;
  box-shadow: inset 0 0 0 1px #f59e0b;
}

.collusion-action-chip.winner {
  background: #ecfdf5;
  box-shadow: inset 0 0 0 1px #34d399;
}

.collusion-action-chip.winner b {
  color: var(--green-dark);
}

.collusion-action-chip.winner > span {
  color: #047857;
}

.collusion-action-empty {
  color: var(--muted);
  font-weight: 800;
}

th button[data-member-sort]:hover,
th button[data-member-sort].active {
  color: var(--green-dark);
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr {
  cursor: default;
}

tbody tr:hover,
tbody tr.selected {
  background: #edf8f5;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty {
  height: 88px;
  text-align: center;
  color: var(--muted);
  cursor: default;
}

.check-good {
  color: var(--green-dark);
  font-weight: 800;
}

.check-warn {
  color: var(--gold);
  font-weight: 800;
}

.negative {
  color: var(--red);
  font-weight: 900;
}

td.negative {
  background: #fff1ef;
  border-left: 0;
  box-shadow: none;
}

td.team-mismatch {
  background: #fff2a8;
  color: #7a3b00;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px #f2b84b;
}

tbody tr.selected td {
  background: #d7eee7;
}

tbody tr.selected td.negative {
  background: #ffdcd7;
}

tbody tr.selected td.team-mismatch {
  background: #ffe57a;
}

.bill-history-panel tbody tr.selected td:nth-child(-n + 3),
.member-table tbody tr.selected td:nth-child(-n + 2) {
  background: #c8e9df;
}

tbody tr.selected {
  outline: 2px solid #7ccabb;
  outline-offset: -2px;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 14px;
  }

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

  .file-button {
    width: 100%;
  }

  .control-band {
    grid-template-columns: 1fr;
  }

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

  .member-controls {
    grid-template-columns: 1fr;
  }

  .risk-controls {
    grid-template-columns: 1fr;
  }

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

  .summary-grid,
  .work-area,
  .analytics-grid,
  .analytics-grid.secondary {
    grid-template-columns: 1fr;
  }

  .formula-panel,
  .history-filter-band,
  .bill-history-panel,
  .detail-panel {
    grid-column: auto;
    grid-row: auto;
  }

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

  .member-mini-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .risk-mini-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

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

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

  .formula-fields,
  .formula-fields.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 25px;
  }

  .summary-grid {
    gap: 10px;
  }

  .metric,
  .panel,
  .history-panel {
    padding: 14px;
  }

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

  .inline-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-actions select,
  .inline-actions button {
    width: 100%;
  }

  .mini-metrics {
    grid-template-columns: 1fr;
  }

  .member-mini-metrics {
    grid-template-columns: 1fr;
  }

  .risk-mini-metrics {
    grid-template-columns: 1fr;
  }

  .member-detail-grid {
    grid-template-columns: 1fr;
  }

  .risk-detail-grid {
    grid-template-columns: 1fr;
  }

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

  .comparison-row strong,
  .comparison-row em {
    text-align: left;
  }

  .formula-fields,
  .formula-fields.compact {
    grid-template-columns: 1fr;
  }
}
