:root {
  --bg: #f8f3ea;
  --panel: #fffaf2;
  --line: #ecd8b6;
  --text: #2f2a24;
  --muted: #8a7b66;
  --primary: #f3b23c;
  --primary-dark: #b87916;
  --danger: #c93a2d;
  --success: #3f8f56;
  --shadow: 0 18px 44px rgba(120, 82, 24, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
code { color: var(--primary-dark); }

.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px;
  padding: 24px 18px;
  background: #2f2412;
  color: #fff7e8;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 36px; }
.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--primary);
  color: #2f2412;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 22px;
}
.brand-title { font-size: 18px; font-weight: 800; }
.brand-subtitle { color: #d9c29b; font-size: 12px; margin-top: 4px; }
.menu { display: grid; gap: 10px; }
.menu-item {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
  background: transparent;
  color: #ead8b9;
}
.menu-item.active, .menu-item:hover { background: rgba(243, 178, 60, 0.18); color: #fff; }
.side-note {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 24px;
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 250, 242, 0.08);
  color: #e8d2aa;
  font-size: 13px;
}
.side-note strong { color: #fff; }

.content { flex: 1; padding: 28px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
}
h1 { margin: 0; font-size: 30px; }
p { margin: 8px 0 0; }
.topbar p, .muted { color: var(--muted); }
.top-actions { display: flex; gap: 12px; }
.btn {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 18px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}
.btn.primary { background: var(--primary); color: #2f2412; }
.btn.ghost { background: #fff8ed; border-color: var(--line); color: var(--primary-dark); }
.btn.danger { background: #fff0ec; color: var(--danger); border-color: #f1b6ae; }
.icon-btn {
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #fff1cf;
  color: var(--primary-dark);
  font-size: 26px;
}
.section { display: none; }
.section.active { display: block; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.stat-card, .panel {
  background: var(--panel);
  border: 1px solid rgba(236, 216, 182, 0.85);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.stat-card { padding: 22px; display: grid; gap: 10px; }
.stat-card span { color: var(--muted); }
.stat-card strong { font-size: 34px; }
.stat-card.warn strong { color: var(--danger); }
.panel { padding: 22px; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; margin-top: 18px; }
.panel-title { font-size: 18px; font-weight: 900; margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 16px; }
.todo-line { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.todo-line:last-child { border-bottom: 0; }
.todo-line strong { color: var(--primary-dark); }

.product-toolbar {
  display: grid;
  grid-template-columns: 1fr 180px 160px auto;
  gap: 12px;
  margin-bottom: 18px;
}
.input, fieldset input, fieldset select, fieldset textarea, .export-output {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 0 12px;
  color: var(--text);
  outline: none;
}
.input:focus, fieldset input:focus, fieldset select:focus, fieldset textarea:focus, .export-output:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(243, 178, 60, 0.18);
}
.table-wrap { overflow: auto; }
.product-table { width: 100%; border-collapse: collapse; min-width: 920px; }
.product-table th {
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.product-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(236, 216, 182, 0.68);
  vertical-align: middle;
}
.product-info { display: flex; gap: 12px; align-items: center; }
.product-cover {
  width: 72px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  background: #f1dfbf;
}
.product-name { font-weight: 900; margin-bottom: 5px; }
.product-no { font-size: 12px; color: var(--muted); }
.price-lines { display: grid; gap: 4px; font-size: 13px; }
.price-lines strong { color: var(--danger); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #fff1cf;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
}
.badge.gray { background: #eee4d4; color: #7f705e; }
.badge.green { background: #e8f5df; color: var(--success); }
.badge.red { background: #fff0ec; color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions button { min-height: 30px; padding: 0 10px; font-size: 12px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(47, 36, 18, 0.48);
  display: grid;
  place-items: center;
  padding: 26px;
}
.modal.hidden, .toast.hidden { display: none; }
.modal-card {
  width: min(1180px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: var(--bg);
  border-radius: 28px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}
.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 26px;
  background: #fffaf2;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; padding: 22px 26px; }
fieldset {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: var(--panel);
}
fieldset legend { font-weight: 900; padding: 0 8px; color: var(--primary-dark); }
fieldset label { display: grid; gap: 7px; margin-bottom: 14px; color: #5d5143; font-weight: 700; }
fieldset textarea { min-height: 86px; padding-top: 10px; resize: vertical; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.switch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.switch-grid label { display: flex; align-items: center; gap: 8px; margin: 0; }
.upload-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-bottom: 12px; }
.image-preview {
  height: 160px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #fff;
  overflow: hidden;
  margin-bottom: 14px;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.modal-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px 26px;
  background: #fffaf2;
  border-top: 1px solid var(--line);
}
.spacer { flex: 1; }
.export-output {
  min-height: 520px;
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  z-index: 30;
  min-width: 220px;
  max-width: 520px;
  padding: 13px 18px;
  border-radius: 999px;
  background: #2f2412;
  color: #fff7e8;
  text-align: center;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  body { min-width: auto; }
  .admin-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; }
  .side-note { position: static; margin-top: 20px; }
  .stats-grid, .panel-grid, .form-grid { grid-template-columns: 1fr; }
  .product-toolbar { grid-template-columns: 1fr; }
}

.settings-form { grid-template-columns: 1fr 1fr; align-items: end; }
.settings-form label { display: grid; gap: 8px; font-weight: 700; }
.settings-actions { grid-column: 1 / -1; display: flex; gap: 12px; }
