:root {
  --ink: #352f2a;
  --muted: #8a7e72;
  --line: #e9dfd4;
  --paper: #fffdf9;
  --cream: #f8f4ee;
  --coffee: #8b654a;
  --coffee-deep: #6f4b36;
  --coffee-pale: #eee1d5;
  --danger: #ad5a4e;
  --success: #667b63;
  --warning: #a8793e;
  --shadow: 0 20px 60px rgba(84, 62, 45, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(139, 101, 74, 0.18);
  outline-offset: 1px;
}

[hidden] {
  display: none !important;
}

.login-page {
  position: relative;
  display: grid;
  min-height: 100vh;
  overflow: hidden;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 88% 10%, #e8d5c7 0, transparent 28%),
    linear-gradient(145deg, #faf7f2 0%, #eee2d7 100%);
}

.login-page::before {
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(111, 75, 54, 0.14);
  content: "";
  pointer-events: none;
}

.login-ornament {
  position: absolute;
  border: 1px solid rgba(111, 75, 54, 0.14);
  border-radius: 50%;
}

.login-ornament-a {
  top: -18vw;
  right: -12vw;
  width: 50vw;
  height: 50vw;
}

.login-ornament-b {
  bottom: -26vw;
  left: -14vw;
  width: 55vw;
  height: 55vw;
}

.login-card {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  padding: 46px;
  background: rgba(255, 253, 249, 0.94);
  border: 1px solid rgba(111, 75, 54, 0.1);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand-mark,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark img,
.sidebar-brand img {
  width: 48px;
  height: 48px;
  border-radius: 13px;
}

.brand-mark strong,
.sidebar-brand strong {
  display: block;
  font-family: "Songti SC", "STSong", serif;
  font-size: 24px;
  letter-spacing: 5px;
}

.brand-mark span,
.sidebar-brand span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 1.8px;
}

.eyebrow {
  margin: 38px 0 8px;
  color: var(--coffee);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
}

.login-card h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 32px;
  font-weight: 600;
}

.login-copy {
  margin: 12px 0 30px;
  color: var(--muted);
  line-height: 1.8;
}

label {
  display: grid;
  gap: 8px;
}

label > span,
.field-label {
  color: #6f6258;
  font-size: 12px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffefa;
  transition: border-color 0.2s ease;
}

input,
select {
  height: 42px;
  padding: 0 13px;
}

textarea {
  min-height: 92px;
  padding: 11px 13px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #b8957b;
  outline: none;
}

#login-form {
  display: grid;
  gap: 18px;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: #fff;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
}

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

.button-primary {
  color: #fff;
  background: linear-gradient(135deg, #967056, #724f3a);
  box-shadow: 0 8px 20px rgba(111, 75, 54, 0.18);
}

.button-ghost {
  color: var(--coffee);
  border-color: #dfd0c2;
  background: #fbf7f2;
}

.button-danger {
  color: var(--danger);
  border-color: #eed4cf;
  background: #fff9f7;
}

.button-small {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 7px;
  font-size: 12px;
}

.button-block {
  width: 100%;
  min-height: 48px;
}

.form-error {
  margin: 0;
  padding: 9px 12px;
  color: var(--danger);
  background: #fbefec;
  border-radius: 7px;
  font-size: 12px;
}

.login-tip {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  padding: 30px 22px 22px;
  color: #f7f0e9;
  background:
    linear-gradient(rgba(80, 57, 43, 0.92), rgba(80, 57, 43, 0.98)),
    url("/assets/hero.svg") center / cover;
}

.sidebar-brand {
  padding: 0 8px 28px;
  color: #fff;
  text-decoration: none;
}

.sidebar-brand img {
  width: 42px;
  height: 42px;
}

.sidebar-brand strong {
  font-size: 21px;
}

.sidebar-brand span {
  color: #d6c2b3;
}

#nav {
  display: grid;
  gap: 5px;
}

.nav-item {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 13px;
  padding: 0 14px;
  color: #d9c9bc;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
}

.nav-item span {
  color: #a88d7b;
  font-family: Georgia, serif;
  font-size: 11px;
}

.nav-item b {
  min-width: 19px;
  margin-left: auto;
  padding: 2px 6px;
  color: #fff;
  background: #b77e61;
  border-radius: 99px;
  font-size: 10px;
  text-align: center;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.nav-item.active span {
  color: #e9d9ca;
}

.sidebar-foot {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding: 22px 8px 0;
  color: #cdb9a9;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
}

.sidebar-foot button {
  width: max-content;
  padding: 0;
  color: #f6eee7;
  border: 0;
  background: none;
}

.main-content {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 4;
  top: 0;
  display: flex;
  min-height: 108px;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(24px, 4vw, 56px);
  background: rgba(248, 244, 238, 0.9);
  border-bottom: 1px solid rgba(111, 75, 54, 0.09);
  backdrop-filter: blur(14px);
}

.topbar .eyebrow {
  margin: 0 0 5px;
}

.topbar h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 27px;
  font-weight: 600;
  letter-spacing: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  color: var(--success);
  border: 1px solid #d9e0d6;
  border-radius: 99px;
  background: #f8faf6;
  font-size: 11px;
}

.status-pill i {
  width: 6px;
  height: 6px;
  background: #718b6c;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(113, 139, 108, 0.12);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  color: var(--coffee);
  border: 1px solid #e0d4c9;
  border-radius: 50%;
  background: #fffdfa;
  font-size: 20px;
  place-items: center;
}

.view {
  padding: 32px clamp(20px, 4vw, 56px) 64px;
}

.loading,
.empty-state {
  display: grid;
  min-height: 280px;
  color: var(--muted);
  place-items: center;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 142px;
  padding: 22px;
  background: var(--paper);
  border: 1px solid rgba(111, 75, 54, 0.09);
  border-radius: 12px;
}

.metric-card::after {
  position: absolute;
  right: -33px;
  bottom: -50px;
  width: 120px;
  height: 120px;
  border: 1px solid var(--coffee-pale);
  border-radius: 50%;
  content: "";
}

.metric-card > span {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 18px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 34px;
  font-weight: 500;
}

.metric-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
  gap: 18px;
  margin-top: 18px;
}

.panel {
  padding: 24px;
  background: var(--paper);
  border: 1px solid rgba(111, 75, 54, 0.09);
  border-radius: 12px;
}

.panel-head,
.toolbar,
.section-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-head {
  margin-bottom: 22px;
}

.panel-head h2,
.section-bar h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 19px;
  font-weight: 600;
}

.panel-head p,
.section-bar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.trend {
  display: flex;
  height: 190px;
  align-items: flex-end;
  gap: clamp(8px, 2vw, 22px);
  padding-top: 24px;
}

.trend-col {
  display: flex;
  min-width: 24px;
  height: 100%;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  text-align: center;
}

.trend-bar {
  position: relative;
  width: 72%;
  min-height: 4px;
  margin: 0 auto;
  background: linear-gradient(180deg, #b28e75, #d8c3b3);
  border-radius: 4px 4px 0 0;
}

.trend-bar span {
  position: absolute;
  top: -21px;
  left: 50%;
  color: var(--coffee);
  font-size: 10px;
  transform: translateX(-50%);
}

.trend-col label {
  color: var(--muted);
  font-size: 9px;
}

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

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #f1eae3;
}

.list-row:last-child {
  border: 0;
}

.list-row-main {
  min-width: 0;
  flex: 1;
}

.list-row strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row span {
  color: var(--muted);
  font-size: 10px;
}

.section-bar {
  margin-bottom: 20px;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-bottom: 16px;
  padding: 14px;
  background: #fbf7f2;
  border: 1px solid #eee4db;
  border-radius: 10px;
}

.toolbar input {
  width: min(260px, 100%);
}

.toolbar select {
  width: auto;
  min-width: 140px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid rgba(111, 75, 54, 0.09);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th,
td {
  padding: 15px 16px;
  border-bottom: 1px solid #f0e8df;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #fbf7f2;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

td {
  font-size: 12px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fffcf7;
}

.order-no {
  color: var(--coffee-deep);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
}

.order-product {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.order-product img,
.product-thumb {
  width: 46px;
  height: 56px;
  border-radius: 7px;
  object-fit: cover;
  background: #f0e7dd;
}

.order-product div {
  max-width: 190px;
}

.order-product strong,
.product-cell strong {
  display: block;
  overflow: hidden;
  max-width: 180px;
  text-overflow: ellipsis;
}

.order-product small,
.product-cell small {
  color: var(--muted);
  font-size: 10px;
}

.product-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
}

.badge.paid,
.badge.accepted {
  color: #9b6c34;
  background: #f7edda;
}

.badge.delivering,
.badge.runner_assigned,
.badge.ready_for_pickup {
  color: #486986;
  background: #e9f0f6;
}

.badge.completed {
  color: var(--success);
  background: #ebf0e8;
}

.badge.cancelled,
.badge.inactive {
  color: var(--danger);
  background: #f8e9e6;
}

.badge.active {
  color: var(--success);
  background: #ebf0e8;
}

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

.link-button {
  padding: 0;
  color: var(--coffee);
  border: 0;
  background: none;
  font-size: 11px;
}

.link-button.danger {
  color: var(--danger);
}

.card-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.product-card,
.coupon-card,
.review-card {
  position: relative;
  padding: 18px;
  background: var(--paper);
  border: 1px solid rgba(111, 75, 54, 0.09);
  border-radius: 12px;
}

.product-card-top {
  display: flex;
  gap: 14px;
}

.product-card .product-thumb {
  width: 76px;
  height: 94px;
}

.product-card h3,
.coupon-card h3,
.review-card h3 {
  margin: 0 0 7px;
  font-size: 14px;
}

.product-card p,
.coupon-card p,
.review-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 15px 0;
}

.stock-chip {
  padding: 4px 8px;
  color: #766355;
  background: #f4ede6;
  border-radius: 5px;
  font-size: 10px;
}

.stock-chip.low {
  color: var(--danger);
  background: #faece8;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.coupon-card {
  overflow: hidden;
  padding-left: 24px;
}

.coupon-card::before {
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 0;
  width: 3px;
  background: #b58c70;
  border-radius: 0 8px 8px 0;
  content: "";
}

.coupon-amount {
  margin: 14px 0 4px;
  color: var(--coffee);
  font-family: "Songti SC", "STSong", serif;
  font-size: 34px;
}

.coupon-amount small {
  margin-left: 4px;
  font-family: inherit;
  font-size: 12px;
}

.review-rating {
  margin: 14px 0;
  color: #bd8e55;
  letter-spacing: 3px;
}

.review-card blockquote {
  margin: 12px 0;
  color: #5d5148;
  font-size: 12px;
  line-height: 1.8;
}

.review-images {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.review-images img {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.settings-panel {
  display: grid;
  gap: 16px;
}

.settings-panel.full {
  grid-column: 1 / -1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.help-text {
  margin: -7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  overflow-y: auto;
  padding: 24px;
  background: rgba(52, 40, 32, 0.42);
  backdrop-filter: blur(4px);
  place-items: start center;
}

.modal {
  width: min(760px, 100%);
  margin: max(24px, 5vh) 0;
  background: var(--paper);
  border-radius: 15px;
  box-shadow: 0 30px 80px rgba(49, 36, 28, 0.2);
}

.modal.small {
  width: min(480px, 100%);
}

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

.modal-head h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 21px;
}

.modal-close {
  width: 32px;
  height: 32px;
  color: var(--muted);
  border: 0;
  border-radius: 50%;
  background: #f5eee8;
  font-size: 18px;
}

.modal-body {
  padding: 24px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 24px;
  border-top: 1px solid var(--line);
  background: #fcf8f3;
}

.modal-form {
  display: grid;
  gap: 16px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.order-detail-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 22px;
}

.detail-box {
  padding: 16px;
  background: #fbf7f2;
  border-radius: 9px;
}

.detail-box h3 {
  margin: 0 0 10px;
  font-size: 12px;
}

.detail-box p {
  margin: 6px 0;
  color: #66594f;
  font-size: 11px;
  line-height: 1.7;
}

.detail-items {
  display: grid;
  gap: 10px;
}

.detail-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-item img {
  width: 48px;
  height: 60px;
  border-radius: 7px;
  object-fit: cover;
}

.detail-item div {
  min-width: 0;
  flex: 1;
}

.detail-item strong,
.detail-item span {
  display: block;
  font-size: 11px;
}

.detail-item span {
  margin-top: 4px;
  color: var(--muted);
}

.timeline {
  display: grid;
  gap: 0;
  margin-top: 20px;
}

.timeline-row {
  position: relative;
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  padding-bottom: 16px;
}

.timeline-row::before {
  position: absolute;
  top: 9px;
  bottom: 0;
  left: 4px;
  width: 1px;
  background: #e4d7cc;
  content: "";
}

.timeline-row:last-child::before {
  display: none;
}

.timeline-dot {
  width: 9px;
  height: 9px;
  margin-top: 3px;
  background: #ad8a72;
  border: 2px solid #efe3d9;
  border-radius: 50%;
}

.timeline-row strong {
  display: block;
  font-size: 11px;
}

.timeline-row span {
  color: var(--muted);
  font-size: 9px;
}

.toast-root {
  position: fixed;
  z-index: 200;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 10px;
}

.toast {
  min-width: 220px;
  padding: 13px 16px;
  color: #fff;
  background: #4d4037;
  border-radius: 9px;
  box-shadow: 0 10px 30px rgba(48, 37, 30, 0.25);
  font-size: 12px;
  animation: toast-in 0.25s ease both;
}

.toast.error {
  background: #9f554b;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@media (max-width: 1080px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: relative;
    display: block;
    height: auto;
    padding: 16px;
    background: #5c4334;
  }

  .sidebar-brand {
    padding: 0 4px 14px;
  }

  .sidebar-brand img {
    width: 34px;
    height: 34px;
  }

  .sidebar-brand strong {
    font-size: 17px;
  }

  #nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .nav-item {
    min-width: max-content;
    min-height: 38px;
    padding: 0 11px;
    font-size: 12px;
  }

  .nav-item span,
  .sidebar-foot {
    display: none;
  }

  .topbar {
    min-height: 82px;
    padding: 14px 20px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .topbar .eyebrow,
  .status-pill {
    display: none;
  }

  .view {
    padding: 20px 14px 48px;
  }

  .panel-grid,
  .settings-grid,
  .order-detail-grid {
    grid-template-columns: 1fr;
  }

  .settings-panel.full {
    grid-column: auto;
  }

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

  .form-grid .full {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .login-page {
    padding: 14px;
  }

  .login-card {
    padding: 30px 24px;
  }

  .login-card h1 {
    font-size: 27px;
  }

  .metric-grid,
  .card-list {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 118px;
  }

  .metric-card strong {
    margin-top: 10px;
    font-size: 28px;
  }

  .section-bar {
    align-items: flex-start;
  }

  .toolbar input {
    width: 100%;
  }

  .toolbar select {
    flex: 1;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal {
    margin: 10px 0;
    border-radius: 11px;
  }

  .toast-root {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .toast {
    min-width: 0;
  }
}
