:root {
  --bg-a: #111827;
  --bg-b: #172554;
  --bg-c: #0f766e;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #f8fafc;
  --muted: rgba(248, 250, 252, 0.68);
  --primary: #38bdf8;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --table-head: #1f2937;
  --table-row: #ffffff;
  --table-alt: #f8fafc;
  --ink: #111827;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 32rem),
    linear-gradient(135deg, var(--bg-a) 0%, var(--bg-b) 48%, var(--bg-c) 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1280px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar,
.toolbar,
.tabs,
.stats,
.admin-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
}

.topbar {
  min-height: 52px;
  padding: 10px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  min-width: 0;
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.brand-subtitle,
.meta {
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.link-btn,
.primary-btn,
.ghost-btn,
.danger-btn {
  border: 0;
  border-radius: 8px;
  min-height: 34px;
  padding: 0 12px;
  color: white;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.primary-btn {
  background: #0284c7;
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.ghost-btn,
.link-btn {
  background: rgba(255, 255, 255, 0.1);
}

.danger-btn {
  background: #dc2626;
}

.stats {
  border-radius: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stat {
  min-height: 54px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  align-content: center;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
}

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

.tabs {
  border-radius: 12px;
  padding: 8px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.tab-btn {
  border: 0;
  border-radius: 999px;
  min-height: 32px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}

.tab-btn.active {
  color: #fff;
  background: #0284c7;
}

.toolbar {
  border-radius: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 8px;
}

.control {
  width: 100%;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  padding: 0 10px;
  outline: 0;
}

.control::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

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

.table-shell {
  min-height: 0;
  flex: 1;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.fund-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 14px;
}

.fund-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 40px;
  color: #fff;
  background: var(--table-head);
  text-align: left;
  padding: 0 10px;
  user-select: none;
  white-space: nowrap;
}

.fund-table th.sortable {
  cursor: pointer;
}

.fund-table td {
  height: 42px;
  padding: 6px 10px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.fund-table tr:nth-child(even) td {
  background: var(--table-alt);
}

.fund-code {
  font-weight: 800;
}

.fund-name {
  vertical-align: middle;
}

.name-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin-left: 6px;
  border-radius: 6px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: middle;
}

.badge-paused {
  color: #991b1b;
  background: #fee2e2;
}

.badge-limit {
  color: #92400e;
  background: #fef3c7;
}

.code-link {
  border: 0;
  padding: 0;
  color: #2563eb;
  background: transparent;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.copy-btn {
  margin-left: 6px;
  border: 0;
  background: transparent;
  color: #64748b;
  padding: 0;
}

.premium-up {
  color: var(--danger);
  font-weight: 800;
}

.premium-down {
  color: var(--success);
  font-weight: 800;
}

.tag,
.advice {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.tag-open,
.advice-wait {
  color: #166534;
  background: #dcfce7;
}

.tag-limit,
.advice-warn {
  color: #92400e;
  background: #fef3c7;
}

.tag-paused {
  color: #991b1b;
  background: #fee2e2;
}

.advice-hot {
  color: #991b1b;
  background: #fee2e2;
}

.footer-line {
  min-height: 32px;
  padding: 6px 10px;
  color: #64748b;
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
}

.empty {
  padding: 32px 16px;
  text-align: center;
  color: #64748b;
}

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.72);
}

.modal-mask[hidden] {
  display: none;
}

.history-modal {
  width: min(980px, 100%);
  max-height: min(760px, 90vh);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.modal-head {
  min-height: 60px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  background: #1f2937;
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-head p {
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.history-wrap {
  overflow: auto;
}

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

.history-table th {
  position: sticky;
  top: 0;
  height: 36px;
  color: #fff;
  background: #334155;
  text-align: left;
  padding: 0 8px;
}

.history-table td {
  height: 34px;
  padding: 5px 8px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.history-table tr:nth-child(even) td {
  background: #f8fafc;
}

.admin-layout {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-panel {
  border-radius: 12px;
  padding: 14px;
}

.admin-panel h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-row .control {
  flex: 1;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

.admin-item.disabled {
  opacity: 0.56;
}

.message {
  min-height: 22px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: #fecaca;
}

.message.success {
  color: #bbf7d0;
}

@media (max-width: 720px) {
  .shell {
    height: 100vh;
    padding: 0;
    gap: 0;
  }

  .topbar,
  .tabs,
  .toolbar,
  .table-shell {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .topbar {
    min-height: 44px;
    padding: 6px 8px;
  }

  .brand-title {
    font-size: 14px;
  }

  .brand-subtitle {
    display: none;
  }

  .top-actions {
    gap: 5px;
  }

  .link-btn,
  .primary-btn,
  .ghost-btn,
  .danger-btn {
    min-height: 28px;
    padding: 0 8px;
    font-size: 12px;
  }

  .stats {
    display: none;
  }

  .tabs {
    padding: 4px;
    gap: 4px;
  }

  .tab-btn {
    min-height: 26px;
    padding: 0 10px;
    font-size: 12px;
  }

  .toolbar {
    grid-template-columns: 1fr 88px;
    gap: 4px;
    padding: 4px;
  }

  .control {
    min-height: 28px;
    padding: 0 6px;
    font-size: 12px;
  }

  .fund-table {
    min-width: 560px;
    font-size: 12px;
  }

  .fund-table th {
    height: 30px;
    padding: 0 6px;
    font-size: 11px;
  }

  .fund-table td {
    height: 32px;
    padding: 4px 6px;
  }

  .tag,
  .advice {
    min-height: 18px;
    padding: 0 5px;
    font-size: 10px;
  }

  .footer-line {
    min-height: 26px;
    padding: 4px 6px;
  }

  .admin-layout {
    padding: 0;
  }

  .modal-mask {
    padding: 0;
    align-items: stretch;
  }

  .history-modal {
    max-height: 100vh;
    border-radius: 0;
  }

  .admin-panel,
  .admin-item {
    border-radius: 0;
  }

  .form-row {
    align-items: stretch;
  }
}
