:root {
  color-scheme: light;
  --ink: #182028;
  --muted: #64707d;
  --line: #dce2e8;
  --panel: #ffffff;
  --bg: #f4f6f3;
  --nav: #16212a;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --amber: #b7791f;
  --red: #b42318;
  --blue: #2457a6;
  --soft-green: #e8f5ef;
  --soft-amber: #fff4d8;
  --shadow: 0 14px 32px rgba(24, 32, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  align-items: center;
  background: var(--nav);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 22px clamp(18px, 4vw, 48px);
}

.topbar h1 {
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.1;
  margin: 2px 0 0;
}

.eyebrow {
  color: #7aa59f;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #b8d9d3;
}

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

.topbar-stats span {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  display: inline-flex;
  gap: 6px;
  padding: 8px 10px;
  white-space: nowrap;
}

#backendStatus.is-cloud {
  background: rgba(232, 245, 239, 0.16);
  border-color: rgba(184, 217, 211, 0.42);
  color: #d9fff6;
}

#backendStatus.is-local {
  background: rgba(255, 244, 216, 0.14);
  border-color: rgba(255, 244, 216, 0.35);
  color: #fff5cf;
}

.topbar-actions {
  align-items: flex-end;
  display: grid;
  gap: 10px;
  justify-items: end;
}

.language-control {
  color: #d8efeb;
  font-size: 12px;
  font-weight: 700;
  min-width: 180px;
}

.language-control select {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.26);
  color: #ffffff;
}

.language-control option {
  color: var(--ink);
}

.workspace {
  margin: 0 auto;
  max-width: 1220px;
  padding: 18px clamp(14px, 3vw, 28px) 42px;
}

.tabs {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 8px;
  overflow: hidden;
}

.tab-button {
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  min-height: 46px;
  padding: 10px;
}

.tab-button:last-child {
  border-right: 0;
}

.tab-button.active {
  background: var(--teal);
  color: #ffffff;
  font-weight: 700;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.manager-links {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.manager-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  min-height: 32px;
  padding: 4px 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.manager-button:hover {
  color: var(--teal);
}

.split-grid,
.report-grid,
.admin-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.formula-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.formula-card {
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 156px;
  padding: 14px;
}

.formula-card p {
  color: var(--muted);
  margin: 0;
}

.formula-card strong {
  color: var(--ink);
}

.formula-card .formula-line {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  display: block;
  margin: 8px 0;
  padding: 9px 10px;
}

.formula-card code {
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  padding: 18px;
}

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

.panel-heading h2,
.panel h3 {
  margin: 0;
}

.panel-heading h2 {
  font-size: 20px;
}

.profile-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin: 6px 0 0;
}

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

.form-grid,
.settings-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

input,
select {
  background: #ffffff;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
  outline: 0;
}

input:disabled,
select:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.form-grid.is-locked input,
.form-grid.is-locked select {
  background: #f5f7f7;
}

.form-span {
  grid-column: 1 / -1;
}

.spend-section {
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-items: stretch;
  padding: 12px;
}

.spend-section-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  grid-column: 1 / -1;
  justify-self: start;
}

.spend-section label {
  justify-self: stretch;
  text-align: left;
}

.form-grid.is-disabled {
  opacity: 0.62;
}

.primary-button,
.ghost-button,
.danger-button {
  border-radius: 7px;
  min-height: 40px;
  padding: 8px 13px;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.primary-button {
  background: var(--teal);
  border: 1px solid var(--teal-dark);
  color: #ffffff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.ghost-button {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.ghost-button:hover {
  border-color: var(--teal);
}

.danger-button {
  background: #fff7f6;
  border: 1px solid #f3b4ad;
  color: var(--red);
}

.danger-button:hover {
  border-color: var(--red);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.table-panel {
  padding-bottom: 10px;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: middle;
}

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

td {
  font-size: 14px;
}

.empty-state {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

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

.metric {
  background: #f9fbfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  padding: 14px;
  min-height: 104px;
}

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

.metric strong {
  color: var(--ink);
  font-size: 28px;
  line-height: 1.1;
}

.metric small {
  color: var(--muted);
}

.verdict-box {
  background: var(--soft-green);
  border: 1px solid #b9ded3;
  border-radius: 8px;
  color: #153f3a;
  min-height: 190px;
  padding: 0;
  overflow: hidden;
}

.verdict-box p {
  margin: 0;
}

.verdict-inner {
  display: grid;
  gap: 0;
}

.verdict-hero {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(183, 121, 31, 0.12));
  border-bottom: 1px solid rgba(15, 118, 110, 0.18);
  padding: 16px;
}

.verdict-box .tier-line {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.verdict-box .tier-title {
  font-size: 22px;
  font-weight: 800;
}

.tier-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
}

.verdict-box .verdict-note {
  color: #284b47;
  font-weight: 700;
  margin-top: 10px;
}

.verdict-body {
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
}

.verdict-box .verdict-meta {
  display: grid;
  gap: 8px;
}

.verdict-meta span {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 7px;
  color: #35514d;
  padding: 8px 10px;
}

.verdict-scale {
  display: grid;
  gap: 6px;
}

.scale-track {
  background: #dfe8e6;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.scale-fill {
  background: linear-gradient(90deg, #9a4a32, #b7791f, #0f766e);
  height: 100%;
}

.scale-labels {
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: space-between;
}

.tier-legend .tier-badge {
  background: #ffe7e0;
  color: #8c2d16;
}

.tier-blessed .tier-badge {
  background: #fff4d8;
  color: #7a4a00;
}

.tier-lucky .tier-badge,
.tier-warm .tier-badge {
  background: #e8f5ef;
  color: #11665d;
}

.tier-normal .tier-badge {
  background: #eef2f6;
  color: #40505f;
}

.tier-cold .tier-badge,
.tier-storm .tier-badge {
  background: #f5ece8;
  color: #7a3b27;
}

.calc-chart {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.distribution-panel {
  background: #fbfbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 14px;
  padding: 14px;
}

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

.distribution-heading h3,
.distribution-heading p {
  margin: 0;
}

.distribution-heading p {
  color: var(--muted);
  font-size: 13px;
}

#distributionMarker {
  background: var(--soft-amber);
  border: 1px solid #ead39b;
  border-radius: 999px;
  color: #7a4a00;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
  white-space: nowrap;
}

.distribution-chart {
  align-items: end;
  display: grid;
  gap: 2px;
  grid-template-columns: repeat(28, minmax(3px, 1fr));
  height: 140px;
  position: relative;
}

.distribution-bar {
  background: #c8d8d4;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}

.distribution-bar.is-current {
  background: var(--teal);
}

.distribution-line {
  background: var(--red);
  bottom: 0;
  position: absolute;
  top: 0;
  width: 2px;
}

.distribution-axis {
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: space-between;
  margin-top: 7px;
}

.calc-row {
  background: #fbfbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.calc-row header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.calc-row strong {
  font-size: 14px;
}

.calc-row small {
  color: var(--muted);
}

.calc-track {
  background: #edf1f4;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.calc-fill {
  background: var(--teal);
  height: 100%;
}

.calc-parts {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 7px;
}

.money-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.money-list div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.money-list dt {
  color: var(--muted);
  font-weight: 700;
}

.money-list dd {
  margin: 0;
}

.tag {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
}

.tag-lucky {
  background: var(--soft-amber);
  color: #7a4a00;
}

.tag-normal {
  background: #eef2f6;
  color: #40505f;
}

.tag-hot {
  background: #ffe7e0;
  color: #923018;
}

.compact-control {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.compact-control select {
  min-height: 36px;
  width: 80px;
}

.bar-list,
.factor-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

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

.bar-track {
  background: #edf1f4;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.bar-fill {
  background: var(--blue);
  height: 100%;
}

.factor-item {
  background: #fbfbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.factor-item strong {
  display: block;
  margin-bottom: 4px;
}

.exchange-table {
  margin-top: 18px;
}

.conditional-input.is-hidden,
#customPlayerWrap.is-hidden {
  display: none;
}

.row-action {
  background: transparent;
  border: 0;
  color: var(--red);
  padding: 4px;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-stats {
    justify-content: flex-start;
  }

  .topbar-actions {
    align-items: flex-start;
    justify-items: start;
    width: 100%;
  }

  .split-grid,
  .report-grid,
  .admin-grid,
  .formula-grid,
  .metric-grid,
  .form-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .spend-section {
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(64px, 1fr));
  }

  .tab-button {
    font-size: 14px;
    min-height: 42px;
    padding: 8px 6px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .button-row {
    justify-content: flex-start;
  }
}
