:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #17212b;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0f766e;
  --accent-strong: #0b5e59;
  --accent-soft: #ecfdf5;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .05);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

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

button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 60px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0;
  white-space: nowrap;
}

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

.brand-mark svg { width: 19px; height: 19px; }

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
}

.main-nav a.active, .main-nav a:hover {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.main-nav a[hidden] {
  display: none;
}

.main-nav svg { width: 16px; height: 16px; }

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 600;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s;
}

.btn:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
}

.btn svg { width: 16px; height: 16px; }

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

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

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

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

.btn-ghost { background: transparent; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

.icon-btn svg { width: 17px; height: 17px; }
.mobile-menu-btn { display: none; }

.app-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  min-height: calc(100vh - 130px);
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 64px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.footer-note { color: #94a3b8; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h1, .page-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: 0;
}

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

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; }
.price { color: var(--danger); font-weight: 800; }
.price-original { color: #94a3b8; text-decoration: line-through; font-weight: 400; }

.notice-band {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--blue-soft);
  color: #1e40af;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 20px;
}

.notice-band svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #94a3b8;
}

.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  outline: none;
}

.search-box .input { padding-left: 36px; }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
.label { display: block; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: #94a3b8; margin-top: 5px; }

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
}

.chip.active, .chip:hover {
  color: var(--accent-strong);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chip svg { width: 14px; height: 14px; }

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

.product-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}

.product-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
}

.product-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.product-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
}

.product-icon svg { width: 21px; height: 21px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.badge-green { background: var(--success-soft); color: var(--success); border-color: #bbf7d0; }
.badge-amber { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge-red { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.badge-blue { background: var(--blue-soft); color: var(--blue); border-color: #bfdbfe; }

.product-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.35;
}

.product-card .subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  min-height: 40px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 4px;
}

.product-price { font-size: 19px; }

.empty-state {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.empty-state svg { width: 38px; height: 38px; margin-bottom: 8px; color: #94a3b8; }

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

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

.card-head h2, .card-head h3 { margin: 0; font-size: 16px; }

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

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.stat-icon svg { width: 20px; height: 20px; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

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

th {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  background: var(--panel-soft);
  white-space: nowrap;
}

td { font-size: 13.5px; }
tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

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

.payment-actions .btn {
  flex: 0 0 auto;
  min-width: 74px;
  padding: 0 12px;
  white-space: nowrap;
}

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

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}

.detail-item .k { color: var(--muted); font-size: 12px; }
.detail-item .v { font-weight: 600; word-break: break-all; }

.delivery-box {
  background: var(--accent-soft);
  border: 1px solid #99f6e4;
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

.order-steps {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.step {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
}

.step.active { color: var(--accent-strong); border-color: var(--accent); background: var(--accent-soft); }
.step-arrow { color: #cbd5e1; }

.auth-panel {
  max-width: 440px;
  margin: 32px auto;
}

.auth-head {
  text-align: center;
  margin-bottom: 20px;
}

.auth-head h1 { margin: 0 0 6px; font-size: 22px; }
.auth-head p { margin: 0; color: var(--muted); }

.admin-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.admin-side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-side a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
}

.admin-side a.active, .admin-side a:hover { color: var(--accent-strong); background: var(--accent-soft); }
.admin-side svg { width: 16px; height: 16px; }

.admin-content { min-width: 0; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar .input, .toolbar .select { width: auto; min-width: 150px; }
.toolbar .spacer { flex: 1; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 0 0;
  color: var(--muted);
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow: auto;
  background: rgba(15, 23, 42, .45);
}

.modal-root[hidden] {
  display: none;
}

.modal-panel {
  width: 100%;
  max-width: 640px;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .22);
  margin: auto;
}

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

.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px; max-height: 70vh; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }

.toast-wrap {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 260px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .22);
  display: flex;
  align-items: flex-start;
  gap: 9px;
  animation: toastIn .18s ease-out;
}

.toast.success { background: #14532d; }
.toast.error { background: #7f1d1d; }
.toast svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 2px; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  color: var(--muted);
  gap: 10px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
  padding: 16px 6px 0;
}

.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.bar-track {
  width: 100%;
  height: 110px;
  display: flex;
  align-items: flex-end;
  background: var(--panel-soft);
  border-radius: 4px;
  overflow: hidden;
}

.bar {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height .3s ease;
}

.bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; max-width: 100%; }

@media (max-width: 980px) {
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-side { position: static; flex-direction: row; overflow-x: auto; }
  .admin-side a { white-space: nowrap; }
}

@media (max-width: 720px) {
  .payment-actions { flex-wrap: wrap; }
  .topbar-inner { flex-wrap: wrap; min-height: 56px; padding: 8px 14px; gap: 8px; }
  .mobile-menu-btn { display: inline-flex; margin-left: auto; }
  .main-nav {
    display: none;
    width: 100%;
    order: 5;
    margin: 4px 0;
    flex-direction: column;
    align-items: stretch;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 10px 12px; }
  .top-actions { margin-left: 0; }
  .app-main { padding: 18px 14px 36px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .product-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .field-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: 4px; }
  .search-row { flex-direction: column; }
  .search-box { max-width: none; }
  .toolbar .input, .toolbar .select { width: 100%; min-width: 0; }
  .toolbar .spacer { display: none; }
}
