:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #17202a;
  --muted: #667085;
  --subtle: #98a2b3;
  --line: #d8dee7;
  --line-soft: #edf0f4;
  --nav: #101828;
  --nav-2: #1d2939;
  --accent: #0f766e;
  --accent-2: #14b8a6;
  --warning: #b7791f;
  --danger: #c2410c;
  --success: #15803d;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.1);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 16px;
  color: #e4e7ec;
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 0 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  display: grid;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: #0f766e;
  border-radius: 8px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
  line-height: 1.1;
}

.brand span {
  margin-top: 4px;
  color: #aab4c2;
  font-size: 12px;
}

.side-nav {
  display: grid;
  gap: 6px;
  margin-top: 20px;
}

.side-nav button {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  color: #cbd5e1;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.side-nav button:hover,
.side-nav button.is-active {
  color: #fff;
  background: rgba(20, 184, 166, 0.16);
}

.side-nav button.is-active {
  box-shadow: inset 3px 0 0 var(--accent-2);
}

.side-note {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.side-note span,
.side-note small {
  color: #aab4c2;
  font-size: 12px;
}

.side-note strong {
  overflow: hidden;
  color: #e4e7ec;
  font-size: 22px;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-note {
  gap: 6px;
}

.account-note small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: #101828;
  font-size: 25px;
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 12px;
  font-size: 15px;
}

p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

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

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

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--accent);
  outline: 3px solid rgba(20, 184, 166, 0.16);
}

.icon-button,
.ghost-button,
.primary-button,
.secondary-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}

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

.ghost-button,
.primary-button,
.secondary-button {
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.secondary-button {
  background: var(--surface-2);
}

.toast {
  position: sticky;
  top: 14px;
  z-index: 5;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 14px auto;
  padding: 10px 14px;
  color: #065f46;
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.13), transparent 34%),
    linear-gradient(315deg, rgba(20, 184, 166, 0.13), transparent 28%),
    var(--bg);
}

.login-card {
  display: grid;
  gap: 22px;
  width: min(420px, 100%);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand {
  padding: 0 0 18px;
  border-bottom-color: var(--line-soft);
}

.login-brand strong {
  color: var(--ink);
}

.login-brand span {
  color: var(--muted);
}

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

.login-form .primary-button {
  width: 100%;
}

.login-hint,
.form-error {
  margin: 0;
  font-size: 13px;
}

.form-error {
  min-height: 20px;
  color: var(--danger);
}

.settings-lock {
  display: grid;
  min-height: 420px;
  place-items: center;
}

.settings-lock-card {
  display: grid;
  gap: 16px;
  width: min(430px, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.settings-lock-card .primary-button {
  width: 100%;
}

.user-chip {
  display: grid;
  min-height: 38px;
  padding: 4px 12px;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.user-chip span,
.user-chip small {
  display: block;
  line-height: 1.25;
  white-space: nowrap;
}

.user-chip span {
  font-size: 13px;
  font-weight: 800;
}

.user-chip small {
  color: var(--muted);
  font-size: 11px;
}

.view-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.75fr);
  gap: 16px;
}

.stat-grid {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card,
.panel,
.cashflow-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.stat-card {
  min-height: 122px;
  padding: 18px;
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
}

.stat-card span {
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 27px;
  line-height: 1.1;
  letter-spacing: 0;
}

.stat-card.positive strong {
  color: var(--accent);
}

.stat-card.warning strong {
  color: var(--warning);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.loading-panel {
  display: grid;
  min-height: 360px;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 44px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.loading-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #dbe3ea;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 780ms linear infinite;
}

.loading-panel strong {
  color: var(--ink);
  font-size: 18px;
}

.loading-panel span {
  color: var(--muted);
  font-size: 13px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.panel.wide {
  min-height: 460px;
}

.panel-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-header.compact {
  display: block;
}

.trend-list {
  display: grid;
  gap: 9px;
}

.trend-row {
  display: grid;
  grid-template-columns: 54px minmax(110px, 1fr) 112px 64px;
  gap: 12px;
  align-items: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 13px;
}

.trend-row strong {
  color: var(--ink);
  text-align: right;
}

.trend-row small {
  text-align: right;
}

.mini-bar {
  height: 8px;
  overflow: hidden;
  background: #e8eef3;
  border-radius: 999px;
}

.mini-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
}

.metric-list {
  display: grid;
  gap: 12px;
}

.metric-list div,
.status-stack button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.metric-list div:last-child,
.status-stack button:last-child {
  border-bottom: 0;
}

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

.status-stack {
  display: grid;
}

.status-stack button {
  background: transparent;
  border-top: 0;
  border-right: 0;
  border-left: 0;
}

.badge,
.summary-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
  white-space: nowrap;
}

.status-已完成 {
  color: #166534;
  background: #dcfce7;
}

.status-进行中 {
  color: #0f766e;
  background: #ccfbf1;
}

.status-已取消,
.status-风控拦截 {
  color: #9a3412;
  background: #ffedd5;
}

.status-退款中,
.status-已退款 {
  color: #854d0e;
  background: #fef3c7;
}

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

.account-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.account-form {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.permission-grid {
  display: grid;
  gap: 8px;
}

.permission-grid h3 {
  margin-bottom: 2px;
}

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--muted);
  font-size: 13px;
}

.permission-grid input {
  width: 16px;
  min-height: 16px;
  padding: 0;
}

.account-table table {
  min-width: 860px;
}

.table-action {
  min-height: 30px;
  padding: 0 10px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
}

.derived-panel {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.derived-panel strong {
  color: var(--text);
  font-size: 24px;
}

.derived-panel small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}

.channel-editor {
  grid-column: 1 / -1;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.channel-editor label {
  display: grid;
  grid-template-columns: 130px minmax(130px, 1fr) 42px;
  gap: 12px;
  align-items: center;
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
}

.channel-editor input {
  width: 100%;
  padding: 0;
}

.form-actions {
  display: flex;
  grid-column: 1 / -1;
  gap: 10px;
}

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

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

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #475467;
  font-size: 12px;
  background: #f8fafc;
}

tbody tr {
  transition: background 150ms ease;
}

tbody tr:hover {
  background: #f8fafc;
}

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

.cashflow-card {
  min-height: 142px;
  padding: 16px;
}

.cashflow-card span,
.cashflow-card small {
  color: var(--muted);
  font-size: 13px;
}

.cashflow-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 25px;
}

.money-in {
  color: var(--success);
}

.money-out {
  color: var(--danger);
}

.report-stats {
  margin-bottom: 16px;
}

.report-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  justify-content: flex-end;
}

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

.report-filter select {
  min-width: 180px;
  font-weight: 700;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 50% / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 13px) 50% / 6px 6px no-repeat,
    #fff;
  appearance: none;
}

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

.modal {
  width: min(720px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.detail-list div {
  min-height: 64px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

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

.detail-list dd {
  margin: 6px 0 0;
  color: var(--ink);
  font-weight: 700;
}

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

  .sidebar {
    position: static;
    width: 100%;
    min-width: 0;
    height: auto;
    overflow: hidden;
  }

  .side-nav {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
  }

  .side-nav button {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }

  .side-note {
    display: none;
  }

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

@media (max-width: 760px) {
  .workspace {
    width: 100%;
    min-width: 0;
    padding: 16px;
  }

  .topbar,
  .panel-header {
    display: grid;
    justify-content: stretch;
  }

  .topbar-actions,
  .form-actions {
    justify-content: stretch;
  }

  .topbar-actions input,
  .topbar-actions button,
  .form-actions button {
    flex: 1;
  }

  .stat-grid,
  .settings-form,
  .cashflow-grid,
  .account-layout,
  .detail-list {
    grid-template-columns: 1fr;
  }

  .trend-row {
    grid-template-columns: 46px minmax(80px, 1fr) 96px;
  }

  .trend-row small {
    display: none;
  }

  .channel-editor label {
    grid-template-columns: 1fr 42px;
  }

  .channel-editor label span {
    grid-column: 1 / -1;
  }
}

@media print {
  .sidebar,
  .topbar-actions,
  .ghost-button,
  .icon-button,
  .toast {
    display: none !important;
  }

  .admin-shell {
    display: block;
  }

  .workspace {
    padding: 0;
  }

  .panel {
    box-shadow: none;
  }

  .workspace::after {
    display: block;
    margin-top: 24px;
    color: #667085;
    content: "本报表为演示模拟数据，由前端假接口生成。";
  }
}
