/* ============================================================
   寝室小卖部 · Design System
   ============================================================ */
:root {
  --cream: #fff8ee;
  --cream-2: #fff2e0;
  --paper: #fffdf9;
  --paper-2: #fffaf2;
  --ink: #241a13;
  --ink-2: #4e3f33;
  --muted: #948274;
  --muted-2: #b8a695;
  --line: #f0e3d2;
  --line-2: #e6d5c0;
  --orange: #ff6b35;
  --orange-deep: #e8501c;
  --orange-soft: #fff0e8;
  --amber: #ffb703;
  --amber-soft: #fff7dd;
  --green: #159b6f;
  --green-soft: #e8f8f1;
  --red: #e5484d;
  --red-soft: #ffeceb;
  --blue: #3b74f2;
  --blue-soft: #eaf1ff;
  --purple: #8157e0;
  --purple-soft: #f2ecff;
  --cyan: #0d9cbb;
  --cyan-soft: #e6f8fc;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --shadow-sm: 0 2px 8px rgba(74, 45, 21, 0.05);
  --shadow: 0 12px 32px rgba(74, 45, 21, 0.08);
  --shadow-lg: 0 28px 70px rgba(56, 31, 12, 0.16);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-num: "DIN Alternate", "Bahnschrift", "Segoe UI", var(--font);
  --header-h: 74px;
  --accent: var(--orange);
  --accent-deep: var(--orange-deep);
  --accent-soft: var(--orange-soft);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, h4, h5, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img, svg { display: block; }
ul, ol { margin: 0; padding: 0; list-style: none; }
::selection { background: #ffd9c7; color: var(--ink); }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #dcc9b2; border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

.container { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.icon { flex: none; display: inline-block; vertical-align: -3px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--font-num); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover { border-color: #d8c3ab; box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary {
  color: #fff;
  background: var(--accent);
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(255, 107, 53, 0.26);
}
.btn-primary:hover { background: var(--accent-deep); border-color: transparent; box-shadow: 0 10px 24px rgba(255, 107, 53, 0.32); }
.btn-dark { background: var(--ink); color: #fff; border-color: transparent; }
.btn-dark:hover { background: #3a2c22; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(78, 63, 51, 0.06); box-shadow: none; }
.btn-soft { background: var(--accent-soft); color: var(--accent-deep); border-color: transparent; }
.btn-soft:hover { background: #ffe6d9; }
.btn-danger { background: var(--red); color: #fff; border-color: transparent; }
.btn-danger:hover { background: #cf3a3f; }
.btn-outline-danger { color: var(--red); border-color: #f3c2c2; background: #fff; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; gap: 5px; }
.btn-lg { height: 50px; padding: 0 26px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 11px; }
.btn[disabled] .spinner { display: inline-block; }

.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: "";
  position: absolute;
  width: 17px; height: 17px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-ghost.btn-loading::after, .btn-soft.btn-loading::after { border-color: rgba(36,26,19,.2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 13px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-2);
  position: relative;
  transition: all .15s;
}
.icon-btn:hover { border-color: #ddc7ae; box-shadow: var(--shadow-sm); color: var(--ink); }

/* ---------------- Badges / chips ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  border-radius: 7px;
  font-size: 11.5px; font-weight: 600;
  background: var(--cream-2); color: var(--ink-2);
  white-space: nowrap;
}
.badge.orange { background: var(--orange-soft); color: var(--orange-deep); }
.badge.amber { background: var(--amber-soft); color: #966200; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }
.badge.cyan { background: var(--cyan-soft); color: var(--cyan); }
.badge.gray { background: #f2eee8; color: #8c7c6d; }
.badge.dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 15px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13.5px; font-weight: 500;
  transition: all .16s;
  white-space: nowrap;
}
.chip:hover { border-color: #e4cbaf; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: 0 6px 16px rgba(36,26,19,.16); }

/* ---------------- Forms ---------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .field-label {
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: 6px;
}
.field .hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.field .req { color: var(--red); }
.input, .select, .textarea {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border-radius: 11px;
  border: 1px solid var(--line-2);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: #bcab9b; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255,107,53,.12);
}
.textarea { height: auto; min-height: 86px; padding: 11px 13px; resize: vertical; line-height: 1.55; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23948274' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group .icon { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.input-group .input { padding-left: 40px; }
.input-suffix { position: absolute; right: 12px; color: var(--muted); font-size: 12.5px; }
.input-wrap-pwd .toggle-pwd { position: absolute; right: 8px; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.input-wrap-pwd .toggle-pwd:hover { background: #f7f0e7; }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 42px; height: 24px; border-radius: 99px;
  background: #e4d7c8; position: relative; transition: background .18s;
  flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch .switch-label { font-size: 13.5px; color: var(--ink-2); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-error { background: var(--red-soft); color: #b3262b; padding: 10px 12px; border-radius: 10px; font-size: 12.5px; }

/* ---------------- Card / table ---------------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }
.card-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }

.table-wrap { width: 100%; overflow-x: auto; }
table.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.data-table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: #fffaf2;
}
.data-table th:first-child { border-top-left-radius: 10px; }
.data-table th:last-child { border-top-right-radius: 10px; }
.data-table td { padding: 13px 12px; border-bottom: 1px solid #f6ecdf; vertical-align: middle; }
.data-table tbody tr:hover td { background: #fffaf4; }
.data-table tr:last-child td { border-bottom: 0; }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(36, 26, 19, 0.46);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity .22s ease;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  width: min(560px, 100%);
  max-height: min(88vh, 900px);
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: auto;
  transform: translateY(14px) scale(.985);
  opacity: 0;
  transition: transform .24s cubic-bezier(.2,.8,.25,1), opacity .2s;
}
.modal-backdrop.show .modal { transform: none; opacity: 1; }
.modal-sm { width: min(420px, 100%); }
.modal-md { width: min(640px, 100%); }
.modal-lg { width: min(820px, 100%); }
.modal-full {
  width: min(1040px, 100%);
  height: min(90vh, 920px);
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,.85); color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  z-index: 3;
}
.modal-close:hover { background: #fff; }
.modal-head { padding: 22px 24px 0; position: relative; }
.modal-head h3 { font-size: 19px; font-weight: 800; letter-spacing: -.2px; }
.modal-head p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.modal-body { padding: 20px 24px; }
.modal-foot { padding: 16px 24px 22px; border-top: 1px solid var(--line); background: #fffdfa; }

.confirm-box { padding: 28px; text-align: center; }
.confirm-icon {
  width: 54px; height: 54px; margin: 0 auto 14px;
  border-radius: 16px; background: var(--amber-soft); color: #a66a00;
  display: flex; align-items: center; justify-content: center;
}
.confirm-icon.danger { background: var(--red-soft); color: var(--red); }
.confirm-box h3 { font-size: 18px; }
.confirm-box p { color: var(--muted); font-size: 13px; margin-top: 8px; line-height: 1.6; }
.confirm-box .modal-actions { justify-content: center; }

/* ---------------- Toast ---------------- */
.toast-wrap {
  position: fixed; z-index: 2000; left: 50%; top: 22px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: min(460px, calc(100% - 32px));
}
.toast {
  display: flex; align-items: center; gap: 9px;
  background: rgba(36,26,19,.94); color: #fff;
  padding: 11px 16px; border-radius: 12px;
  font-size: 13.5px; box-shadow: 0 12px 34px rgba(0,0,0,.22);
  opacity: 0; transform: translateY(-8px);
  transition: all .22s; max-width: 100%;
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: none; }
.toast-icon { display: flex; color: #ffd166; }
.toast-success .toast-icon { color: #5ee2b0; }
.toast-error .toast-icon { color: #ff8d8d; }

/* ---------------- Empty / misc ---------------- */
.empty-state { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-emoji { font-size: 42px; margin-bottom: 10px; filter: grayscale(.15); }
.empty-state h4 { color: var(--ink-2); font-size: 14.5px; margin-bottom: 4px; }
.empty-state p { font-size: 12.5px; max-width: 280px; margin: 0 auto; line-height: 1.6; }

.emoji-tile {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 16px; flex: none;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.04);
}
.emoji-tile > span { line-height: 1; filter: drop-shadow(0 3px 4px rgba(80,40,0,.1)); }
.emoji-xs { width: 34px; height: 34px; font-size: 19px; border-radius: 10px; }
.emoji-sm { width: 44px; height: 44px; font-size: 24px; border-radius: 12px; }
.emoji-md { width: 58px; height: 58px; font-size: 31px; border-radius: 15px; }
.emoji-lg { width: 78px; height: 78px; font-size: 42px; border-radius: 20px; }
.emoji-xl { width: 104px; height: 104px; font-size: 58px; border-radius: 26px; }

.avatar {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--orange-soft); color: var(--orange-deep);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; flex: none;
}

.stars { display: inline-flex; gap: 1px; color: #e5d8c8; }
.stars .star.on { color: #ffb703; }
.stars svg { fill: currentColor; stroke: none; }

.divider { height: 1px; background: var(--line); border: 0; margin: 16px 0; }
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(36,26,19,.15);
  border-top-color: var(--orange); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
.loading-block { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); font-size: 13px; }

/* ---------------- Skeleton ---------------- */
.skeleton {
  background: linear-gradient(90deg, #f4eadc 25%, #fbf4ea 37%, #f4eadc 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: 8px;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------- Responsive ---------------- */
@media (max-width: 720px) {
  body { font-size: 14px; }
  .container { width: calc(100% - 28px); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { border-radius: 22px 22px 0 0; max-height: 92vh; width: 100%; }
  .modal-full { height: 94vh; max-height: 94vh; border-radius: 22px 22px 0 0; }
  .modal-sm, .modal-md, .modal-lg { width: 100%; }
  .modal-head { padding: 20px 18px 0; }
  .modal-body { padding: 16px 18px; }
  .modal-foot { padding: 14px 18px calc(16px + env(safe-area-inset-bottom)); }
  .modal-actions .btn { flex: 1; }
  .toast-wrap { top: 12px; }
}
