:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f252c;
  --muted: #687483;
  --line: #dce2e8;
  --strong-line: #c6d0da;
  --primary: #15705f;
  --primary-dark: #0e594c;
  --accent: #255f9d;
  --danger: #b13f3f;
  --warning: #996100;
  --success-bg: #e5f5ee;
  --failed-bg: #fff1dc;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  margin: 0;
}

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

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

h1 {
  font-size: 24px;
  font-weight: 780;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  font-weight: 740;
  letter-spacing: 0;
}

h3 {
  font-size: 14px;
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}

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

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 36px rgba(31, 37, 44, 0.08);
  display: grid;
  gap: 14px;
  margin: 0 auto;
  max-width: 380px;
  padding: 24px;
  width: 100%;
}

.password-login {
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

.password-login summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  list-style-position: inside;
  padding: 6px 0;
}

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

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

input,
textarea,
select {
  background: #fff;
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  color: var(--text);
  min-height: 38px;
  outline: none;
  padding: 8px 10px;
}

textarea {
  line-height: 1.5;
  min-height: 132px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 95, 157, 0.12);
}

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 18px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.userbar,
.admin-actions,
.button-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(540px, 1fr) minmax(320px, 400px);
  padding: 16px 24px 28px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 16px;
}

.hall-panel {
  min-height: 640px;
}

.side-stack {
  display: grid;
  gap: 16px;
}

.admin-panel {
  grid-column: 1 / -1;
}

.panel-title {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.stats {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stats span {
  background: #f0f4f7;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 9px;
}

.stats b {
  color: var(--text);
  font-size: 15px;
}

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

.button,
.icon-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 720;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  text-decoration: none;
  white-space: nowrap;
}

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

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

.button.secondary {
  background: #eef3f7;
  border-color: #d4dde6;
  color: #1f354c;
}

.button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--accent);
}

.button.wide {
  width: 100%;
}

.icon-button {
  background: var(--primary);
  color: #fff;
  font-size: 18px;
  min-width: 38px;
  padding: 8px;
}

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

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

.product-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 72px minmax(0, 1fr);
  overflow: hidden;
  padding: 12px;
}

.product-image {
  background: #edf1f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 72px;
  overflow: hidden;
  width: 72px;
}

.product-image img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.image-fallback {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-weight: 800;
  height: 100%;
  justify-content: center;
}

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

.product-head {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-width: 0;
}

.product-head > div {
  min-width: 0;
}

.product-head strong,
.product-head p {
  overflow-wrap: anywhere;
}

.product-head p,
.product-meta {
  color: var(--muted);
  font-size: 13px;
}

.progress-line {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) max-content;
  min-width: 0;
}

.progress-bar {
  background: #edf1f4;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar span {
  background: var(--primary);
  display: block;
  height: 100%;
}

.product-meta,
.operator-list {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-select {
  min-height: 30px;
  padding: 4px 8px;
}

.operator-list span {
  background: #f0f4f7;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 7px;
}

.increment-form {
  display: grid;
  gap: 8px;
  grid-column: 2;
  grid-template-columns: 1fr 38px;
  justify-self: end;
  max-width: 220px;
  min-width: 0;
  width: 100%;
}

.increment-form input {
  min-width: 0;
  width: 100%;
}

.tag {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  padding: 6px 8px;
}

.tag.success {
  background: var(--success-bg);
  color: var(--primary-dark);
}

.tag.failed {
  background: var(--failed-bg);
  color: var(--warning);
}

.records {
  display: grid;
  gap: 10px;
}

.record,
.admin-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.record-head {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.record-title {
  font-weight: 760;
}

.record-meta {
  color: var(--muted);
  font-size: 12px;
}

.order-edit,
.user-edit,
.field-row {
  display: grid;
  gap: 8px;
}

.order-edit {
  grid-template-columns: minmax(80px, 1fr) 66px 44px;
}

.user-edit {
  grid-template-columns: minmax(110px, 1fr) 96px minmax(110px, 1fr) 66px;
}

.field-row {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.admin-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.admin-grid.lower {
  margin-top: 12px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 420px;
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 100%;
  table-layout: fixed;
}

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

th {
  background: #f9fafb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  position: sticky;
  top: 0;
}

.num {
  text-align: right;
}

.mini-list {
  color: var(--muted);
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.mini-list li {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  list-style: none;
}

.link-button {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  font-weight: 720;
  padding: 0;
}

.notice {
  background: #fff8e8;
  border: 1px solid #efd39e;
  border-radius: 8px;
  color: #835400;
  margin-top: 12px;
  padding: 10px 12px;
}

.modal {
  background: transparent;
  border: 0;
  max-width: min(760px, calc(100vw - 24px));
  padding: 0;
  width: 100%;
}

.modal::backdrop {
  background: rgba(31, 37, 44, 0.42);
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(31, 37, 44, 0.22);
  margin: 0;
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 18px;
}

.modal-head,
.modal-actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.modal-head p {
  margin-top: 4px;
}

.modal-actions {
  justify-content: flex-end;
}

.sku-column {
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding: 10px 12px;
}

.preview-card {
  max-width: 760px;
}

.preview-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  max-height: 440px;
  overflow: auto;
}

.preview-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: 58px minmax(0, 1fr) max-content;
  padding: 10px;
}

.preview-row:last-child {
  border-bottom: 0;
}

.preview-row .product-image {
  height: 58px;
  width: 58px;
}

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

.preview-main p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.preview-quantity {
  color: var(--primary-dark);
  font-size: 18px;
  font-weight: 800;
  min-width: 52px;
  text-align: right;
}

.switch {
  align-items: center;
  display: flex;
  gap: 6px;
}

.switch input {
  min-height: auto;
}

.toast {
  background: #1f252c;
  border-radius: 8px;
  bottom: 20px;
  color: #fff;
  left: 50%;
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 8px);
  transition: opacity 150ms ease, transform 150ms ease;
  z-index: 20;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

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

@media (max-width: 720px) {
  .topbar,
  .userbar,
  .panel-title,
  .admin-actions,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .layout {
    padding: 12px;
  }

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

  .product-image {
    height: 64px;
    width: 64px;
  }

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

  .field-row,
  .user-edit,
  .order-edit {
    grid-template-columns: 1fr;
  }

  .button,
  .icon-button {
    width: 100%;
  }

  .modal-head,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .preview-row .product-image {
    height: 52px;
    width: 52px;
  }

  .preview-quantity {
    grid-column: 2;
    text-align: left;
  }
}
