:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #eef3f7;
  --text: #111827;
  --muted: #6b7280;
  --line: #dfe5eb;
  --brand: #0f766e;
  --brand-2: #155e75;
  --danger: #dc2626;
  --warning: #b45309;
  --ok: #15803d;
  --info: #2563eb;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: #101820;
  color: #f8fafc;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 24px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f766e, #22c55e);
  color: #fff;
  font-weight: 900;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span {
  color: #a8b3bf;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  border: 0;
  width: 100%;
  border-radius: 8px;
  color: #dbe4ea;
  background: transparent;
  text-align: left;
  padding: 12px;
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
}

.nav button:hover,
.nav button.active {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 78px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: rgba(246, 247, 249, 0.88);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid var(--line);
}

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

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

.api-config {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(620px, 55vw);
}

.api-config input {
  min-width: 0;
}

.content {
  padding: 24px 28px 44px;
}

.toolbar,
.filterbar,
.panel,
.table-wrap,
.detail-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toolbar,
.filterbar {
  padding: 14px;
}

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

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

.input,
.select,
.textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  min-height: 42px;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.22);
  border-color: var(--brand);
}

.textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
}

.btn {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn:hover {
  border-color: #b9c5d1;
}

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

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

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.icon {
  width: 40px;
  padding: 0;
  justify-content: center;
}

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

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.rank-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-card,
.panel {
  padding: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 108px;
}

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

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 27px;
}

.table-wrap {
  overflow: hidden;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: #4b5563;
  background: #f9fafb;
  font-weight: 700;
}

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

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover td {
  background: #f9fafb;
}

.cell-title {
  font-weight: 700;
}

.cell-sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  text-align: inherit;
}

.avatar,
.thumb {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--panel-2);
  object-fit: cover;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.thumb {
  width: 70px;
  height: 44px;
}

.profile-avatar {
  width: 86px;
  height: 86px;
  border-radius: 8px;
  background: var(--panel-2);
  object-fit: cover;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  flex: 0 0 auto;
}

.profile-cover {
  height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
  margin-bottom: 12px;
}

.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #eef2f7;
  color: #334155;
}

.badge.ok {
  background: #dcfce7;
  color: var(--ok);
}

.badge.warn {
  background: #fef3c7;
  color: var(--warning);
}

.badge.danger {
  background: #fee2e2;
  color: var(--danger);
}

.badge.info {
  background: #dbeafe;
  color: var(--info);
}

.actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.skeleton {
  min-height: 18px;
  border-radius: 8px;
  background: linear-gradient(90deg, #eef2f7, #f8fafc, #eef2f7);
  background-size: 220% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

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

.state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.chart {
  display: flex;
  align-items: end;
  gap: 10px;
  height: 210px;
  padding-top: 12px;
}

.bar {
  flex: 1;
  min-width: 34px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, var(--brand), var(--brand-2));
  position: relative;
}

.bar span {
  position: absolute;
  inset-inline: 0;
  bottom: -28px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  z-index: 20;
}

.drawer {
  position: fixed;
  inset-block: 0;
  right: 0;
  width: min(980px, 94vw);
  background: #fff;
  z-index: 21;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr;
}

.drawer-head,
.modal-head {
  padding: 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.drawer-body,
.modal-body {
  padding: 18px;
  overflow: auto;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 92vw);
  background: #fff;
  border-radius: 8px;
  z-index: 21;
  box-shadow: var(--shadow);
}

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

.detail-card {
  box-shadow: none;
  padding: 12px;
}

.detail-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.detail-tabs {
  overflow-x: auto;
  padding-bottom: 2px;
}

.detail-tabs button {
  white-space: nowrap;
}

.tabs button {
  border: 0;
  background: transparent;
  padding: 11px 12px;
  color: var(--muted);
}

.tabs button.active {
  color: var(--brand);
  box-shadow: inset 0 -2px 0 var(--brand);
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  margin-bottom: 16px;
}

.profile-summary h2 {
  margin: 0;
  font-size: 20px;
}

.profile-summary p {
  margin: 5px 0 10px;
  color: var(--muted);
}

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

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

.content-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.content-card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.media-tile {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
  color: var(--text);
  text-decoration: none;
}

.media-img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  background: var(--panel-2);
}

.media-tile span {
  display: block;
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.promo-panel {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.push-panel {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(260px, 360px);
  gap: 18px;
  align-items: start;
}

.push-side {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  padding: 14px;
}

.push-side h3,
.push-result h3 {
  margin: 0 0 12px;
}

.push-target-grid {
  grid-template-columns: 1fr;
}

.checkbox-group {
  display: grid;
  gap: 10px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 13px;
}

.checkbox-group input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.code-textarea {
  min-height: 86px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.push-result {
  margin-top: 14px;
}

.promo-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  min-height: 220px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.promo-img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
  display: block;
}

.promo-empty {
  color: var(--muted);
  font-weight: 700;
}

.promo-form {
  display: grid;
  gap: 12px;
}

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

.inline-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 13px;
  margin: 0 0 14px;
}

.inline-note.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.inline-note.warning strong,
.inline-note.warning span {
  display: block;
}

.inline-note.warning strong {
  color: #78350f;
  margin-bottom: 4px;
}

.storage-mini {
  display: grid;
  gap: 7px;
  min-width: 132px;
}

.storage-mini div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.storage-mini strong {
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.storage-mini span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.storage-summary {
  margin-bottom: 14px;
}

.quota-card {
  margin-bottom: 14px;
  box-shadow: none;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaf0;
  margin: 12px 0 8px;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #22c55e);
}

.compact-table {
  box-shadow: none;
  margin-bottom: 14px;
}

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

.json-value {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.compact-json {
  display: block;
  max-width: 190px;
}

.order-title-row {
  justify-content: space-between;
  margin-bottom: 12px;
}

.order-title-row h3,
.order-person-card h3,
.panel h3 {
  margin: 0;
}

.order-party-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 14px 0;
}

.order-person-card {
  box-shadow: none;
}

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

.pricing-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.pricing-line span {
  color: var(--muted);
}

.pricing-line.discount strong {
  color: var(--warning);
}

.pricing-line.warning {
  border-color: #fde68a;
  background: #fffbeb;
}

.pricing-line.warning strong {
  color: var(--warning);
}

.order-table-wrap {
  overflow-x: auto;
}

.order-items-table {
  min-width: 1280px;
}

.raw-json {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
}

.promo-actions {
  padding-top: 8px;
}

.toast-root {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 8px;
}

.toast {
  background: #101820;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.mobile-nav {
  display: none;
}

@media (max-width: 1100px) {
  .stats-grid,
  .rank-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .api-config {
    min-width: 0;
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: block;
  }

  .topbar {
    position: static;
    display: grid;
    padding: 14px;
  }

  .content {
    padding: 14px;
  }

  .stats-grid,
  .rank-grid,
  .promo-panel,
  .push-panel,
  .order-party-grid,
  .pricing-summary,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 900px;
  }
}
