:root {
  --ink: #20242a;
  --muted: #69717d;
  --line: #e7e2dc;
  --paper: #fffaf4;
  --soft: #f7efe6;
  --blue: #2456a6;
  --blue-soft: #dbe8ff;
  --rose: #cb4d65;
  --white: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: #efe7dd;
  color: var(--ink);
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--blue);
  color: var(--white);
  font-weight: 800;
  cursor: pointer;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
  border-radius: 12px;
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(32, 36, 42, 0.12);
}

.login-card h1 {
  margin: 0;
}

.login-card p {
  margin: 0 0 8px;
  color: var(--blue);
  font-weight: 800;
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.app-view {
  display: none;
}

.app-view.active {
  display: flex;
}

main.app-view.active {
  display: block;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
}

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

.topbar {
  padding: 20px 26px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.file-btn {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.file-btn input {
  display: none;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.layout {
  padding: 20px;
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

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

.panel h2 {
  margin: 0;
  font-size: 20px;
}

.hint,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat {
  padding: 14px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
}

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

.stat strong {
  display: block;
  margin-top: 8px;
  color: var(--blue);
  font-size: 24px;
}

.stat.warn {
  background: #fdecec;
  border-color: #f2c4c4;
}

.stat.warn strong {
  color: #c0392b;
}

.stock-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  vertical-align: middle;
}

.stock-badge.low {
  background: #fff3d6;
  color: #b26a00;
}

.stock-badge.sold-out {
  background: #fdecec;
  color: #c0392b;
}

.product-card.low-stock {
  border-color: #f0c36d;
}

.product-card.sold-out {
  border-color: #f2b8b8;
  opacity: 0.85;
}

.content {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 360px;
  gap: 16px;
}

.order-card,
.product-card,
.category-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.order-top,
.product-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 12px;
}

.category-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.order-top img,
.product-card img {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 8px;
}

.order-preview {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.order-preview img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
}

.order-preview-title {
  font-size: 14px;
  font-weight: 900;
  margin-bottom: 6px;
}

.name {
  font-size: 17px;
  font-weight: 900;
}

.price {
  color: var(--rose);
  font-weight: 900;
  margin-top: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.actions button {
  background: var(--blue-soft);
  color: var(--blue);
}

.actions button.done {
  background: var(--soft);
  color: var(--ink);
}

.actions button.danger {
  background: #fdecec;
  color: #c0392b;
}

.filter-bar {
  display: grid;
  grid-template-columns: 150px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.filter-bar button {
  background: var(--blue-soft);
  color: var(--blue);
}

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.batch-bar .hint {
  margin-right: auto;
}

.batch-bar button {
  background: var(--blue-soft);
  color: var(--blue);
}

.batch-bar button.done {
  background: #e6f4ea;
  color: #1a7f37;
}

.order-select {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  flex-shrink: 0;
  accent-color: var(--blue);
}

.order-top,
.product-card {
  grid-template-columns: auto 86px 1fr;
  align-items: center;
}

.photo {
  margin-top: 12px;
  max-width: 260px;
  width: 100%;
  border-radius: 8px;
}

.detail-box {
  display: none;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.detail-box.open {
  display: block;
}

.detail-grid {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px 12px;
  font-size: 14px;
}

.detail-grid span:nth-child(odd) {
  color: var(--muted);
  font-weight: 700;
}

.photo-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 13px;
}

.review-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  background: var(--white);
}

.review-card.hidden {
  background: var(--soft);
  opacity: 0.82;
}

.review-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.review-head .name {
  color: var(--rose);
}

.review-content {
  margin: 10px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}

.review-reply {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
  line-height: 1.5;
}

.product-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.product-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.form-row.action-row {
  grid-template-columns: minmax(0, 1fr) minmax(130px, 0.8fr) auto;
  align-items: end;
}

.subhead {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.upload-line {
  display: grid;
  grid-template-columns: 1fr 128px;
  gap: 8px;
  align-items: center;
}

.upload-line input[type="file"] {
  padding: 7px;
  font-size: 12px;
}

.checkline {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 8px !important;
}

.checkline input {
  width: auto;
  min-height: auto;
}

.rest-days-label {
  display: block;
  margin-top: 4px;
}

.rest-days {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 8px;
}

.rest-days .checkline {
  font-size: 13px;
  font-weight: 400;
  color: var(--text, #333);
}

.tier-editor {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line, #e7e2dc);
  border-radius: 10px;
  background: #faf8f4;
}

.tier-editor-head {
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--text, #333);
}

.tier-editor-row {
  display: grid;
  grid-template-columns: 44px 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line, #eee);
}

.tier-editor-row:first-of-type {
  border-top: none;
}

.tier-editor-level {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent, #e7837d);
  text-align: center;
}

.tier-editor-row label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #777;
}

.tier-editor-row input {
  width: 100%;
  box-sizing: border-box;
}

.tier-editor-row .tier-free {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #555;
}

@media (max-width: 900px) {
  .tier-editor-row {
    grid-template-columns: 44px 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .content,
  .stats,
  .filter-bar,
  .form-row.action-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .stats-columns {
    grid-template-columns: 1fr;
  }
}

/* ===== 数据统计面板 ===== */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stats-columns {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
}

.stats-col {
  padding: 14px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.stats-col-title {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 180px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-width: 0;
}

.bar-value {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  min-height: 14px;
}

.bar-track {
  flex: 1;
  width: 100%;
  max-width: 26px;
  display: flex;
  align-items: flex-end;
  background: var(--blue-soft);
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  background: var(--blue);
  border-radius: 4px 4px 0 0;
}

.bar-label {
  font-size: 9px;
  color: var(--muted);
  margin-top: 6px;
  white-space: nowrap;
}

.top-product {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.top-product:last-child {
  border-bottom: none;
}

.top-product .rank {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  text-align: center;
  line-height: 22px;
  font-size: 12px;
  font-weight: 700;
}

.top-product .top-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-product .top-meta {
  flex: none;
  color: var(--muted);
  font-size: 12px;
}
