:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #687386;
  --line: #dde3eb;
  --primary: #087f8c;
  --primary-dark: #066875;
  --accent: #c47a1b;
  --danger: #b42318;
  --success: #147d3f;
  --shadow: 0 10px 30px rgba(30, 45, 70, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef2f6;
  color: #344054;
  font-family: Consolas, "SFMono-Regular", monospace;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button:hover {
  border-color: #aeb8c5;
}

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

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

.wide {
  width: 100%;
}

.small {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #111827;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

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

.brand small {
  display: block;
  color: #a9b4c6;
  font-size: 12px;
}

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

.nav a {
  display: block;
  padding: 11px 12px;
  border-radius: 8px;
  color: #cbd5e1;
}

.nav a.active,
.nav a:hover {
  background: #1f2937;
  color: #fff;
}

.logout {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  color: #cbd5e1;
}

.logout button {
  min-height: 32px;
  background: transparent;
  color: #fff;
  border-color: #384354;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
}

.content {
  display: grid;
  gap: 20px;
  padding: 28px 32px 44px;
}

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

.button-group,
.inline-form,
.search {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.compact-form {
  min-width: 420px;
}

.compact-form input {
  min-width: 120px;
}

.search input {
  min-width: 320px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.segmented a {
  padding: 8px 14px;
  color: var(--muted);
  border-right: 1px solid var(--line);
}

.segmented a:last-child {
  border-right: 0;
}

.segmented a.active {
  background: var(--primary);
  color: #fff;
}

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

.panel {
  padding: 20px;
  overflow: hidden;
}

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

.panel-title h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
}

.metric-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric {
  padding: 18px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1.1;
}

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

.bar-chart {
  display: grid;
  grid-template-columns: repeat(24, minmax(24px, 1fr));
  align-items: end;
  min-height: 176px;
  gap: 6px;
  padding-top: 10px;
}

.bar-item {
  display: grid;
  gap: 6px;
  justify-items: center;
  align-items: end;
  min-width: 0;
}

.bar-item i {
  display: block;
  width: 100%;
  max-width: 26px;
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--primary), #70b6a4);
}

.bar-item small,
.bar-value {
  color: var(--muted);
  font-size: 11px;
}

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

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
}

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

.url-cell {
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  white-space: nowrap;
}

.actions a {
  margin-right: 10px;
}

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

.center {
  text-align: center;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2f6;
  color: #475467;
  font-size: 12px;
  font-weight: 600;
}

.status.active,
.status.redirected {
  background: #e7f6ec;
  color: var(--success);
}

.status.paused,
.status.expired {
  background: #fff2df;
  color: var(--accent);
}

.status.archived,
.status.not_found,
.status.invalid_target,
.status.no_target {
  background: #fee4e2;
  color: var(--danger);
}

.qr-thumb {
  width: 62px;
  height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.form-grid.single {
  grid-template-columns: 1fr;
}

.form-grid .wide,
.form-actions.wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.check {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  flex-wrap: wrap;
}

.check input {
  width: 18px;
  min-height: 18px;
}

.check span {
  margin: 0;
  color: var(--text);
}

.check small {
  flex-basis: 100%;
  margin-left: 26px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.check.slim {
  min-width: 92px;
}

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

.alert.danger {
  border-color: #fecdca;
  background: #fffbfa;
  color: var(--danger);
}

.alert.warning {
  border-color: #fedf89;
  background: #fffbeb;
  color: #93370d;
}

.alert.success {
  border-color: #abefc6;
  background: #f6fef9;
  color: var(--success);
}

.asset-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
}

.qr-panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.qr-panel img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.copy-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.upload-form {
  display: grid;
  gap: 10px;
}

.download-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wechat-admin-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.wechat-admin-preview {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.wechat-admin-preview img {
  max-width: 220px;
  max-height: 220px;
}

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

.detail-grid div.wide {
  grid-column: 1 / -1;
}

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

.detail-grid dd {
  margin: 4px 0 0;
}

.rule-create {
  display: grid;
  grid-template-columns: 160px minmax(260px, 1fr) 190px 190px 92px 92px auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

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

.rule-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.rule-item summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
}

.rule-edit {
  padding: 0 14px 14px;
}

.danger-text {
  margin: 0 14px 14px;
  border-color: #fecdca;
  color: var(--danger);
}

.danger-text.compact {
  margin: 0;
}

.team-hero {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 1.5fr);
  gap: 20px;
  align-items: end;
}

.team-hero h2 {
  margin: 4px 0;
  font-size: 24px;
}

.team-hero p,
.login-link {
  margin: 10px 0 0;
  color: var(--muted);
}

.parent-form {
  justify-content: flex-end;
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

.login-page,
.message-page,
.wechat-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel,
.message-box {
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.login-brand h1,
.message-box h1 {
  margin: 0;
  font-size: 24px;
}

.login-brand p,
.message-box p {
  margin: 4px 0 0;
  color: var(--muted);
}

.wechat-page {
  min-height: 100vh;
  background: #eef7f2;
}

.wechat-card {
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid #d7e9df;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.wechat-title {
  text-align: center;
}

.wechat-title span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #e7f6ec;
  color: var(--success);
  font-size: 13px;
  font-weight: 700;
}

.wechat-title h1 {
  margin: 12px 0 4px;
  font-size: 24px;
}

.wechat-title p,
.wechat-steps p {
  margin: 0;
  color: var(--muted);
}

.wechat-qr-box {
  display: grid;
  place-items: center;
  margin: 22px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.wechat-qr-box img {
  width: min(320px, 100%);
  height: auto;
}

.wechat-steps {
  padding: 14px;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
}

.wechat-steps strong {
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
}

@media (max-width: 1100px) {
  .app-shell,
  .asset-head,
  .two-col {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

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

  .team-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .metric-grid,
  .metric-grid.compact,
  .form-grid,
  .rule-create,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .search input {
    min-width: 100%;
  }

  .toolbar,
  .search,
  .inline-form {
    align-items: stretch;
    width: 100%;
  }

  .compact-form {
    min-width: 100%;
  }

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

  .wechat-admin-grid {
    grid-template-columns: 1fr;
  }

  .bar-chart {
    overflow-x: auto;
    grid-template-columns: repeat(24, 32px);
  }

  table {
    min-width: 760px;
  }

  .panel {
    overflow-x: auto;
  }
}
