:root {
  --bg: #f7f4ee;
  --panel: #fffdf9;
  --ink: #241f1a;
  --muted: #75695d;
  --line: #e5dbcf;
  --brand: #9b4d2a;
  --brand-dark: #713319;
  --accent: #267260;
  --danger: #b93636;
  --paid: #1f7a55;
  --unpaid: #b45d12;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.mobile-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 253, 249, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
}

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

.status-pill,
.pay-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: #efe2d4;
  color: var(--brand-dark);
}

.status-pill.open {
  background: #dff0e6;
  color: var(--accent);
}

.status-pill.closed,
.pay-pill.unpaid {
  background: #ffe7cc;
  color: var(--unpaid);
}

.pay-pill.paid {
  background: #dff0e6;
  color: var(--paid);
}

.pay-pill.pending {
  background: #dfeafa;
  color: #2457a6;
}

.page {
  padding: 16px;
}

.hero-band {
  padding: 16px;
  background: #fbefd9;
  border-bottom: 1px solid var(--line);
}

.hero-band strong {
  display: block;
  margin-bottom: 6px;
}

.section-title {
  margin: 20px 0 12px;
  font-size: 18px;
}

.product-list {
  display: grid;
  gap: 12px;
}

.product-row {
  display: grid;
  grid-template-columns: 86px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 98px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.product-row img {
  width: 86px;
  height: 76px;
  object-fit: cover;
  border-radius: 6px;
  background: #eadfce;
}

.product-name {
  font-weight: 800;
  margin-bottom: 6px;
}

.price {
  color: var(--brand);
  font-weight: 800;
}

.stepper {
  display: grid;
  grid-template-columns: 36px 42px 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.stepper button {
  width: 36px;
  height: 36px;
  background: #f1e4d7;
  color: var(--brand-dark);
  font-size: 22px;
  line-height: 1;
}

.stepper span {
  text-align: center;
  font-weight: 800;
}

.bottom-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: rgba(255, 253, 249, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.total-line {
  font-size: 15px;
}

.total-line b {
  color: var(--brand);
  font-size: 22px;
}

.primary,
.secondary,
.danger,
.ghost {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 800;
}

.primary {
  background: var(--brand);
  color: #fff;
}

.secondary {
  background: #e3efea;
  color: var(--accent);
}

.danger {
  background: #ffe1dc;
  color: var(--danger);
}

.ghost {
  background: transparent;
  color: var(--brand);
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.summary-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.summary-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  z-index: 99;
  max-width: min(88vw, 420px);
  padding: 10px 14px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: #231f1a;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

.hidden {
  display: none !important;
}

.success-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 24px auto 14px;
  border-radius: 50%;
  background: #dff0e6;
  color: var(--paid);
  font-size: 34px;
  font-weight: 900;
}

.order-row {
  display: grid;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

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

.admin-body {
  background: #f6f7f8;
}

.admin-shell {
  min-height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: #22272e;
  color: #fff;
}

.admin-header h1 {
  margin: 0;
  font-size: 18px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  min-height: calc(100vh - 56px);
}

.admin-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 14px;
  background: #2f363f;
}

.admin-nav button {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: #dbe2ea;
  text-align: left;
}

.admin-nav button.active {
  background: #fff;
  color: #22272e;
  font-weight: 800;
}

.admin-main {
  padding: 18px;
  overflow: auto;
}

.panel {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #dde2e8;
  border-radius: 8px;
  background: #fff;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.stat-box {
  padding: 12px;
  border: 1px solid #e1e5ea;
  border-radius: 8px;
  background: #fafbfc;
}

.stat-box span {
  display: block;
  color: #66707c;
  font-size: 12px;
}

.stat-box b {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar .field {
  min-width: 180px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #e1e5ea;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #e8ebef;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  background: #f2f4f6;
  color: #4b5562;
  font-size: 13px;
}

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

.mini {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  background: #eef2f6;
  color: #29313b;
  font-weight: 700;
}

.login-box {
  width: min(92vw, 380px);
  margin: 15vh auto;
  padding: 22px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.38);
}

.dialog {
  width: min(900px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
}

.item-editor {
  display: grid;
  grid-template-columns: 1fr 110px auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.proof-box {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
}

.proof-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.proof-box img {
  max-width: min(260px, 100%);
  max-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.image-field {
  min-width: 240px;
}

.image-drop {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 96px;
  padding: 12px;
  border: 1px dashed #cdbba8;
  border-radius: 8px;
  background: #fffaf2;
  cursor: pointer;
}

.image-drop.dragging {
  border-color: var(--brand);
  background: #fbefd9;
}

.image-file-input {
  display: none;
}

.image-drop-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.image-drop-copy strong {
  font-size: 14px;
}

.image-drop-copy small {
  color: var(--muted);
  font-size: 12px;
}

.image-preview {
  width: 82px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: #fff;
}

.clear-image-btn {
  width: fit-content;
}

@media (max-width: 820px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    grid-auto-flow: column;
    overflow: auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .product-row {
    grid-template-columns: 76px 1fr;
  }

  .product-row img {
    width: 76px;
    height: 68px;
  }

  .product-row .stepper {
    grid-column: 2;
    justify-self: start;
  }
}
