:root {
  color-scheme: light;
  --bg: #f3f5f2;
  --panel: #ffffff;
  --text: #172018;
  --muted: #6f7b73;
  --line: #dde6de;
  --green: #10b956;
  --green-dark: #087c39;
  --red: #e84832;
  --orange: #f59e0b;
  --blue: #2563eb;
  --shadow: 0 12px 30px rgba(24, 36, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-width: 1120px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.login-view {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  background: linear-gradient(135deg, #edf8ef 0%, #d8f1e4 45%, #f7faf6 100%);
}

body.auth-pending .login-view,
body.logged-out .login-view {
  display: grid;
}

body.auth-pending .sidebar,
body.auth-pending .main,
body.logged-out .sidebar,
body.logged-out .main {
  pointer-events: none;
  filter: blur(1px);
}

.login-card {
  display: grid;
  gap: 14px;
  width: 380px;
  padding: 34px;
  border: 1px solid rgba(16, 185, 86, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 26px 70px rgba(20, 52, 30, 0.16);
}

.login-logo {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  object-fit: contain;
}

.login-card p {
  color: var(--muted);
  font-size: 14px;
}

.login-card h1 {
  margin-bottom: 6px;
  font-size: 28px;
}

.login-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.login-card input {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 46px 0 14px;
  color: var(--text);
  outline: none;
}

.login-card input:focus {
  border-color: rgba(16, 185, 86, 0.64);
  box-shadow: 0 0 0 4px rgba(16, 185, 86, 0.1);
}

.login-submit {
  height: 46px;
  margin-top: 4px;
}

.login-hint {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 22px 18px;
  background: #0e1f15;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 4px 24px;
}

.brand-logo,
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--green);
}

.brand-logo {
  display: block;
  padding: 3px;
  object-fit: contain;
  background: #ffffff;
}

.brand-mark {
  font-size: 20px;
  font-weight: 900;
}

.brand p {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.brand h1 {
  margin-top: 4px;
  font-size: 21px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  position: relative;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  text-align: left;
}

.nav-badge {
  position: absolute;
  top: 50%;
  right: 12px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ff3b30;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  transform: translateY(-50%);
  box-shadow: 0 6px 16px rgba(255, 59, 48, 0.32);
}

.nav-badge.hidden {
  display: none;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(16, 185, 86, 0.18);
  color: #fff;
  font-weight: 800;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logout-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--orange);
}

.dot.online {
  background: var(--green);
}

.dot.offline {
  background: var(--red);
}

.aftersale-meta {
  color: #b45309;
  font-weight: 700;
}

.main {
  min-width: 0;
  padding: 24px 30px 42px;
}

.section-head,
.panel-head,
.filters,
.form-actions,
.order-actions,
.stock-actions {
  display: flex;
  align-items: center;
}






.section {
  display: none;
}

.section.active {
  display: block;
}

.section-head {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.section-tools {
  justify-content: flex-end;
  margin-bottom: 14px;
}

.section-tools .filters {
  margin-left: auto;
}

.management-head {
  align-items: flex-start;
}

.management-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 0 0 auto;
}

.toolbar-btn {
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.management-actions .inline-switch {
  margin-left: 0;
}

.section-head h3,
.panel h3 {
  font-size: 21px;
}

.section-head p,
.panel-head p,
.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card,
.panel,
.order,
.product,
.inventory-row,
.product-form,
.settings-form {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 16px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  color: var(--text);
  font-size: 27px;
  font-weight: 900;
}

.stat-card em {
  color: #8b948e;
  font-size: 12px;
  font-style: normal;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.compact-list {
  display: grid;
  gap: 10px;
}

.compact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border-radius: 10px;
  background: #f7faf7;
}

.compact-row strong,
.compact-row span {
  display: block;
}

.compact-row strong {
  font-size: 14px;
}

.compact-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.compact-row em {
  flex: 0 0 auto;
  color: var(--red);
  font-style: normal;
  font-weight: 900;
}

.compact-row em.warn {
  color: #a45d00;
}

.filters {
  gap: 10px;
}

.orders-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -4px 0 14px;
  padding: 10px 0 12px;
  background: var(--bg);
}

.orders-toolbar .filters {
  flex: 0 0 auto;
}

.orders-filterbar {
  display: grid;
  grid-template-columns: minmax(360px, auto) minmax(260px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin: 0 0 14px;
}

.order-toolbar-actions {
  display: inline-flex;
  align-items: end;
  gap: 8px;
  height: 40px;
}

.date-filter-group {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.date-filter-group label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.date-filter-group select,
.custom-date-range input,
.export-form select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  outline: none;
}

.date-filter-group select {
  min-width: 160px;
  padding: 0 46px 0 12px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%2315251b' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  background-size: 14px 14px;
}

.custom-date-range {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.custom-date-range input {
  width: 142px;
  padding: 0 10px;
}

.custom-date-range span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.order-filter-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 40px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.order-filter-summary span,
.order-filter-summary small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.order-filter-summary strong {
  color: var(--text);
  font-size: 15px;
}

.order-filter-summary em {
  color: var(--red);
  font-style: normal;
  font-weight: 900;
}

.filters input,
.product-form input,
.settings-form input,
.settings-form select,
.settings-form textarea,
.field-row input {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.filters input {
  width: 320px;
  height: 40px;
  min-width: 0;
  padding: 0 12px;
}

.order-search input {
  width: clamp(280px, 24vw, 380px);
}

.filters input:focus,
.product-form input:focus,
.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus,
.field-row input:focus {
  border-color: rgba(16, 185, 86, 0.7);
  box-shadow: 0 0 0 3px rgba(16, 185, 86, 0.1);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

#ordersSection .tabs {
  flex: 1 1 auto;
  margin-bottom: 0;
}

.tab,
.ghost-btn,
.link-btn,
.order-actions button,
.order-actions select,
.form-actions button,
.product button,
.stock-actions button,
.setting-panel button {
  height: 38px;
  padding: 0 13px;
  border-radius: 9px;
  background: #eef4ef;
  color: var(--text);
  font-weight: 700;
}

.order-actions select {
  width: 100%;
  border: 1px solid var(--line);
}

.tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}

.tab.active {
  border-color: var(--green);
  background: #e7f8ee;
  color: var(--green-dark);
}

.link-btn {
  background: transparent;
  color: var(--green-dark);
}

.primary,
.order-actions .primary,
.form-actions .primary,
.setting-panel .primary {
  background: var(--green);
  color: #fff;
}

.danger,
button.danger,
.small-danger {
  background: #feeceb;
  color: var(--red);
}

.order-list {
  display: grid;
  gap: 18px;
}

.order-date-group {
  display: grid;
  gap: 10px;
}

.order-date-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px 6px;
  background: var(--bg);
}

.order-date-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.order-date-header span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.order-date-items {
  display: grid;
  gap: 12px;
}

.load-more-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.load-more-row.muted-only {
  padding-bottom: 8px;
}

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

.user-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.user-card img {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  background: #eaf8ef;
}

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

.user-main h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 16px;
}

.user-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, auto));
  gap: 8px;
  text-align: center;
}

.user-stats span {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f5faf7;
  color: var(--muted);
  font-size: 12px;
}

.user-stats strong {
  color: var(--text);
  font-size: 16px;
}

.order {
  display: grid;
  grid-template-columns: minmax(300px, 1.08fr) minmax(290px, 1fr) minmax(252px, 0.72fr);
  gap: 0;
  align-items: stretch;
  overflow: hidden;
  padding: 0;
}

.order-main,
.order-items,
.order-summary {
  min-width: 0;
  padding: 16px 17px;
}

.order-main,
.order-items {
  border-right: 1px solid #edf2ee;
}

.order-main {
  display: grid;
  align-content: start;
  gap: 10px;
}

.order-items {
  background: #fcfdfb;
}

.order-summary {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  min-height: 100%;
  background: #fff;
}

.order-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.order-title-row h3,
.rider-row h3,
.building-row h3 {
  min-width: 0;
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rider-row h3 {
  margin-bottom: 8px;
}

.order-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 10px;
  align-items: center;
}

.order-contact span,
.order-contact strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.55;
}

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

.order-contact strong {
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f6f2;
  color: #3e4c42;
}

.order-meta-grid {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.order-meta-grid span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-flow {
  display: grid;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px dashed #dbe5dc;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.items {
  display: grid;
  gap: 0;
  font-size: 14px;
}

.order-receipt-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf2ee;
}

.order-receipt-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.order-receipt-summary strong {
  color: var(--red);
  font-size: 20px;
  white-space: nowrap;
}

.order-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 7px 0;
  border-bottom: 1px dashed #e1e9e2;
}

.order-item-row:first-child {
  padding-top: 0;
}

.order-item-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.order-item-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.order-item-row em {
  color: #59665d;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.amount {
  color: var(--red);
  font-size: 21px;
  font-weight: 900;
}

.order-corner {
  display: flex;
  justify-content: flex-end;
  min-height: 70px;
}

.delivered-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 94px;
  height: 54px;
  transform: rotate(-10deg);
  border: 3px solid var(--red);
  border-radius: 10px;
  color: var(--red);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0;
  background: rgba(255, 59, 48, 0.04);
  box-shadow: inset 0 0 0 2px rgba(255, 59, 48, 0.14);
}

.deleted-stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 94px;
  height: 54px;
  transform: rotate(-10deg);
  border: 3px solid #8a93a0;
  border-radius: 10px;
  color: #6b7280;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0;
  background: rgba(107, 114, 128, 0.04);
  box-shadow: inset 0 0 0 2px rgba(107, 114, 128, 0.14);
}

.badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  height: 25px;
  padding: 0 9px;
  border-radius: 999px;
  background: #edf2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.delivering {
  background: #fff4d8;
  color: #9a5a00;
}

.badge.shipping {
  background: #e7f8ee;
  color: var(--green-dark);
}

.badge.pending_payment {
  background: #fff4d8;
  color: #9a5a00;
}

.badge.completed {
  background: #feeceb;
  color: var(--red);
  border: 1px solid rgba(255, 59, 48, 0.2);
}

.badge.canceled {
  background: #feeceb;
  color: var(--red);
}

.badge.deleted,
.badge.order-user {
  background: #eef2f7;
  color: #607086;
}

.deleted-meta {
  color: #8a4b00;
  font-weight: 800;
}

.deleted-order {
  opacity: 0.92;
}

.delivery-meta {
  color: #42526a;
}

.dispatch-meta {
  color: #0f766e;
  font-weight: 700;
}

.order-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: auto;
}

.order-actions button,
.order-actions select {
  width: 100%;
  min-width: 0;
}

.order-actions select,
.order-actions button[data-action="ready-order"],
.order-actions button[data-action="view-order"],
.order-actions button[data-action="print"] {
  grid-column: 1 / -1;
}

.review-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.review-summary span {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.review-summary strong {
  color: var(--text);
  font-size: 18px;
}

.review-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 18px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.review-card.hidden-review {
  background: #f8fafc;
}

.review-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.review-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.review-title-row h3 {
  margin: 0;
  font-size: 17px;
}

.review-rating span {
  color: #cbd5e1;
  font-size: 18px;
  font-weight: 900;
}

.review-rating span.on {
  color: #f59e0b;
}

.review-main p {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

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

.review-tags span {
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f6f2;
  color: #3e4c42;
  font-size: 12px;
  font-weight: 800;
}

.review-actions {
  display: grid;
  gap: 8px;
}

.review-actions button {
  width: 100%;
  height: 38px;
  border-radius: 9px;
  background: #eef4ef;
  color: var(--text);
  font-weight: 800;
}

.review-actions .danger {
  background: #feeceb;
  color: var(--red);
}

@media (max-width: 1380px) {
  .orders-toolbar {
    align-items: flex-start;
    flex-direction: column-reverse;
  }

  .orders-toolbar .filters,
  .order-search input {
    width: 100%;
  }

  .orders-filterbar {
    grid-template-columns: 1fr;
  }

  .date-filter-group,
  .custom-date-range {
    width: 100%;
  }

  .date-filter-group label,
  .date-filter-group select,
  .custom-date-range input,
  .orders-filterbar .toolbar-btn,
  .order-toolbar-actions {
    width: 100%;
  }

  .order-toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: auto;
  }

  .order {
    grid-template-columns: minmax(280px, 1fr) minmax(270px, 0.92fr) minmax(238px, 0.72fr);
  }

  .order-main,
  .order-items,
  .order-summary {
    padding: 15px;
  }

  .review-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .order {
    grid-template-columns: minmax(0, 1fr);
  }

  .order-main,
  .order-items {
    border-right: 0;
    border-bottom: 1px solid #edf2ee;
  }

  .order-summary {
    gap: 12px;
  }

  .order-corner {
    justify-content: flex-start;
    min-height: 0;
  }
}

.rider-row,
.building-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px 280px;
  gap: 18px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.building-row {
  grid-template-columns: minmax(0, 1fr) 260px;
}

.building-row.offline {
  opacity: 0.66;
}

.dispatch-pool-note {
  padding: 12px 14px;
  border: 1px solid #cfe8d8;
  border-radius: 10px;
  background: #f0fbf4;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.rider-stat {
  justify-self: center;
  min-width: 96px;
  text-align: center;
}

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

.rider-actions button,
.building-actions button {
  height: 38px;
  padding: 0 13px;
  border-radius: 9px;
  background: #eef4ef;
  color: var(--text);
  font-weight: 700;
}

.rider-actions button.danger,
.building-actions button.danger {
  background: #feeceb;
  color: var(--red);
}

.product-form {
  display: grid;
  grid-template-columns: 1.7fr 1fr 0.8fr 0.7fr 0.7fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 16px;
}

.product-form label,
.settings-form label,
.field-row {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.product-form input,
.settings-form input,
.settings-form select,
.field-row input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
}

.settings-form textarea {
  width: 100%;
  padding: 10px 11px;
  resize: vertical;
}

#buildingBackups,
#riderBuildings {
  height: auto;
  min-height: 132px;
  padding: 8px 10px;
}

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

.product {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.product.offline {
  opacity: 0.64;
}

.product img {
  width: 94px;
  height: 94px;
  border-radius: 10px;
  object-fit: contain;
  background: #f5f5ef;
}

.product h3 {
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product .price {
  margin-top: 7px;
  color: var(--red);
  font-size: 19px;
  font-weight: 900;
}

.product-tags {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.product-tags span {
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf4ef;
  color: var(--green-dark);
  font-size: 12px;
  line-height: 22px;
}

.product-tags .danger-tag {
  background: #fff1dc;
  color: #a45d00;
}

.product .actions {
  display: flex;
  gap: 8px;
  margin-top: 11px;
}

.inventory-list {
  display: grid;
  gap: 10px;
}

.inventory-row {
  display: grid;
  grid-template-columns: 1fr 120px 360px;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
}

.inventory-row.warning {
  border-color: #ffd490;
  background: #fffaf0;
}

.inventory-row strong,
.inventory-row span {
  display: block;
}

.inventory-row strong {
  font-size: 17px;
}

.inventory-row span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.stock-number {
  color: var(--text);
  font-size: 28px;
  font-weight: 900;
  text-align: center;
}

.stock-actions {
  justify-content: flex-end;
  gap: 8px;
}

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

.setting-panel {
  display: grid;
  align-content: start;
  gap: 15px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  background: #f7faf7;
  color: var(--text);
  font-weight: 800;
}

.switch-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--green);
}

.setting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.setting-actions button {
  min-height: 40px;
}

.receipt-preview {
  display: grid;
  gap: 7px;
  padding: 16px;
  border: 1px dashed #b9c6bb;
  border-radius: 10px;
  background: #fbfcfb;
  font-family: "Consolas", "Courier New", monospace;
}

.receipt-preview strong {
  font-size: 16px;
}

.receipt-preview span {
  color: #3f4b42;
  font-size: 13px;
}

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

.wide-field {
  grid-column: 1 / -1;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
}

.empty.small {
  min-height: 74px;
  box-shadow: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #172018;
  color: #fff;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Category and unit extensions */
.product-form-with-unit {
  grid-template-columns: 1.45fr 0.9fr 0.72fr 0.46fr 0.58fr 0.58fr auto;
}

.category-form {
  display: grid;
  grid-template-columns: 1fr 160px 150px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 16px;
}

.category-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.category-form input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.category-form input:focus {
  border-color: rgba(16, 185, 86, 0.7);
  box-shadow: 0 0 0 3px rgba(16, 185, 86, 0.1);
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  height: 40px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.inline-switch {
  width: 220px;
  margin-left: auto;
}

.category-list {
  display: grid;
  gap: 10px;
}

.category-row {
  display: grid;
  grid-template-columns: 1fr 120px 190px;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}

.category-row.offline {
  opacity: 0.66;
}

.category-row strong,
.category-row span {
  display: block;
}

.category-row strong {
  font-size: 17px;
}

.category-row span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.category-state {
  justify-self: start;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e7f8ee;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
  line-height: 28px;
}

.category-state.off {
  background: #eef2f0;
  color: var(--muted);
}

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

.category-actions button {
  height: 38px;
  padding: 0 13px;
  border-radius: 9px;
  background: #eef4ef;
  color: var(--text);
  font-weight: 700;
}

.meituan-alert-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff7d6, #ffe78f);
  color: #2b2410;
  box-shadow: inset 0 0 0 1px rgba(139, 97, 0, 0.12);
}

.meituan-alert-card strong {
  font-size: 16px;
}

.meituan-alert-card span {
  font-size: 20px;
  font-weight: 900;
}



/* Product form layout override */
.product-form.product-form-with-unit {
  display: grid;
  grid-template-columns: minmax(330px, 0.92fr) minmax(0, 1fr);
  grid-template-rows: auto;
  gap: 18px 20px;
  align-items: stretch;
  margin-bottom: 18px;
  padding: 18px;
  border-radius: 14px;
}

.product-form.product-form-with-unit .image-upload-field {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 14px;
  grid-column: 1;
  grid-row: 1 / span 3;
  align-items: center;
  min-height: 148px;
  padding: 10px;
  border: 1px solid #dce8df;
  border-radius: 13px;
  background: linear-gradient(180deg, #ffffff, #f8fbf8);
  cursor: copy;
}

.product-form.product-form-with-unit > label {
  min-width: 0;
}

.product-form.product-form-with-unit > label:nth-of-type(1) {
  grid-column: 2;
  grid-row: 1;
}

.product-form.product-form-with-unit > label:nth-of-type(2) {
  grid-column: 2;
  grid-row: 2;
}

.product-form.product-form-with-unit > label:nth-of-type(3) {
  grid-column: 2;
  grid-row: 3;
}

.product-form.product-form-with-unit > label:nth-of-type(4) {
  grid-column: 2;
  grid-row: 4;
}

.product-form.product-form-with-unit > label:nth-of-type(5) {
  grid-column: 2;
  grid-row: 5;
}

.product-form.product-form-with-unit .form-actions {
  grid-column: 2;
  grid-row: 6;
  justify-content: flex-end;
  gap: 10px;
}

@media (min-width: 1500px) {
  .product-form.product-form-with-unit {
    grid-template-columns: minmax(460px, 0.62fr) repeat(5, minmax(116px, 1fr));
    grid-template-rows: auto auto;
    align-items: end;
  }

  .product-form.product-form-with-unit .image-upload-field {
    grid-column: 1;
    grid-row: 1 / 3;
  }

  .product-form.product-form-with-unit > label:nth-of-type(1) {
    grid-column: 2 / 4;
    grid-row: 1;
  }

  .product-form.product-form-with-unit > label:nth-of-type(2) {
    grid-column: 4;
    grid-row: 1;
  }

  .product-form.product-form-with-unit > label:nth-of-type(3) {
    grid-column: 5;
    grid-row: 1;
  }

  .product-form.product-form-with-unit > label:nth-of-type(4) {
    grid-column: 2;
    grid-row: 2;
  }

  .product-form.product-form-with-unit > label:nth-of-type(5) {
    grid-column: 3;
    grid-row: 2;
  }

  .product-form.product-form-with-unit .form-actions {
    grid-column: 4 / 7;
    grid-row: 2;
  }
}

@media (min-width: 1280px) and (max-width: 1499px) {
  .product-form.product-form-with-unit {
    grid-template-columns: minmax(330px, 0.75fr) repeat(3, minmax(128px, 1fr));
    grid-template-rows: auto auto auto;
    align-items: end;
  }

  .product-form.product-form-with-unit .image-upload-field {
    grid-column: 1;
    grid-row: 1 / 4;
  }

  .product-form.product-form-with-unit > label:nth-of-type(1) {
    grid-column: 2 / 4;
    grid-row: 1;
  }

  .product-form.product-form-with-unit > label:nth-of-type(2) {
    grid-column: 4;
    grid-row: 1;
  }

  .product-form.product-form-with-unit > label:nth-of-type(3) {
    grid-column: 2;
    grid-row: 2;
  }

  .product-form.product-form-with-unit > label:nth-of-type(4) {
    grid-column: 3;
    grid-row: 2;
  }

  .product-form.product-form-with-unit > label:nth-of-type(5) {
    grid-column: 4;
    grid-row: 2;
  }

  .product-form.product-form-with-unit .form-actions {
    grid-column: 2 / 5;
    grid-row: 3;
  }
}

.product-form.product-form-with-unit .image-picker {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 118px;
  border: 1px dashed #9ab7a4;
  border-radius: 12px;
  background: #f7faf7;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 900;
}

.product-form.product-form-with-unit .image-picker img {
  width: 100%;
  height: 118px;
  object-fit: contain;
  background: #fff;
}

.product-form.product-form-with-unit .image-picker span {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--green-dark);
  font-size: 12px;
  line-height: 26px;
  text-align: center;
  white-space: normal;
}

.product-form.product-form-with-unit .image-upload-meta {
  display: grid;
  align-content: center;
  gap: 7px;
  min-width: 0;
}

.product-form.product-form-with-unit .image-upload-meta strong,
.product-form.product-form-with-unit .image-upload-meta span,
.product-form.product-form-with-unit .image-upload-meta code {
  overflow-wrap: anywhere;
  white-space: normal;
}

.product-form.product-form-with-unit .image-upload-meta strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.product-form.product-form-with-unit .image-upload-meta span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.product-form.product-form-with-unit .image-upload-meta code {
  color: #67726b;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.product-form.product-form-with-unit .image-upload-field.dragging {
  border-color: rgba(16, 185, 86, 0.62);
  background: #f0fbf4;
  box-shadow: 0 0 0 4px rgba(16, 185, 86, 0.1);
}

.product-form.product-form-with-unit .image-upload-field.dragging .image-picker {
  border-color: var(--green);
  background: #eaf8ef;
  box-shadow: inset 0 0 0 2px rgba(16, 185, 86, 0.1);
}

.product-form.product-form-with-unit .image-upload-field.dragging .image-picker span {
  background: var(--green);
  color: #fff;
}

.product-form.product-form-with-unit .image-upload-field.dragging .image-picker span::before {
  content: "\677e\624b\4e0a\4f20 \00b7 ";
}

.product-form.product-form-with-unit .image-upload-field.dragging .image-upload-meta strong::after {
  content: "\ff08\677e\624b\4e0a\4f20\ff09";
  color: var(--green-dark);
  font-weight: 900;
}


/* Product card layout override */
.product-list {
  grid-template-columns: repeat(auto-fit, minmax(430px, 1fr));
  align-items: stretch;
}

.product {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 142px;
  padding: 14px 16px 14px 14px;
}

.product > img {
  width: 108px;
  height: 108px;
  padding: 8px;
  border: 1px solid #edf2ee;
  border-radius: 12px;
  object-fit: contain;
  background: #f8faf5;
  align-self: center;
  justify-self: start;
}

.product > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title actions"
    "price actions"
    "meta actions"
    "tags actions";
  column-gap: 14px;
  align-items: center;
  min-width: 0;
}

.product h3 {
  grid-area: title;
  min-width: 0;
  padding-right: 4px;
}

.product .price {
  grid-area: price;
}

.product .meta {
  grid-area: meta;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-tags {
  grid-area: tags;
  flex-wrap: wrap;
}

.product .actions {
  grid-area: actions;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: center;
  justify-self: end;
  margin-top: 0;
}

.product .actions button {
  min-width: 58px;
  height: 36px;
  padding: 0 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(12, 20, 15, 0.48);
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  width: min(920px, calc(100vw - 56px));
  max-height: calc(100vh - 56px);
  overflow: auto;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.22);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.modal-head h3 {
  font-size: 22px;
}

.modal-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.modal-close {
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  background: #eef5f0;
  color: var(--green-dark);
  font-weight: 800;
}

.form-modal-card {
  width: min(780px, calc(100vw - 56px));
}

.product-modal-card {
  width: min(920px, calc(100vw - 56px));
}

.export-modal-card {
  width: min(720px, calc(100vw - 56px));
}

.small-form-modal {
  width: min(620px, calc(100vw - 56px));
}

.form-modal-card .settings-form,
.form-modal-card .product-form,
.form-modal-card .category-form {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.form-modal-card .settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 22px;
}

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

.export-includes,
.export-note {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbf8;
}

.export-includes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

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

.export-includes strong {
  color: var(--green-dark);
  font-size: 14px;
}

.export-note {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.form-modal-card .product-form.product-form-with-unit {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(0, 1fr);
  gap: 16px 18px;
  align-items: stretch;
  padding: 22px;
}

.form-modal-card .product-form.product-form-with-unit .image-upload-field {
  grid-column: 1;
  grid-row: 1 / span 5;
  min-height: 260px;
  align-content: center;
}

.form-modal-card .product-form.product-form-with-unit > label:nth-of-type(1),
.form-modal-card .product-form.product-form-with-unit > label:nth-of-type(2),
.form-modal-card .product-form.product-form-with-unit > label:nth-of-type(3),
.form-modal-card .product-form.product-form-with-unit > label:nth-of-type(4),
.form-modal-card .product-form.product-form-with-unit > label:nth-of-type(5) {
  grid-column: 2;
  grid-row: auto;
}

.form-modal-card .product-form.product-form-with-unit .form-actions {
  grid-column: 2;
  grid-row: auto;
  justify-content: flex-end;
}

.form-modal-card .category-form {
  grid-template-columns: minmax(0, 1fr) 120px;
  padding: 22px;
}

.form-modal-card .category-form .check-row {
  grid-column: 1 / -1;
}

.form-modal-card .category-form .form-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.order-detail-card {
  padding-bottom: 18px;
}

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

.detail-section {
  margin: 18px 22px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfb;
}

.detail-grid .detail-section {
  margin: 0;
}

.detail-section h4 {
  margin: 0 0 10px;
  font-size: 16px;
}

.detail-section p {
  margin: 6px 0 0;
  color: #4d5a52;
  font-size: 14px;
}

.aftersales-box {
  border-color: #fed7aa;
  background: #fff7ed;
}

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

.detail-product-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
}

.detail-product-row img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: contain;
  background: #f6f8f6;
}

.detail-product-row strong,
.detail-product-row span {
  display: block;
}

.detail-product-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.detail-product-row em {
  color: var(--red);
  font-style: normal;
  font-weight: 900;
}

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

.amount-detail div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #4d5a52;
}

.amount-detail .total {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 18px;
}

.amount-detail .total strong {
  color: var(--red);
  font-size: 22px;
}
