/* ============================================================
   麦小七鲜蛋 · 商家后台样式
   配色沿用小程序：主色 #0abab5，背景 #e9f7f6
   ============================================================ */

:root {
  --brand: #0abab5;
  --brand-deep: #089e9a;
  --brand-lite: #4dd6d2;
  --brand-soft: #d6f2f0;
  --brand-mist: #e9f7f6;

  --bg: #f4faf9;
  --card: #ffffff;
  --line: #dfeeec;
  --line-strong: #c9e3e0;

  --ink: #16211f;
  --ink-2: #3d4f4c;
  --ink-3: #7d8b89;
  --ink-4: #a8b5b3;

  --danger: #e0565b;
  --danger-soft: #fdeced;
  --warn: #e89a3c;
  --warn-soft: #fdf3e3;
  --ok: #2fb344;
  --ok-soft: #e9f8ec;

  --r: 10px;
  --r-lg: 16px;
  --sh: 0 1px 2px rgba(22, 33, 31, .04), 0 4px 12px rgba(22, 33, 31, .06);
  --sh-lg: 0 8px 32px rgba(22, 33, 31, .12);
  --sb: 216px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

/* ================= 登录 ================= */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #e9f7f6 0%, #f4faf9 45%, #eef6f5 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 34px 30px 26px;
  box-shadow: 0 12px 48px rgba(10, 186, 181, .12), 0 2px 8px rgba(22, 33, 31, .05);
  border: 1px solid var(--line);
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 27px;
}

.login-title {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -.02em;
}

.login-sub {
  margin: 6px 0 24px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  letter-spacing: .06em;
}

.login-err {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 4px 0 8px;
}

.login-tip {
  margin: 18px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-4);
  line-height: 1.6;
}

/* ================= 表单元素 ================= */
.field {
  display: block;
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-size: 13.5px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(10, 186, 181, .12);
}

input::placeholder, textarea::placeholder { color: var(--ink-4); }

textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.6;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%237d8b89'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
  margin: 0;
}

/* ================= 按钮 ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: #fff;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: all .15s;
  user-select: none;
}

.btn:active { transform: translateY(1px); }

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

.btn-ghost {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--ink-2);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

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

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

.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; height: 42px; }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ================= 主布局 ================= */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sb);
  flex: none;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  transition: transform .22s ease;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.sb-logo {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.sb-brand-txt { display: flex; flex-direction: column; line-height: 1.3; }
.sb-brand-txt b { font-size: 15px; letter-spacing: -.01em; }
.sb-brand-txt small { font-size: 11px; color: var(--ink-3); }

.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--ink-2);
  text-decoration: none;
  cursor: pointer;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
  position: relative;
}

.sb-item i {
  font-style: normal;
  font-size: 14px;
  width: 18px;
  text-align: center;
  opacity: .85;
}

.sb-item:hover { background: var(--brand-mist); }

.sb-item.on {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 600;
}

.sb-item.on i { opacity: 1; }

.badge {
  margin-left: auto;
  font-style: normal;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

.sb-user {
  font-size: 12.5px;
  color: var(--ink-3);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-logout {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-2);
  transition: all .15s;
}

.sb-logout:hover { border-color: var(--danger); color: var(--danger); }

.main {
  flex: 1;
  margin-left: var(--sb);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 58px;
  flex: none;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.tb-left { display: flex; align-items: center; gap: 12px; }

.tb-menu {
  display: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.tb-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
}

.tb-right { display: flex; align-items: center; gap: 10px; }

.tb-status {
  font-size: 12px;
  color: var(--ink-3);
  transition: opacity .3s;
}
.tb-status.saving { color: var(--warn); }
.tb-status.saved { color: var(--ok); }
.tb-status.err { color: var(--danger); }

.content {
  padding: 20px 22px 60px;
  flex: 1;
}

/* ================= 卡片 / 通用块 ================= */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh);
  margin-bottom: 16px;
  overflow: hidden;
}

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

.card-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}

.card-head .sub {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 400;
  margin-left: 8px;
}

.card-body { padding: 16px 18px; }
.card-body.tight { padding: 0; }

/* ================= 统计卡片 ================= */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px 17px;
  box-shadow: var(--sh);
  position: relative;
  overflow: hidden;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-value {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-value small { font-size: 14px; font-weight: 600; margin-right: 1px; }

.stat-foot {
  font-size: 11.5px;
  color: var(--ink-4);
  margin-top: 5px;
}

.stat.accent { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%); border-color: transparent; }
.stat.accent .stat-label, .stat.accent .stat-foot { color: rgba(255, 255, 255, .8); }
.stat.accent .stat-value { color: #fff; }

/* ================= 表格 ================= */
.table-wrap { overflow-x: auto; }

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.tbl th {
  text-align: left;
  padding: 10px 14px;
  background: #fafdfc;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

table.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f7f6;
  vertical-align: middle;
}

table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #fbfefd; }

.tbl .num { font-variant-numeric: tabular-nums; }
.tbl .right { text-align: right; }
.tbl .center { text-align: center; }

.tbl-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--brand-mist);
  display: block;
  flex: none;
}

.cell-goods { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-goods-txt { min-width: 0; }
.cell-goods-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.cell-goods-spec { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* ================= 标签 ================= */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 21px;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-gray { background: #f1f5f4; color: var(--ink-3); }
.tag-brand { background: var(--brand-soft); color: var(--brand-deep); }
.tag-ok { background: var(--ok-soft); color: #248a35; }
.tag-warn { background: var(--warn-soft); color: #b8752a; }
.tag-danger { background: var(--danger-soft); color: #c9484d; }
.tag-info { background: #e8f0fd; color: #3b6fc4; }

/* ================= 工具栏 ================= */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .spacer { flex: 1; }

.search-box {
  position: relative;
  min-width: 200px;
}

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

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: .5;
  pointer-events: none;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 100px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all .15s;
}

.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { font-size: 11px; opacity: .75; }

/* ================= 空态 ================= */
.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--ink-3);
}

.empty-icon { font-size: 40px; opacity: .35; margin-bottom: 12px; }
.empty-title { font-size: 14px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.empty-sub { font-size: 12.5px; color: var(--ink-4); }

/* ================= 弹窗 ================= */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(22, 33, 31, .42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fade .15s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-lg);
  animation: pop .18s cubic-bezier(.2, .8, .3, 1);
}

@keyframes pop {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to { opacity: 1; transform: none; }
}

.modal-sm { max-width: 400px; }
.modal-lg { max-width: 760px; }

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

.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
  border-radius: 6px;
  transition: all .15s;
}

.modal-close:hover { background: #f1f5f4; color: var(--ink); }

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body p { margin: 0; line-height: 1.7; color: var(--ink-2); }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  flex: none;
  background: #fbfdfd;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ================= 表单网格（弹窗内） ================= */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.form-grid .full { grid-column: 1 / -1; }

.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.form-hint {
  font-size: 11.5px;
  color: var(--ink-4);
  margin-top: 4px;
  line-height: 1.5;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  padding: 8px 0;
}

.form-check input { flex: none; }

/* ================= 图片上传 ================= */
.img-picker {
  display: flex;
  align-items: center;
  gap: 12px;
}

.img-preview {
  width: 76px;
  height: 76px;
  border-radius: 10px;
  border: 1px dashed var(--line-strong);
  background: var(--brand-mist);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
  font-size: 22px;
  color: var(--ink-4);
  position: relative;
}

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

.img-actions { display: flex; flex-direction: column; gap: 6px; }

.file-btn {
  position: relative;
  overflow: hidden;
}

.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 200px;
}

/* ================= 订单卡片 ================= */
.order-list { display: flex; flex-direction: column; gap: 12px; }

.order-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh);
  overflow: hidden;
}

.order-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fafdfc;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.order-no {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.02em;
}

.order-time { font-size: 12px; color: var(--ink-3); }
.order-head .spacer { flex: 1; }

.order-body { padding: 13px 16px; }

.order-items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.order-item .oi-name { flex: 1; min-width: 0; }
.order-item .oi-qty { color: var(--ink-3); font-size: 12px; }
.order-item .oi-price { font-variant-numeric: tabular-nums; font-weight: 500; min-width: 62px; text-align: right; }

.order-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-3);
  padding-top: 11px;
  border-top: 1px dashed var(--line);
}

.order-meta b { color: var(--ink-2); font-weight: 500; }

.order-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  background: #fbfdfd;
  flex-wrap: wrap;
}

.order-total {
  font-size: 15px;
  font-weight: 700;
  margin-right: auto;
  font-variant-numeric: tabular-nums;
}

.order-total small { font-size: 12px; font-weight: 600; }

/* ================= 设置页 ================= */
.set-section {
  border-bottom: 1px solid var(--line);
  padding: 18px 20px;
}

.set-section:last-child { border-bottom: none; }

.set-title {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 4px;
}

.set-desc {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 14px;
  line-height: 1.6;
}

.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}

/* ================= 文案编辑 ================= */
.pages-layout {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 16px;
  align-items: start;
}

.pages-nav {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 8px;
  position: sticky;
  top: 76px;
  box-shadow: var(--sh);
}

.pn {
  display: block;
  padding: 8px 11px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  margin-bottom: 2px;
  transition: all .15s;
}

.pn:hover { background: var(--brand-mist); }
.pn.on { background: var(--brand-soft); color: var(--brand-deep); font-weight: 600; }

/* ================= Toast ================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(22, 33, 31, .9);
  color: #fff;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 13.5px;
  z-index: 3000;
  box-shadow: var(--sh-lg);
  animation: toastIn .2s ease;
  max-width: 80vw;
  text-align: center;
}

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

.toast.err { background: rgba(201, 72, 77, .95); }
.toast.ok { background: rgba(36, 138, 53, .95); }

/* ================= 响应式 ================= */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--sh-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .tb-menu { display: block; }
  .content { padding: 14px 14px 60px; }
  .form-grid { grid-template-columns: 1fr; }
  .pages-layout { grid-template-columns: 1fr; }
  .pages-nav { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .pages-nav .pn { margin-bottom: 0; }
  .topbar { padding: 0 14px; }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 21px; }
  .order-meta { gap: 10px; }
}

/* 遮罩（移动端菜单） */
.sb-mask {
  position: fixed;
  inset: 0;
  background: rgba(22, 33, 31, .35);
  z-index: 99;
}

[hidden] { display: none !important; }
