:root {
  --brand: #e11d48;
  --brand-dark: #be123c;
  --brand-soft: #fff1f2;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ok: #059669;
  --warn: #d97706;
  --side: #0b1220;
  --side-2: #111827;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 20%, rgba(225, 29, 72, 0.35), transparent 40%),
    radial-gradient(circle at 88% 10%, rgba(14, 165, 233, 0.22), transparent 36%),
    linear-gradient(160deg, #0b1220, #1e293b 55%, #0f172a);
}

.login-card {
  width: 400px;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.login-card .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fb7185, #e11d48);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  margin-bottom: 16px;
}

.login-card h1 { margin: 0 0 8px; font-size: 26px; letter-spacing: 0.5px; }
.login-card .sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.login-card input {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
  border-color: #fda4af;
  box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.12);
}
.login-card button {
  width: 100%;
  height: 46px;
  margin-top: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #fb7185, #e11d48);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
}
.login-card button:hover { filter: brightness(1.05); }
.hint { margin-top: 12px; color: #94a3b8; font-size: 12px; line-height: 1.5; }

/* ===== App shell ===== */
.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.side {
  width: 248px;
  background: linear-gradient(180deg, var(--side), var(--side-2));
  color: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 8px 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 14px;
}
.brand .name { font-weight: 800; font-size: 18px; letter-spacing: 0.5px; }
.brand .desc { margin-top: 6px; color: #94a3b8; font-size: 12px; }

.nav-group { margin-bottom: 14px; }
.nav-group .label {
  color: #64748b;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 6px 12px;
  text-transform: uppercase;
}

.side nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow: auto; }
.side nav button, .logout {
  text-align: left;
  border: none;
  background: transparent;
  color: #cbd5e1;
  padding: 11px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s, color .15s;
}
.side nav button .ico {
  width: 22px;
  text-align: center;
  opacity: 0.85;
}
.side nav button.on,
.side nav button:hover {
  background: rgba(225, 29, 72, 0.18);
  color: #fff;
}
.side nav button.on {
  box-shadow: inset 3px 0 0 var(--brand);
}
.logout {
  color: #fda4af;
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  padding-top: 16px;
}

.main {
  flex: 1;
  padding: 28px 28px 40px;
  overflow: auto;
  max-width: 1400px;
}

.tab { display: none; }
.tab.on { display: block; animation: fadeIn .2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
}
.page-head .sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, 0.8);
}
.card > h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.stat {
  background: linear-gradient(180deg, #fff, #f8fafc);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 16px;
  transition: transform .15s, box-shadow .15s;
}
.stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.06);
}
.stat .n {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--ink);
}
.stat .l {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}
.stat.warn .n { color: var(--warn); }
.stat.danger .n { color: var(--brand); }
.stat.ok .n { color: var(--ok); }

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

.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.search-bar .search-input {
  flex: 1 1 220px;
  min-width: 180px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}
.search-bar .search-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.search-bar .search-date input {
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}

button.btn, .btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  transition: background .15s, border-color .15s, color .15s;
}
button.btn:hover, .btn:hover { background: #f8fafc; }
button.btn-primary, .btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
button.btn-primary:hover, .btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}
button.btn-danger, .btn-danger {
  color: var(--brand);
  border-color: #fecdd3;
  background: #fff1f2;
}
button.btn-danger:hover { background: #ffe4e6; }

.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--line); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 720px;
}
th, td {
  border-bottom: 1px solid #f1f5f9;
  padding: 12px 12px;
  text-align: left;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
  font-size: 12px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
td .btn { margin-right: 6px; margin-bottom: 4px; }

img.thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
  background: #eee;
  border: 1px solid var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: #475569;
  font-weight: 500;
}
.form-grid input,
.form-grid select,
.form-grid textarea {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  border-color: #fda4af;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
}
.form-grid textarea {
  height: 88px;
  padding: 10px 12px;
  resize: vertical;
}
.form-grid .full { grid-column: 1 / -1; }

.muted { color: #94a3b8; font-size: 12px; line-height: 1.6; }
code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 12px;
  color: #334155;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  width: 720px;
  max-width: 96vw;
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.modal h2 { margin: 0 0 18px; font-size: 20px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.media-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.media-item {
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid var(--line);
}
.media-item img,
.media-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-item .rm {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.7);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  line-height: 22px;
  padding: 0;
}
.media-item .cover-tag {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba(225, 29, 72, 0.9);
  color: #fff;
  font-size: 11px;
  text-align: center;
  padding: 3px 0;
}

.modal-goods { width: 760px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.modal-head h2 { margin: 0 0 6px; }
.modal-tip {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.upload-zone {
  border: 1.5px dashed #cbd5e1;
  border-radius: 14px;
  background: #f8fafc;
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  margin-bottom: 16px;
}
.upload-zone.dragover,
.upload-zone:hover {
  border-color: #fb7185;
  background: #fff1f2;
}
.upload-zone-inner { text-align: center; padding: 10px 8px 14px; }
.upload-plus {
  width: 44px;
  height: 44px;
  line-height: 42px;
  margin: 0 auto 8px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 28px;
  color: var(--brand);
}
.upload-title { font-weight: 700; font-size: 15px; }
.upload-sub { margin-top: 6px; color: var(--muted); font-size: 12px; }
.easy-grid { margin-bottom: 8px; }
.adv-box {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  background: #fff;
  margin-top: 8px;
}
.adv-box summary {
  cursor: pointer;
  font-weight: 650;
  color: #334155;
  user-select: none;
}
.video-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: -24px; background: #fff; }
.set-cover {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 11px;
  padding: 4px 0;
  cursor: pointer;
}

.as-detail { line-height: 1.75; font-size: 14px; }
.as-detail .goods-line {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
  padding: 8px;
  background: #f8fafc;
  border-radius: 10px;
}
.as-detail .goods-line img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

.modal-order { width: min(720px, 94vw); max-height: 90vh; overflow: auto; }
.ship-box {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
}
.ship-box h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #9a3412;
}
.cell-clamp {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sku-editor {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}
.sku-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.sku-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}
.sku-table th,
.sku-table td {
  border: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  font-size: 13px;
}
.sku-table th { background: #f1f5f9; }
.sku-table input {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
}
.badge.paid, .badge.pending { background: #fff7ed; color: #c2410c; }
.badge.shipping { background: #eff6ff; color: #1d4ed8; }
.badge.done, .badge.received { background: #ecfdf5; color: #047857; }
.badge.rejected, .badge.cancelled { background: #fee2e2; color: #b91c1c; }
.badge.aftersale { background: #fdf2f8; color: #be185d; }
.badge.refunded { background: #f1f5f9; color: #475569; }
.badge.unpaid { background: #fef3c7; color: #a16207; }

.sync-flash {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  background: #0f172a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
}
.sync-flash.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.nav-badge[hidden] { display: none !important; }

.pending-alert {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: none;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(225, 29, 72, 0.18);
}
.pending-alert.show { display: flex; flex-wrap: wrap; }
.pending-alert button {
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  background: #e11d48;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.pending-alert button.secondary {
  background: #fff;
  color: #be123c;
  border: 1px solid #fecdd3;
}

.ops-cell {
  white-space: nowrap;
}
.ops-cell .btn {
  margin: 2px 4px 2px 0;
}
tr.row-disabled td {
  opacity: 0.72;
  background: #f8fafc;
}
tr.row-disabled td b {
  color: #64748b;
}

@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .app { flex-direction: column; }
  .side {
    width: 100%;
    height: auto;
    position: relative;
  }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group { width: 100%; }
  .main { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
