* {
  box-sizing: border-box;
}

:root {
  --blue: #1498ff;
  --blue-dark: #0c63d7;
  --violet: #7a6cff;
  --green: #19c37d;
  --gold: #ffb640;
  --orange: #ff6b45;
  --ink: #202633;
  --muted: #7b8494;
  --line: #e8edf5;
  --bg: #f4f7fb;
  --card: #ffffff;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  color: #fff;
  background:
    radial-gradient(circle at 32% 8%, rgba(255,255,255,.2), transparent 24%),
    linear-gradient(180deg, #112a56 0%, #18213b 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-weight: 900;
  font-size: 18px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  box-shadow: 0 10px 24px rgba(20, 152, 255, .3);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.12);
}

.main {
  min-width: 0;
  padding: 22px 28px 40px;
}

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

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

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

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

.btn,
.btn-secondary,
.btn-danger,
.btn-mini {
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}

.btn {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  box-shadow: 0 10px 24px rgba(20,152,255,.2);
}

.btn-secondary {
  color: #526071;
  background: #fff;
  border: 1px solid var(--line);
}

.btn-danger {
  color: #d64528;
  background: #fff0ea;
}

.btn-mini {
  height: 30px;
  padding: 0 10px;
  color: var(--blue-dark);
  background: #e8f4ff;
  font-size: 12px;
}

.btn-mini.warn {
  color: #d64528;
  background: #fff0ea;
}

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

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

.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

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

.card {
  background: var(--card);
  border: 1px solid rgba(232,237,245,.9);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(21, 40, 72, 0.06);
}

.panel {
  padding: 18px;
}

.metric {
  padding: 18px;
}

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

.metric b {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: #11a866;
  font-size: 12px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

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

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

th {
  color: #667085;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.tag.blue {
  color: var(--blue-dark);
  background: #e8f4ff;
}

.tag.green {
  color: #0b8f5d;
  background: #e8f8ef;
}

.tag.gold {
  color: #8a5506;
  background: #fff3d9;
}

.tag.gray {
  color: #667085;
  background: #eef2f6;
}

.tag.red {
  color: #d64528;
  background: #fff0ea;
}

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

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

.field label {
  color: #475467;
  font-size: 12px;
  font-weight: 800;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.table-input,
.table-select {
  width: 100%;
  min-width: 88px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.table-input.small {
  min-width: 64px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.switch input {
  appearance: none;
  width: 38px;
  height: 22px;
  position: relative;
  border-radius: 999px;
  background: #d0d5dd;
  outline: none;
  transition: .18s ease;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(17,24,39,.18);
  transition: .18s ease;
}

.switch input:checked {
  background: var(--green);
}

.switch input:checked::after {
  transform: translateX(16px);
}

.input,
.select {
  height: 40px;
  padding: 0 12px;
}

.textarea {
  min-height: 90px;
  padding: 12px;
  resize: vertical;
}

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

.formula {
  padding: 14px;
  border: 1px dashed #b9d8ff;
  border-radius: 12px;
  background: #f4faff;
  color: #245f9d;
  font-size: 13px;
  line-height: 1.8;
}

.preview-phone {
  width: 260px;
  min-height: 520px;
  margin: 0 auto;
  padding: 12px;
  border-radius: 24px;
  background: #f4f7fb;
  box-shadow: inset 0 0 0 1px #dfe6ef, 0 14px 34px rgba(21,40,72,.12);
}

.preview-card {
  color: #fff;
  padding: 16px;
  border-radius: 16px;
  background:
    radial-gradient(circle at 80% 18%, rgba(255,255,255,.24), transparent 30%),
    linear-gradient(135deg, #13b887 0%, #18a6e8 54%, #756cff 100%);
}

.preview-card b {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

.progress {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #e9eef7;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.rule-card {
  padding: 14px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.rule-card b {
  display: block;
  margin-bottom: 8px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  color: #fff;
  border-radius: 12px;
  background: rgba(17, 24, 39, .92);
  box-shadow: 0 16px 34px rgba(17,24,39,.2);
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.index-wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 46px 24px;
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 18px;
}

.index-card {
  display: block;
  padding: 20px;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 44px rgba(23, 37, 84, 0.1);
}

.index-card b {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

.index-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

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

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

  .nav-group {
    grid-template-columns: repeat(2, 1fr);
  }

  .cols-2,
  .cols-3,
  .cols-4,
  .form-grid,
  .index-grid {
    grid-template-columns: 1fr;
  }

  .rule-card > div[style*="grid-template-columns:92px"] {
    grid-template-columns: 1fr !important;
  }

  .actions {
    flex-wrap: wrap;
  }
}
