:root {
  --bg: #f4f8fb;
  --panel: #ffffff;
  --panel-soft: #f7fbfd;
  --ink: #121926;
  --muted: #64748b;
  --line: #dce5ee;
  --brand: #0ea5e9;
  --brand-deep: #1557d6;
  --teal: #11b89a;
  --green: #16a34a;
  --orange: #f59e0b;
  --purple: #7c3aed;
  --red: #ef476f;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(17, 184, 154, 0.14), transparent 34rem),
    linear-gradient(135deg, #f7fbfd 0%, #eef7f7 45%, #f8fafc 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: rgba(255, 255, 255, 0.94);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  height: 88px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 38px;
  height: 38px;
  overflow: hidden;
  display: inline-grid;
  place-items: start center;
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.14);
}

.brand-mark img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  object-position: center top;
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
}

.nav {
  padding: 16px 12px;
  display: grid;
  gap: 6px;
}

.nav-link,
.nav-action {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #263244;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-align: left;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.nav-link:hover,
.nav-action:hover {
  background: #eef7fb;
}

.nav-link.active {
  background: #e8fbf6;
  color: #008976;
  font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 14px 12px;
  display: grid;
  gap: 6px;
}

.content-shell {
  min-width: 0;
}

.topbar {
  min-height: 88px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  position: sticky;
  top: 0;
  z-index: 15;
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

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

.topbar-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu {
  display: none;
}

.icon-button,
.locale,
.user-menu,
.chip-button,
.primary-button,
.ghost-button,
.danger-button,
.select-button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.icon-button {
  width: 38px;
  padding: 0;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff;
  border-color: transparent;
}

.ghost-button {
  background: #f8fafc;
}

.danger-button {
  color: #b42345;
  background: #fff5f7;
  border-color: #ffd6df;
}

.balance-pill {
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  color: #008976;
  background: #e8fbf6;
  font-weight: 800;
}

.user-menu {
  padding: 6px 10px 6px 6px;
}

.user-menu strong,
.user-menu small {
  display: block;
  text-align: left;
}

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

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.main {
  padding: 32px;
  display: grid;
  gap: 24px;
}

.section {
  display: grid;
  gap: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-header h2,
.section-header h3 {
  margin: 0;
}

.section-header h2 {
  font-size: 18px;
}

.section-header h3 {
  font-size: 15px;
}

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

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card,
.panel,
.table-panel,
.platform-card,
.plan-card,
.task-card,
.doc-block {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card {
  min-height: 96px;
  padding: 18px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #fff;
}

.stat-icon.teal {
  background: var(--teal);
}

.stat-icon.blue {
  background: var(--brand);
}

.stat-icon.green {
  background: var(--green);
}

.stat-icon.purple {
  background: var(--purple);
}

.stat-icon.orange {
  background: var(--orange);
}

.stat-icon.red {
  background: var(--red);
}

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

.stat-card strong {
  display: block;
  margin: 2px 0;
  font-size: 22px;
  line-height: 1.15;
}

.platform-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.platform-card {
  padding: 14px;
  box-shadow: none;
}

.platform-card h4,
.plan-card h4,
.task-card h4 {
  margin: 0 0 10px;
  font-size: 15px;
}

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 24px;
  color: var(--muted);
}

.metric-row strong {
  color: var(--ink);
}

.metric-row .money {
  color: #009b6e;
}

.filters {
  min-height: 74px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.input,
.textarea,
.select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.textarea {
  min-height: 86px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: rgba(14, 165, 233, 0.8);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12);
}

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

.panel {
  padding: 18px;
}

.chart-wrap {
  min-height: 260px;
  position: relative;
}

canvas.chart {
  width: 100%;
  height: 240px;
  display: block;
}

.model-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

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

.recent-item {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #eef2f6;
  padding-bottom: 10px;
}

.recent-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.recent-item strong,
.recent-item small {
  display: block;
}

.recent-item small {
  color: var(--muted);
  margin-top: 3px;
}

.quick-grid,
.plan-grid,
.task-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px;
}

.quick-action {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  text-align: left;
}

.quick-action.active,
.payment-route.active,
.ghost-button.active {
  border-color: rgba(37, 99, 235, 0.72);
  background: #eff6ff;
  color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.quick-action strong,
.quick-action small {
  display: block;
}

.quick-action small {
  color: var(--muted);
  margin-top: 4px;
}

.bonus-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.bonus-strip span {
  border: 1px solid #fed7aa;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
  font-weight: 800;
  padding: 7px 10px;
}

.payment-pick {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.payment-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.payment-routes {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.payment-route {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  display: grid;
  gap: 6px;
  padding: 13px 14px;
  text-align: left;
}

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

.recharge-confirm {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
}

.recharge-confirm div {
  display: grid;
  gap: 4px;
}

.table-panel {
  overflow: hidden;
}

.table-toolbar {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid #edf2f7;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #f8fbfd;
}

td {
  vertical-align: middle;
}

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

.mono {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef7fb;
  color: #25637a;
  font-size: 12px;
  font-weight: 700;
}

.badge.green {
  background: #e8fbf0;
  color: #087443;
}

.badge.orange {
  background: #fff7e6;
  color: #b36300;
}

.badge.red {
  background: #fff0f3;
  color: #ba1a3a;
}

.badge.gray {
  background: #f1f5f9;
  color: #475569;
}

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

.switch {
  width: 42px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: #cbd5e1;
  padding: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
}

.switch span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
}

.switch.on {
  background: var(--teal);
  justify-content: flex-end;
}

.plan-card,
.task-card {
  padding: 18px;
}

.plan-price {
  font-size: 30px;
  line-height: 1;
  margin: 10px 0;
  font-weight: 800;
}

.feature-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 18px;
  padding: 0;
  list-style: none;
  color: var(--muted);
}

.feature-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--brand), var(--teal));
}

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

.admin-login-panel {
  max-width: 430px;
  margin: 64px auto;
}

.admin-login-form {
  display: grid;
  gap: 14px;
}

.admin-login-form strong {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}

.admin-login-form label {
  display: grid;
  gap: 6px;
  color: #334155;
  font-weight: 700;
}

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

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

.field label {
  font-weight: 700;
  color: #334155;
}

.doc-block {
  padding: 16px;
  box-shadow: none;
}

.code-line {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: 11px 12px;
  overflow-x: auto;
}

.code-line code {
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.42);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal {
  width: min(620px, 100%);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.modal header,
.modal footer {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal header {
  border-bottom: 1px solid var(--line);
}

.modal footer {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.modal h3 {
  margin: 0;
}

.modal-body {
  padding: 18px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  min-width: 220px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.icon::before {
  line-height: 1;
  font-size: 18px;
}

.icon.dashboard::before { content: "▦"; }
.icon.key::before { content: "⚿"; }
.icon.usage::before { content: "▥"; }
.icon.monitor::before { content: "◌"; }
.icon.subscription::before { content: "▤"; }
.icon.purchase::before { content: "￥"; }
.icon.order::before { content: "□"; }
.icon.redeem::before { content: "◇"; }
.icon.profile::before { content: "♙"; }
.icon.task::before { content: "↻"; }
.icon.moon::before { content: "◐"; }
.icon.collapse::before { content: "≪"; }
.icon.menu::before { content: "☰"; }
.icon.bell::before { content: "♧"; }
.icon.chevron::before { content: "⌄"; }
.icon.wallet::before { content: "▣"; }
.icon.chart::before { content: "▧"; }
.icon.token::before { content: "◫"; }
.icon.clock::before { content: "◷"; }
.icon.copy::before { content: "⧉"; }
.icon.plus::before { content: "+"; }
.icon.refresh::before { content: "↻"; }
.icon.check::before { content: "✓"; }
.icon.close::before { content: "×"; }

body.dark {
  --bg: #101722;
  --panel: #162033;
  --panel-soft: #111827;
  --ink: #e5edf8;
  --muted: #97a6ba;
  --line: #25344a;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  background: #0d1420;
  color-scheme: dark;
}

body.dark .sidebar,
body.dark .topbar,
body.dark .stat-card,
body.dark .panel,
body.dark .table-panel,
body.dark .platform-card,
body.dark .plan-card,
body.dark .task-card,
body.dark .doc-block,
body.dark .modal,
body.dark .quick-action,
body.dark .payment-route,
body.dark .recharge-confirm,
body.dark .filters,
body.dark .input,
body.dark .textarea,
body.dark .select,
body.dark .icon-button,
body.dark .locale,
body.dark .user-menu,
body.dark .ghost-button {
  background: var(--panel);
  color: var(--ink);
}

body.dark th {
  background: #111827;
}

body.dark .code-line {
  background: #030712;
}

@media (max-width: 1180px) {
  .summary-grid,
  .platform-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

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

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 248px;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu {
    display: inline-flex;
  }

  .topbar {
    padding: 14px 16px;
    align-items: flex-start;
  }

  .topbar-tools {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .locale,
  .balance-pill {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .summary-grid,
  .platform-grid,
  .quick-grid,
  .payment-routes,
  .plan-grid,
  .task-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .model-layout {
    grid-template-columns: 1fr;
  }

  .filters,
  .recharge-confirm,
  .table-toolbar,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }
}
