:root {
  --bg: #f6f1e8;
  --bg-strong: #efe5d5;
  --surface: rgba(255, 252, 247, 0.9);
  --surface-strong: #fffdf9;
  --surface-muted: #f4ede1;
  --line: rgba(123, 94, 61, 0.14);
  --line-strong: rgba(123, 94, 61, 0.22);
  --text: #241d17;
  --text-soft: #645545;
  --text-faint: #8a7764;
  --accent: #0f766e;
  --accent-strong: #0b5e58;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --accent-alt: #d97706;
  --danger: #c2410c;
  --danger-soft: rgba(194, 65, 12, 0.12);
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.12);
  --warning: #b45309;
  --shadow-sm: 0 14px 30px rgba(56, 36, 20, 0.08);
  --shadow-md: 0 24px 60px rgba(56, 36, 20, 0.12);
  --radius-sm: 14px;
  --radius-md: 24px;
  --radius-lg: 32px;
  --transition: 180ms ease;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(217, 119, 6, 0.15), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.16), transparent 32%),
    linear-gradient(180deg, #f9f4ec 0%, #f4eee4 36%, #f7f3eb 100%);
}

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

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

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(460px, 100%);
}

.auth-card {
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 253, 249, 0.97), rgba(255, 250, 244, 0.94));
  box-shadow: var(--shadow-md);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 32px;
  letter-spacing: -0.04em;
}

.auth-card .muted {
  margin-bottom: 22px;
}

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

.site-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(123, 94, 61, 0.08);
  background: rgba(248, 243, 235, 0.82);
  backdrop-filter: blur(16px);
}

.topbar-inner {
  width: min(1460px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-mark {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-alt));
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.topbar-nav::-webkit-scrollbar {
  display: none;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--text-soft);
  white-space: nowrap;
  transition:
    transform var(--transition),
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    box-shadow var(--transition);
}

.nav-link:hover {
  transform: translateX(3px);
  color: var(--text);
  background: rgba(255, 255, 255, 0.56);
  border-color: var(--line);
}

.nav-link.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(217, 119, 6, 0.09));
  border-color: rgba(15, 118, 110, 0.18);
  box-shadow: var(--shadow-sm);
}

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

.content {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 20px 24px 32px;
}

.page-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  margin-bottom: 18px;
  padding: 22px 24px;
  border: 1px solid rgba(123, 94, 61, 0.12);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at top right, rgba(217, 119, 6, 0.18), transparent 28%),
    radial-gradient(circle at left bottom, rgba(15, 118, 110, 0.14), transparent 34%),
    linear-gradient(145deg, rgba(255, 253, 249, 0.98), rgba(247, 240, 228, 0.92));
  box-shadow: var(--shadow-md);
}

.page-hero::after {
  content: "";
  position: absolute;
  inset: auto -28px -40px auto;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.26);
  filter: blur(4px);
}

.page-hero-main,
.page-hero-side {
  position: relative;
  z-index: 1;
}

.page-hero-main {
  display: grid;
  gap: 14px;
  align-content: start;
}

.page-hero-copy {
  display: grid;
  gap: 12px;
}

.page-hero-copy h1 {
  margin: 0;
  max-width: 720px;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.1;
  letter-spacing: -0.06em;
}

.hero-eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-description {
  display: block;
  max-width: 640px;
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.55;
}

.page-hero-side {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.page-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.hero-tag-soft {
  color: var(--text-soft);
}

.hero-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

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

.hero-summary-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.64);
}

.hero-summary-label {
  margin-bottom: 8px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-summary-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.page-content {
  display: grid;
  gap: 14px;
}

.card {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 253, 249, 0.96), rgba(255, 250, 244, 0.88));
  box-shadow: var(--shadow-sm);
}

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

.card-header h2,
.table-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.card-subtitle {
  color: var(--text-soft);
  font-size: 13px;
}

.card-section {
  display: grid;
  gap: 14px;
}

.compact-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.summary-item {
  padding: 12px 14px;
  border: 1px solid rgba(123, 94, 61, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.64);
}

.summary-label {
  margin-bottom: 6px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.summary-value {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.status-banner {
  padding: 12px 14px;
  border: 1px solid rgba(123, 94, 61, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
}

.status-banner .detail {
  font-size: 14px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.cols-2 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.85fr);
  gap: 14px;
}

.stack {
  display: grid;
}

.gap-md {
  gap: 12px;
}

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

.notice {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.status-success {
  color: var(--success);
}

.status-danger {
  color: var(--danger);
}

.status-warning {
  color: var(--warning);
}

.detail {
  color: var(--text-soft);
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.6;
}

.stat-card {
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding-top: 16px;
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.1), transparent 24%),
    linear-gradient(180deg, rgba(255, 253, 249, 0.98), rgba(245, 238, 227, 0.9));
}

.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-alt));
}

.stat-card .muted {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.stat-meta {
  color: var(--text-faint);
  font-size: 13px;
}

.toolbar,
.btn-row,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar {
  justify-content: space-between;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition:
    transform var(--transition),
    border-color var(--transition),
    background var(--transition),
    box-shadow var(--transition),
    color var(--transition);
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.26);
  background: #fff;
  box-shadow: 0 14px 22px rgba(56, 36, 20, 0.08);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.btn-primary:hover {
  border-color: var(--accent-strong);
  background: linear-gradient(135deg, #11857c, var(--accent-strong));
}

.btn-danger {
  border-color: rgba(194, 65, 12, 0.2);
  background: rgba(255, 244, 238, 0.84);
  color: var(--danger);
}

.btn-danger:hover {
  border-color: rgba(194, 65, 12, 0.32);
  background: rgba(255, 237, 227, 0.95);
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 12px;
}

.pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.pill {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-red {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill.success {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(21, 128, 61, 0.16);
}

.status-pill.failed {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(194, 65, 12, 0.16);
}

.status-pill.pending {
  color: var(--text-soft);
  background: rgba(100, 85, 69, 0.1);
  border-color: rgba(100, 85, 69, 0.12);
}

label {
  display: grid;
  gap: 8px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text);
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.5);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.inline-form {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(123, 94, 61, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
}

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

.helper-text {
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.5;
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(123, 94, 61, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(123, 94, 61, 0.08);
  text-align: left;
  vertical-align: middle;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(245, 238, 227, 0.92);
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}

tbody tr {
  transition: background var(--transition), transform var(--transition);
}

tbody tr:nth-child(even) {
  background: rgba(248, 243, 235, 0.34);
}

tbody tr:hover {
  background: rgba(255, 249, 239, 0.92);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr.row-highlighted {
  background: rgba(255, 240, 229, 0.82) !important;
}

tbody tr.row-highlighted:hover {
  background: rgba(255, 232, 216, 0.96) !important;
}

.cell-main {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.cell-sub {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 12px;
}

.align-right {
  text-align: right;
}

.num-strong {
  font-weight: 800;
  color: var(--text);
}

.detail-row td,
.detail-cell {
  background: rgba(250, 245, 237, 0.92);
}

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

.detail-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(123, 94, 61, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
}

.detail-title {
  font-size: 14px;
  font-weight: 800;
}

.chip-item {
  padding: 10px 12px;
  border: 1px solid rgba(123, 94, 61, 0.08);
  border-radius: 14px;
  background: rgba(245, 238, 227, 0.54);
}

.chip-main {
  font-size: 13px;
  font-weight: 700;
}

.chip-sub {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 12px;
}

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

.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.bar-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(100, 85, 69, 0.12);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-alt));
}

.sparkline-wrap,
.monthly-chart-wrap {
  min-width: 180px;
  height: 72px;
}

.monthly-chart-wrap {
  height: 220px;
}

.api-mode-control {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.api-mode-label {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

.api-mode-hint {
  color: var(--text-faint);
  font-size: 12px;
  word-break: break-all;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(36, 29, 23, 0.36);
  backdrop-filter: blur(10px);
}

.modal.open {
  display: grid;
}

.modal-panel {
  width: min(680px, 100%);
  max-height: min(88vh, 920px);
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(123, 94, 61, 0.12);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 253, 249, 0.98), rgba(250, 244, 235, 0.96));
  box-shadow: var(--shadow-md);
}

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

.modal-header h3 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -0.04em;
}

.modal-header p {
  margin: 0;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
}

.modal-body {
  display: grid;
  gap: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.empty-state {
  padding: 24px;
  border: 1px dashed rgba(123, 94, 61, 0.22);
  border-radius: 18px;
  color: var(--text-soft);
  text-align: center;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable::after {
  content: " ⇅";
  opacity: 0.34;
  font-size: 11px;
}

thead th[data-sort="asc"]::after {
  content: " ↑";
  opacity: 1;
  color: var(--accent);
}

thead th[data-sort="desc"]::after {
  content: " ↓";
  opacity: 1;
  color: var(--accent);
}

.content > * {
  animation: fade-up 280ms ease both;
}

.content > *:nth-child(2) {
  animation-delay: 40ms;
}

.content > *:nth-child(3) {
  animation-delay: 80ms;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .content {
    padding-top: 18px;
  }
}

@media (max-width: 920px) {
  .topbar-inner {
    width: min(100%, calc(100% - 24px));
    min-height: 68px;
    flex-wrap: wrap;
    padding: 12px 0;
  }

  .topbar-brand {
    width: 100%;
    justify-content: space-between;
  }

  .topbar-nav {
    order: 3;
    width: 100%;
    flex-basis: 100%;
    padding-bottom: 4px;
  }

  .content {
    padding: 18px 16px 28px;
  }

  .page-hero {
    grid-template-columns: 1fr;
    padding: 22px;
  }

  .page-hero-copy h1 {
    font-size: 32px;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .hero-summary,
  .grid.cols-2,
  .grid.cols-4,
  .summary-strip,
  .split-layout,
  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 12px 14px;
  }

  .modal {
    padding: 12px;
  }

  .modal-panel {
    padding: 18px;
    border-radius: 22px;
  }
}

@media (max-width: 640px) {
  .auth-card {
    padding: 24px;
  }

  .card {
    padding: 16px;
  }

  .toolbar,
  .btn-row,
  .actions,
  .modal-actions {
    align-items: stretch;
  }

  .compact-toolbar,
  .compact-toolbar-group {
    align-items: stretch;
  }

  .btn {
    width: 100%;
  }

  .toolbar-group {
    width: 100%;
  }

  .toolbar-group .btn,
  .toolbar-group .pill {
    width: auto;
  }
}
