:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f4f8;
  --text: #172033;
  --muted: #667085;
  --line: #d9e0ea;
  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 10px 28px rgba(15, 23, 42, .10);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

.mobile-app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.mobile-topbar {
  flex: 0 0 auto;
  position: relative;
  z-index: 20;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(15, 23, 42, .06);
  backdrop-filter: blur(16px);
}

.topbar-main,
.topbar-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.topbar-sub {
  padding-top: 0;
}

.game-select-wrap {
  display: grid;
  gap: 4px;
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.game-select-wrap select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 10px;
  font-weight: 700;
}

.desktop-switch,
.topbar-btn,
.icon-btn,
.ghost-btn,
.primary-btn {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 0 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.desktop-switch {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  min-width: 64px;
}

.topbar-sub h1 {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 22px;
  line-height: 1.25;
}

.topbar-btn {
  background: #eef4ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.mobile-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  padding-bottom: 12px;
}

.mobile-tabs {
  flex: 0 0 auto;
  position: relative;
  z-index: 22;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 20px rgba(15, 23, 42, .08);
  backdrop-filter: blur(16px);
}

.tab-btn {
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 800;
}

.tab-btn span:first-child {
  font-size: 20px;
  line-height: 1;
}

.tab-btn.is-active {
  background: #eef4ff;
  color: var(--brand-2);
}

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

.metric-card,
.panel,
.record-card,
.state-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 92px;
  padding: 12px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

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

.metric-value {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

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

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

.chart {
  width: 100%;
  height: 260px;
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-card {
  padding: 12px;
}

.record-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

.field {
  min-width: 0;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 2px;
}

.field-value {
  font-weight: 750;
  overflow-wrap: anywhere;
}

.state-panel {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.action-list {
  display: grid;
  gap: 10px;
}

.action-btn {
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 850;
}

.action-btn.danger {
  color: var(--danger);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}

.sheet.is-open {
  display: block;
}

.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .40);
}

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(82vh, 720px);
  overflow: auto;
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  padding: 14px 14px calc(14px + var(--safe-bottom));
  box-shadow: 0 -18px 38px rgba(15, 23, 42, .22);
}

.sheet-head,
.sheet-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sheet-head strong {
  font-size: 18px;
}

.filter-fields {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

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

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

.filter-field input,
.filter-field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.check-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.check-row {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.check-row input {
  width: 20px;
  height: 20px;
  min-height: 20px;
  flex: 0 0 auto;
  accent-color: var(--brand);
}

.filter-hint,
.filter-empty {
  color: var(--muted);
  font-size: 12px;
}

.filter-empty {
  padding: 12px 6px;
}

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

.ghost-btn {
  background: var(--panel-2);
}

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

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

.mini-table th,
.mini-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.mini-table th {
  color: var(--muted);
  font-size: 12px;
}

.mini-table tbody > tr:nth-child(even) > td {
  background: #eef3f8;
}

.compact-table-wrap {
  border-radius: 8px;
}

.compact-table {
  min-width: 0;
  table-layout: fixed;
}

.compact-table th,
.compact-table td {
  padding: 11px 8px;
  white-space: normal;
  word-break: break-word;
}

.compact-table th:not(:first-child),
.compact-table td:not(:first-child) {
  text-align: right;
}

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

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