:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --line: #dfe5ee;
  --text: #172033;
  --muted: #6b7483;
  --accent: #1677ff;
  --accent-strong: #0f5fd3;
  --danger: #d93025;
  --warn: #a16207;
  --ok: #15803d;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #13213a;
  color: #fff;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 26px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2bb673;
  font-weight: 800;
}

h1, h2, p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.35;
}

.brand p {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

nav {
  display: grid;
  gap: 6px;
  margin-top: 22px;
}

nav a {
  color: rgba(255, 255, 255, 0.76);
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 6px;
  font-size: 14px;
}

nav a.active,
nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

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

.topbar,
.section,
.panel {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.topbar strong {
  font-size: 15px;
  word-break: break-all;
}

.section {
  margin-top: 18px;
  padding: 18px;
}

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

h2 {
  font-size: 18px;
  line-height: 1.4;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.metrics article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcff;
}

.metrics span,
.section-head span {
  color: var(--muted);
  font-size: 13px;
}

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

.grid-two {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 0.8fr);
  gap: 16px;
  background: transparent;
  border: 0;
  padding: 0;
}

.panel {
  padding: 18px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  white-space: nowrap;
}

.product-thumb {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef4ff;
  color: var(--accent-strong);
  font-weight: 800;
}

.user-thumb {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #eef4ff;
  color: var(--accent-strong);
  font-weight: 800;
}

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

td small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.stock-low {
  color: var(--danger);
  font-weight: 700;
}

.stock-ok {
  color: var(--ok);
  font-weight: 700;
}

.form-panel {
  display: grid;
  gap: 13px;
  align-content: start;
}

.form-heading {
  margin-bottom: 0;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

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

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 160px;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(22, 119, 255, 0.18);
  border-color: var(--accent);
}

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

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #eef4ff;
  color: var(--accent-strong);
}

td button + button {
  margin-left: 6px;
}

.image-preview {
  min-height: 180px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  color: var(--muted);
}

.image-preview img {
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.avatar-preview {
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fbfcff;
  color: var(--muted);
  font-size: 13px;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.empty-preview {
  border-style: dashed;
}

.record-tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.record-tag.in {
  background: #e7f8ef;
  color: #0f7a3a;
}

.record-tag.out {
  background: #fdeceb;
  color: #b3261e;
}

.theme-preview-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.theme-preview {
  min-height: 86px;
  color: #fff;
  text-align: left;
  background: linear-gradient(135deg, #1677ff, #8bbcff);
}

.theme-preview.dark {
  background: linear-gradient(135deg, #17130c, #c99a42);
}

.theme-preview.green {
  background: linear-gradient(135deg, #0f6b4a, #62c48e);
}

.theme-preview.pink {
  background: linear-gradient(135deg, #d6336c, #ffa8c5);
}

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

.parsed-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.parsed-list {
  display: grid;
  gap: 8px;
}

.parsed-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

#toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 44px));
  padding: 11px 14px;
  border-radius: 8px;
  background: #172033;
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.18s ease;
  pointer-events: none;
}

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

@media (max-width: 920px) {
  body {
    grid-template-columns: 1fr;
  }

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

  nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metrics,
  .grid-two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  main {
    padding: 14px;
  }

  .topbar,
  .section-head,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  nav,
  .form-row {
    grid-template-columns: 1fr;
  }
}
