:root {
  --primary: #007aff;
  --primary-dark: #0062cc;
  --primary-soft: #e8f2ff;
  --ink: #1a1a1a;
  --text: #454545;
  --muted: #777777;
  --line: #e8e8e8;
  --page: #f5f6f8;
  --panel: #ffffff;
  --green: #07a85a;
  --blue: #1989fa;
  --yellow: #b96f08;
  --red: #dd3b45;
  --sidebar: #1d1d1f;
  --shadow: 0 2px 12px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 8px;
  overflow-y: auto;
  color: #ffffff;
  background: var(--sidebar);
}

.brand-block {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 8px;
  padding: 0 0 18px;
}

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

.brand-block strong {
  display: none;
}

.brand-block span {
  display: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
}

.site-card {
  display: none;
  gap: 8px;
  margin: 0 0 14px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.site-card span {
  color: rgba(255, 255, 255, 0.56);
  font-size: 12px;
}

.site-card strong {
  font-size: 15px;
}

.site-card button,
.store-options button {
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.site-options,
.store-options {
  display: grid;
  gap: 6px;
  margin: -6px 0 14px;
}

.site-options button,
.store-options button {
  padding: 8px 10px;
  text-align: left;
}

.site-options button.is-active,
.store-options button.is-active {
  border-color: rgba(245, 81, 34, 0.55);
  background: rgba(245, 81, 34, 0.24);
}

.section-hint {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.platforms-page table {
  min-width: 1180px;
}

.copy-code {
  display: inline-flex;
  max-width: 220px;
  overflow: hidden;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f4f5f7;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-group {
  display: none;
  margin: 14px 10px 6px;
  color: rgba(255, 255, 255, 0.38);
  font-size: 12px;
  font-weight: 800;
}

.nav-item {
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  text-align: center;
}

.nav-item span:last-child {
  display: none;
}

.nav-item:hover,
.nav-item.is-active {
  color: #ffffff;
  background: rgba(245, 81, 34, 0.18);
}

.nav-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: currentColor;
  font-weight: 800;
}

.main-area {
  min-width: 0;
  max-width: 1600px;
  padding: 40px 42px 50px;
}

.topbar,
.section-toolbar,
.panel-head,
.drawer-head,
.drawer-actions,
.drawer-action-right,
.entity-title,
.row-actions,
.table-meta,
.settings-form label {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 30px;
}

.topbar h1,
.drawer-head h2,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  display: inline-flex;
  align-items: center;
  font-size: 28px;
  font-weight: 850;
}

.site-inline-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  margin-left: 14px;
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 14px;
  font-weight: 750;
  vertical-align: 4px;
}

.site-inline-pill.is-hidden {
  display: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.topbar-actions,
.section-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.notice-band {
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid #d8eaff;
  border-radius: 8px;
  background: var(--primary-soft);
  color: #135a9f;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.metric-card,
.panel,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 128px;
  padding: 24px;
}

.metric-label {
  color: #8f949f;
  font-size: 15px;
}

.metric-value {
  margin-top: 12px;
  font-size: 36px;
  font-weight: 850;
  line-height: 1.1;
}

.metric-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-grid,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.settings-grid {
  grid-template-columns: minmax(320px, 680px);
}

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

.dashboard-grid-lower {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.dashboard-grid-lower .recent-panel:only-child {
  grid-column: 1 / -1;
}

.dashboard-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.segmented-control button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.segmented-control button.is-active {
  color: #ffffff;
  background: var(--primary);
}

.dashboard-grid-lower {
  margin-top: 24px;
}

.panel {
  padding: 28px 30px;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 22px;
  font-weight: 850;
}

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

.status-board,
.settings-form {
  display: grid;
  gap: 10px;
}

.status-row {
  display: grid;
  grid-template-columns: minmax(90px, 130px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 42px;
}

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

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.trend-chart {
  min-height: 270px;
  overflow: hidden;
}

.trend-svg {
  display: block;
  width: 100%;
  min-height: 270px;
}

.chart-grid {
  stroke: #eef0f3;
  stroke-width: 1;
}

.chart-label {
  fill: #7d838d;
  font-size: 13px;
}

.trend-area {
  fill: rgba(0, 122, 255, 0.11);
}

.trend-line {
  fill: none;
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.trend-dot {
  fill: var(--primary);
  stroke: var(--primary);
  stroke-width: 2;
}

.rank-list {
  display: grid;
  gap: 0;
}

.rank-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
}

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

.rank-index {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  background: #f0f1f3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rank-item:nth-child(1) .rank-index,
.rank-item:nth-child(2) .rank-index,
.rank-item:nth-child(3) .rank-index {
  color: #ffffff;
  background: var(--primary);
}

.rank-main {
  min-width: 0;
}

.rank-name {
  overflow: hidden;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-sub {
  color: var(--muted);
  font-size: 12px;
}

.rank-value {
  font-weight: 800;
}

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

.compact-table table {
  min-width: 980px;
}

.compact-table th,
.compact-table td {
  padding: 12px 14px;
}

.compact-table tbody tr:first-child td {
  background: #fafafa;
}

.recent-panel {
  min-width: 0;
}

.section-toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(360px, 100%);
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
}

select,
input:not([type="file"]),
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

select {
  min-width: 144px;
  height: 40px;
  padding: 0 34px 0 12px;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.text-button,
.danger-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  padding: 0 16px;
  color: #ffffff;
  background: var(--primary);
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  padding: 0 14px;
  color: var(--primary);
  border-color: #ffc8b8;
  background: var(--primary-soft);
}

.ghost-button {
  padding: 0 14px;
  color: var(--text);
  border-color: var(--line);
  background: #ffffff;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--text);
  border-color: var(--line);
  background: #ffffff;
  font-size: 18px;
}

.text-button,
.danger-button {
  min-height: 32px;
  padding: 0 10px;
  background: transparent;
}

.text-button {
  color: var(--blue);
}

.danger-button {
  color: var(--red);
}

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

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  background: #fafafa;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

tbody tr:hover td {
  background: #fffdfc;
}

.entity-title {
  gap: 10px;
  min-width: 0;
}

.avatar {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.entity-main,
.entity-sub {
  display: block;
}

.entity-main {
  font-weight: 750;
}

.entity-sub {
  max-width: 300px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-meta {
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--text);
  background: #f0f1f3;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.success {
  color: #05633a;
  background: #e9f7ef;
}

.pill.warning {
  color: var(--yellow);
  background: #fff5df;
}

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

.pill.info {
  color: #1165ad;
  background: #eaf4ff;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions {
  flex-wrap: wrap;
  gap: 6px;
}

.empty-row {
  padding: 36px 16px;
  color: var(--muted);
  text-align: center;
}

.empty-state {
  display: grid;
  min-height: 128px;
  place-items: center;
  padding: 28px 16px;
  border: 1px dashed #d9dde4;
  border-radius: 8px;
  color: var(--muted);
  background: #fafbfc;
  text-align: center;
}

.settings-form label {
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.settings-form input {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.28);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  display: flex;
  width: min(520px, 100vw);
  height: 100vh;
  padding: 24px;
  background: #ffffff;
  box-shadow: var(--shadow);
  transform: translateX(104%);
  transition: transform 180ms ease-out;
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer form {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}

.drawer-head {
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  font-size: 22px;
}

.form-grid {
  display: grid;
  gap: 14px;
  overflow-y: auto;
  padding: 18px 4px 18px 0;
}

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

.field label {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  outline: 0;
}

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

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

.drawer-actions {
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.drawer-action-right {
  gap: 10px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: min(380px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: #20242c;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease-out, transform 160ms ease-out;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .brand-block {
    padding-bottom: 12px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-group {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    min-width: 96px;
  }

  .main-area {
    padding: 18px;
  }

  .metric-grid,
  .dashboard-grid,
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .section-toolbar {
    justify-content: flex-start;
    width: 100%;
  }

  .search-box,
  select,
  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }

  .metric-grid,
  .dashboard-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .status-row {
    grid-template-columns: 1fr;
  }

  .drawer {
    padding: 18px;
  }

  .drawer-actions,
  .drawer-action-right {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .drawer-actions button,
  .drawer-action-right button {
    width: 100%;
  }
}
