:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #eef2f6;
  --text: #19212a;
  --muted: #64717f;
  --line: #d9e0e7;
  --accent: #0f8f7a;
  --accent-strong: #087262;
  --danger: #b42318;
  --warning: #a16207;
  --ok: #137333;
  --shadow: 0 18px 48px rgba(25, 33, 42, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  align-items: center;
  min-height: 68px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #fff;
  background: #19212a;
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.topnav,
.session-box,
.segmented,
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav {
  justify-content: center;
}

.nav-tab,
.segmented button,
.ghost-button,
.refresh-button,
.text-button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 12px;
  color: var(--text);
  background: transparent;
}

.nav-tab.is-active,
.segmented button.is-active {
  background: #19212a;
  color: #fff;
}

.ghost-button,
.refresh-button {
  border-color: var(--line);
  background: var(--panel);
}

.text-button {
  color: var(--accent-strong);
  padding-inline: 0;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 220px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--panel-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

.left-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.notice,
.login-panel,
.account-panel,
.editor,
.settings-form,
.product-card,
.order-card,
.admin-item,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.notice {
  padding: 14px;
  color: var(--muted);
}

.login-panel,
.account-panel,
.editor,
.settings-form {
  padding: 16px;
}

.login-panel.attention {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 143, 122, .16), var(--shadow);
}

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

h1 {
  margin-bottom: 4px;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 14px;
  font-size: 17px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

label span {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 38px;
  border: 0;
  border-radius: 7px;
  padding: 8px 13px;
  color: #fff;
  background: var(--accent);
  font-weight: 700;
}

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

.secondary-button {
  background: #314150;
}

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

.compact-button {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 13px;
}

.order-actions {
  margin-top: 12px;
}

.form-hint,
.inline-status,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.secondary-link {
  display: block;
  margin-top: 10px;
  color: var(--accent-strong);
  text-decoration: none;
}

.account-panel dl {
  display: grid;
  gap: 9px;
  margin: 0;
}

.account-panel div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.account-panel dt,
.account-panel dd {
  margin: 0;
}

.account-panel dt {
  color: var(--muted);
}

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

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.product-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.product-card h3 {
  margin: 0;
  font-size: 17px;
}

.product-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.card-meta,
.order-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}

.badge.ok {
  color: var(--ok);
  background: #e8f3ea;
}

.badge.warn {
  color: var(--warning);
  background: #fff4d6;
}

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

.price {
  font-size: 22px;
  font-weight: 800;
}

.editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 14px;
  margin-bottom: 22px;
}

.editor label:nth-child(5),
.editor label:nth-child(6),
.editor label:nth-child(8),
.editor label:nth-child(9),
.editor label:nth-child(10),
.editor .check-row,
.editor .form-actions {
  grid-column: 1 / -1;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin: 2px 0 12px;
}

.check-row label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--muted);
}

.check-row input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.subhead {
  margin: 18px 0 10px;
  font-size: 17px;
}

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

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

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

th {
  color: var(--muted);
  font-weight: 700;
  background: #f9fafb;
}

.order-list,
.admin-list {
  display: grid;
  gap: 12px;
}

.order-card,
.admin-item {
  padding: 16px;
}

.order-card h3,
.admin-item h3 {
  margin: 0 0 8px;
}

.delivery-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  white-space: pre-wrap;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  padding: 14px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #19212a;
  box-shadow: var(--shadow);
}

.empty {
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    padding: 12px 16px;
  }

  .topnav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 18px 16px 36px;
  }

  .editor,
  .admin-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
  }
}
