:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #18202b;
  --muted: #657184;
  --line: #dfe6ef;
  --brand: #1267d8;
  --brand-dark: #0e4fa6;
  --green: #16845b;
  --red: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

a {
  color: var(--brand);
  text-decoration: none;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

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

.admin-content {
  min-width: 0;
  padding: 28px 28px 48px;
}

.left-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 22px 16px;
}

.nav-brand {
  display: grid;
  gap: 4px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--line);
}

.nav-brand strong {
  font-size: 20px;
}

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

.left-nav nav {
  display: grid;
  align-content: start;
  gap: 6px;
}

.left-nav a {
  display: block;
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  padding: 11px 12px;
}

.left-nav a:hover,
.left-nav a.active {
  background: #e8f1ff;
  color: var(--brand);
}

.nav-link {
  border: 1px solid var(--line);
  text-align: center;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

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

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

p {
  color: var(--muted);
  margin-top: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(18, 32, 51, 0.06);
}

.grid {
  display: grid;
  gap: 22px;
}

.two {
  grid-template-columns: minmax(300px, 420px) 1fr;
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

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

button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  padding: 11px 14px;
}

button:hover {
  background: var(--brand-dark);
}

button:disabled {
  background: #c7d1df;
  cursor: not-allowed;
}

button.danger {
  background: var(--red);
}

button.danger:hover {
  background: #8f1d14;
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button.secondary:hover {
  background: #eef4fb;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 28px;
  box-shadow: 0 16px 40px rgba(24, 32, 43, 0.10);
}

.login-panel h1 {
  margin-bottom: 22px;
  font-size: 24px;
}

pre {
  min-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1720;
  color: #d8e7ff;
  line-height: 1.5;
}

.compact-pre {
  min-height: 160px;
  max-height: 300px;
  font-size: 13px;
}

.checkout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.checkout .panel {
  width: min(560px, 100%);
}

.cashier-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #eef7f1;
}

.cashier-card {
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
  border: 1px solid #cfe2d5;
  border-radius: 8px;
  background: #fff;
  padding: 20px;
}

.cashier-head {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cashier-head span,
.cashier-info span,
.cashier-status span,
.cashier-tips span {
  color: #1e3f32;
  font-size: 13px;
  font-weight: 700;
}

.cashier-head h1 {
  margin-top: 4px;
  color: #031915;
  font-size: 26px;
}

.cashier-shield {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e3f1e9;
  color: #1d7d58;
  font-size: 18px;
}

.cashier-info,
.cashier-status,
.cashier-tips {
  border: 1px solid #cfe2d5;
  border-radius: 8px;
  padding: 18px 16px;
  background: #fff;
}

.cashier-info,
.cashier-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.cashier-info strong,
.cashier-status strong {
  display: block;
  margin-top: 8px;
  color: #071f18;
  font-size: 16px;
}

.cashier-amount {
  color: #16845b !important;
  font-size: 24px !important;
}

.cashier-countdown,
#payStatus.is-invalid {
  color: #9f1620 !important;
  font-size: 24px !important;
}

.cashier-alert {
  border: 1px solid #ffb5bc;
  border-radius: 8px;
  background: #fff1f3;
  color: #b42318;
  padding: 14px 16px;
  font-weight: 700;
}

.cashier-tips ul {
  margin: 12px 0 0;
  padding-left: 18px;
  color: #233b31;
  line-height: 1.8;
}

.cashier-actions {
  display: grid;
  gap: 10px;
}

.cashier-actions button {
  min-height: 48px;
  font-size: 18px;
}

.summary {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.summary div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

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

.pay-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metrics {
  margin-bottom: 16px;
}

.metrics > div {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.admin-page {
  display: none;
}

.admin-page.is-active {
  display: grid;
}

.metrics.admin-page.is-active {
  display: block;
}

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

.section-head p {
  font-size: 14px;
}

.query-line {
  display: grid;
  grid-template-columns: minmax(240px, 340px) auto;
  gap: 10px;
}

.protocol-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 32, 0.42);
  padding: 24px;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-panel {
  width: min(980px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

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

.button-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.local-order-head {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.product-grid,
.pool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.product-grid article,
.pool-grid article {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 14px;
}

.product-grid strong,
.product-grid span,
.product-grid small,
.pool-grid span,
.pool-grid strong,
.pool-grid small {
  display: block;
}

.product-grid span,
.product-grid small,
.pool-grid span,
.pool-grid small {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.pool-grid strong {
  font-size: 24px;
  margin-top: 8px;
}

.manager-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.manage-result {
  display: grid;
  gap: 10px;
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 14px;
  word-break: break-all;
}

.payment-summary {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 14px;
  word-break: break-all;
}

.payment-summary.empty {
  color: var(--muted);
}

.payment-summary div {
  display: grid;
  gap: 4px;
}

.payment-summary span {
  color: var(--muted);
  font-size: 12px;
}

.payment-summary strong {
  font-size: 14px;
  line-height: 1.45;
}

.manage-result.empty {
  align-content: center;
  color: var(--muted);
}

.manage-result div {
  display: grid;
  gap: 3px;
}

.manage-result span {
  color: var(--muted);
  font-size: 12px;
}

.manage-result strong {
  font-size: 14px;
}

.message {
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric span, .metric small {
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: 28px;
  margin: 8px 0 2px;
}

.table-wrap {
  overflow-x: auto;
}

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

.table-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.table-toolbar select {
  width: auto;
  min-width: 86px;
  padding: 8px 10px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.pager button {
  padding: 8px 12px;
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
}

.scroll-cell {
  max-width: 180px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding-bottom: 2px;
}

.product-scroll-cell {
  max-width: 220px;
}

.mono-cell {
  max-width: 260px;
  white-space: normal;
  word-break: break-all;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.45;
}

td button {
  padding: 7px 10px;
  font-size: 13px;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status.paid {
  background: #e8f6ef;
  color: var(--green);
}

.status.refunded, .status.closed {
  background: #fdecec;
  color: var(--red);
}

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

  .admin-content {
    padding: 18px 16px 36px;
  }

  .left-nav {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .two, .metrics > div, .pay-grid, .product-grid, .pool-grid, .form-grid {
    grid-template-columns: 1fr;
  }

  .cashier-info,
  .cashier-status {
    grid-template-columns: 1fr;
  }

  .cashier-head h1 {
    font-size: 22px;
  }

  .section-head,
  .query-line,
  .table-toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .pager {
    justify-content: start;
  }

  h1 {
    font-size: 24px;
  }
}
