:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #111827;
  --body: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --nav: #0b1020;
  --nav-soft: #111827;
  --green: #16a34a;
  --orange: #f59e0b;
  --red: #dc2626;
  --gray: #64748b;
  --cyan: #00a8ff;
  --violet: #7c3aed;
  --shadow: 0 18px 48px rgba(15, 23, 42, .08);
  --shadow-strong: 0 26px 80px rgba(15, 23, 42, .16);
  --radius: 20px;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--body);
  background:
    radial-gradient(circle at 8% -8%, rgba(37, 99, 235, .14), transparent 28%),
    radial-gradient(circle at 92% 0%, rgba(0, 168, 255, .12), transparent 25%),
    linear-gradient(180deg, #f8fafc 0%, #f5f7fb 54%, #eef4ff 100%),
    var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 34px;
  border: 0;
  border-radius: 12px;
  padding: 0 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  cursor: pointer;
  font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

button:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-dark), #0284c7);
  box-shadow: 0 12px 28px rgba(37, 99, 235, .22);
  transform: translateY(-1px);
}

button.secondary {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

button.secondary:hover:not(:disabled) {
  color: var(--primary);
  background: #eff6ff;
  border-color: rgba(37, 99, 235, .24);
}

button.danger {
  color: var(--red);
  background: #fff5f5;
  border: 1px solid #fecaca;
  box-shadow: none;
}

button.danger:hover:not(:disabled) {
  color: #fff;
  background: var(--red);
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(37, 99, 235, .5);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .11);
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 25% 20%, rgba(37, 99, 235, .18), transparent 28%),
    radial-gradient(circle at 85% 10%, rgba(0, 168, 255, .14), transparent 30%),
    linear-gradient(135deg, #f8fafc, #eef4ff 55%, #e0f2fe);
}

.login-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 16px;
  padding: 32px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 24px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(16px);
}

.brand-lock,
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-lock p {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.brand-lock h1 {
  margin: 0;
  color: var(--ink);
  font-size: 27px;
}

.brand-lock span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.login-panel label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

.code-logo {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  display: block;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 14px 30px rgba(30, 31, 143, .16);
}

.code-logo.small {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
  border-radius: 50%;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px 14px;
  background:
    radial-gradient(circle at 28% 0%, rgba(0, 168, 255, .2), transparent 28%),
    radial-gradient(circle at 90% 18%, rgba(124, 58, 237, .18), transparent 26%),
    linear-gradient(180deg, var(--nav), #111827 60%, #172554);
  color: #cbd5e1;
}

.brand {
  padding: 10px 8px 18px;
  border-bottom: 1px solid rgba(125, 211, 252, .16);
}

.brand strong {
  display: block;
  color: #fff;
  font-size: 17px;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: #93c5fd;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

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

.nav-title {
  padding: 7px 8px 4px;
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
}

nav button {
  width: 100%;
  min-height: 38px;
  justify-content: flex-start;
  text-align: left;
  color: #cbd5e1;
  background: transparent;
  box-shadow: none;
}

nav button:hover:not(:disabled) {
  color: #fff;
  background: rgba(255, 255, 255, .08);
  box-shadow: none;
}

nav button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  box-shadow: 0 12px 30px rgba(37, 99, 235, .28);
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(226, 232, 240, .86);
  background: rgba(248, 250, 252, .9);
  backdrop-filter: blur(18px);
}

.topbar p,
.page-head p,
.section-title p {
  margin: 0;
  color: var(--muted);
}

.topbar p {
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.topbar h2 {
  margin: 0;
  color: var(--ink);
  font-size: 20px;
}

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

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--ink);
  background: #eff6ff;
  border: 1px solid var(--line);
  font-weight: 700;
}

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

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    radial-gradient(circle at 88% 4%, rgba(0, 168, 255, .18), transparent 26%),
    radial-gradient(circle at 16% 0%, rgba(124, 58, 237, .12), transparent 28%),
    linear-gradient(135deg, #ffffff, #f8fbff 62%, #eff6ff);
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .14em;
}

.page-head h1 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1.05;
}

.page-actions {
  display: flex;
  gap: 10px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat,
.section,
.chart-card,
.list-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 18px;
  min-height: 128px;
  background:
    radial-gradient(circle at 92% 0%, rgba(0, 168, 255, .1), transparent 32%),
    linear-gradient(180deg, #ffffff, #f8fbff);
}

.stat::after {
  content: "";
  position: absolute;
  right: -32px;
  top: -42px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(37, 99, 235, .08);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 9px;
  color: var(--ink);
  font-size: 26px;
  line-height: 1.1;
}

.stat em {
  display: inline-flex;
  margin-top: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--primary);
  background: rgba(37, 99, 235, .08);
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
}

.stat.green strong { color: var(--green); }
.stat.orange strong { color: var(--orange); }
.stat.red strong { color: var(--red); }

.insight-grid,
.overview-lists {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.chart-card,
.list-card {
  min-height: 228px;
  padding: 16px;
}

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

.card-head h3,
.section h3 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
}

.bar-list,
.mini-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-row div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.bar-row span {
  overflow: hidden;
  color: var(--body);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row b {
  color: var(--ink);
  white-space: nowrap;
}

.bar-row i {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e0f2fe;
}

.bar-row em {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
}

.mini-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  min-height: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: inherit;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  box-shadow: none;
  text-align: left;
}

.mini-row:hover {
  border-color: rgba(37, 99, 235, .28);
  background: #eff6ff;
  box-shadow: none;
}

.mini-row strong {
  color: var(--ink);
}

.mini-row span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.mini-row em {
  grid-row: 1 / 2;
  grid-column: 2 / 3;
  font-style: normal;
}

.filterbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}

.filterbar label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.filter-actions {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  align-items: center;
}

.section {
  margin-bottom: 16px;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 96% 0%, rgba(37, 99, 235, .08), transparent 26%),
    linear-gradient(180deg, #ffffff, #f8fbff);
}

.section-title p {
  margin-top: 5px;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #475569;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
  white-space: nowrap;
}

td {
  color: var(--body);
}

tbody tr:nth-child(even) td {
  background: #fbfdff;
}

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

th:last-child,
td:last-child {
  position: sticky;
  right: 0;
  background: inherit;
  box-shadow: -10px 0 16px rgba(15, 23, 42, .05);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.actions button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--primary);
  background: rgba(37, 99, 235, .08);
  border: 1px solid rgba(37, 99, 235, .16);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
}

.badge.green {
  color: var(--green);
  background: #ecfdf3;
  border-color: #bbf7d0;
}

.badge.orange {
  color: var(--orange);
  background: #fffbeb;
  border-color: #fed7aa;
}

.badge.red {
  color: var(--red);
  background: #fef2f2;
  border-color: #fecaca;
}

.badge.gray {
  color: var(--gray);
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.money {
  color: var(--ink);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.progress-pill {
  position: relative;
  width: 116px;
  height: 26px;
  display: inline-flex;
  overflow: hidden;
  border-radius: 999px;
  background: #e0f2fe;
}

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

.progress-pill b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.import-panel {
  margin-bottom: 16px;
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 18px 18px;
}

.file-btn {
  position: relative;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0 13px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  font-weight: 800;
}

.file-btn:hover {
  color: var(--primary);
  background: #eff6ff;
  border-color: rgba(37, 99, 235, .28);
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 16px;
}

.settings-list {
  display: grid;
  gap: 0;
  padding: 4px 18px 18px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.setting-row span {
  color: var(--muted);
}

.setting-row strong {
  color: var(--ink);
  text-align: right;
}

.notes {
  padding: 4px 18px 18px;
}

.notes p {
  margin: 12px 0;
  line-height: 1.7;
}

.notes strong {
  color: var(--ink);
}

.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(6px);
}

.drawer {
  width: min(860px, 100%);
  height: 100%;
  overflow: auto;
  background: var(--surface);
  box-shadow: -28px 0 70px rgba(15, 23, 42, .22);
  animation: drawerIn .18s ease-out;
}

@keyframes drawerIn {
  from { transform: translateX(24px); opacity: .75; }
  to { transform: translateX(0); opacity: 1; }
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 250, 252, .94);
  backdrop-filter: blur(14px);
}

.drawer-head span {
  display: block;
  margin-bottom: 7px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .14em;
}

.drawer-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
}

.drawer-head p {
  margin: 7px 0 0;
  color: var(--muted);
}

.drawer-body {
  padding: 18px 24px 28px;
}

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

.product-form-grid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-weight: 700;
}

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

.detail-block {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.detail-block h4 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 15px;
}

.detail-block p {
  margin: 7px 0;
  color: var(--body);
  line-height: 1.6;
}

.rule-help {
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(239, 246, 255, .95), rgba(255, 255, 255, .95));
}

.admin-drawer-actions {
  margin-top: 18px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.check-card {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 250, 252, .9);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

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

.muted,
.empty-cell {
  color: var(--muted);
}

.empty-cell {
  padding: 30px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  max-width: 430px;
  padding: 13px 15px;
  border-radius: 14px;
  color: #fff;
  background: #0f172a;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .24);
  font-weight: 800;
}

@media (max-width: 1280px) {
  .insight-grid,
  .overview-lists { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  nav {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
  .topbar,
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }
  .stats,
  .insight-grid,
  .overview-lists,
  .settings-grid,
  .detail-grid,
  .permission-grid,
  .form-grid,
  .product-form-grid,
  .filterbar {
    grid-template-columns: 1fr;
  }
  .drawer {
    width: 100%;
  }
  .table-wrap {
    overflow: visible;
  }
  table {
    min-width: 0;
  }
  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }
  thead {
    display: none;
  }
  tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }
  tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
  }
  td {
    position: static !important;
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 12px;
    padding: 11px 12px;
    box-shadow: none !important;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
  }
  .empty-cell {
    display: block;
  }
  .empty-cell::before {
    content: "";
  }
}
