:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-muted: #edf1f7;
  --ink: #172033;
  --ink-soft: #33405a;
  --muted: #6a7487;
  --line: #dce3ed;
  --strong-line: #b9c5d6;
  --accent: #315d9f;
  --accent-dark: #243f73;
  --accent-soft: #e8eef8;
  --amber: #9a6412;
  --red: #b3261e;
  --blue: #315d9f;
  --green: #28706f;
  --soft-amber: #fff5dc;
  --soft-red: #fff0ee;
  --soft-blue: #edf5ff;
  --soft-green: #e6f2f2;
  --radius: 8px;
  --shadow: 0 14px 30px rgba(23, 32, 51, 0.07);
  --shadow-soft: 0 6px 18px rgba(23, 32, 51, 0.045);
}

* {
  box-sizing: border-box;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html {
  min-height: 100%;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 16% 0%, rgba(49, 93, 159, 0.1), transparent 30%),
    linear-gradient(180deg, #f9fbfe 0, var(--bg) 360px);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

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

.app-shell {
  width: min(1520px, calc(100% - 48px));
  margin: 0 auto;
  padding: 14px 0 34px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 66px;
  padding: 8px 0 10px;
  border-bottom: 1px solid rgba(220, 227, 237, 0.9);
  background: rgba(249, 251, 254, 0.94);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

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

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 7px;
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.35;
}

.workspace {
  min-width: 0;
  padding-top: 14px;
  animation: surfaceIn 180ms ease-out;
}

@keyframes surfaceIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.top-actions,
.button-row,
.inline-actions,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.top-actions {
  justify-content: flex-end;
  flex: 0 0 auto;
  min-width: 260px;
  max-width: 520px;
  min-height: 40px;
}

.session-user {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 280px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-soft);
  padding: 4px 5px 4px 11px;
  font-size: 12px;
  font-weight: 800;
}

.session-name {
  min-width: 0;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-role {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 3px 8px;
  white-space: nowrap;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.small-button,
.nav-button,
.link-button {
  min-height: 36px;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 11px;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.small-button:hover,
.nav-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

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

.secondary-button {
  border-color: rgba(49, 93, 159, 0.45);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
}

.danger-button {
  border-color: #efb8b1;
  background: var(--soft-red);
  color: var(--red);
  font-weight: 800;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
}

.small-button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 12px;
}

.small-button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 900;
}

.link-button {
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent-dark);
  padding: 0;
  font-weight: 900;
  text-align: left;
}

.danger-text {
  color: var(--red);
}

.full-width {
  width: 100%;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 20px;
  align-items: stretch;
  min-height: 520px;
}

.login-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-soft);
  padding: 30px;
}

.login-copy h2 {
  margin-bottom: 14px;
  font-size: 38px;
  line-height: 1.08;
}

.login-accounts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 22px;
}

.login-accounts span {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-form {
  align-self: center;
  display: grid;
  gap: 13px;
}

.buyer-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: end;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(232, 238, 248, 0.72));
  box-shadow: var(--shadow-soft);
  padding: 20px;
  margin-bottom: 14px;
}

.buyer-hero h2 {
  max-width: 760px;
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.16;
}

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

.buyer-stats div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  padding: 10px;
}

.buyer-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.buyer-stats b {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.1;
}

.buyer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 18px;
  align-items: start;
}

.buyer-products {
  min-width: 0;
}

.buyer-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.buyer-section-head h2 {
  margin-bottom: 3px;
}

.buyer-shop-filters {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  padding: 10px;
}

.buyer-search {
  min-width: 0;
}

.buyer-filter-tabs {
  min-width: 0;
  margin: 0;
  justify-content: flex-start;
}

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

.buyer-product-card {
  min-height: 318px;
  border-color: rgba(185, 197, 214, 0.72);
}

.buyer-product-card .product-image,
.buyer-product-card .product-art {
  height: auto;
  aspect-ratio: 1 / 1;
}

.buyer-product-title {
  display: grid;
  gap: 6px;
  min-height: 42px;
}

.buyer-product-title h3 {
  line-height: 1.35;
}

.buyer-product-foot {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.buyer-product-foot .price {
  margin: 0;
}

.buyer-side {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 12px;
}

.buyer-card,
.buyer-orders-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
  padding: 14px;
}

.buyer-card-head,
.buyer-order-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.cart-card .line-item {
  background: var(--surface-soft);
}

.checkout-empty {
  background: linear-gradient(180deg, #fff, var(--surface-soft));
}

.buyer-payment-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}

.buyer-payment-form .field.wide {
  grid-column: span 1;
}

.buyer-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin: 10px 0 12px;
}

.buyer-flow span {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 5px 7px;
  font-size: 11.5px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.buyer-flow span.is-active {
  border-color: rgba(49, 93, 159, 0.35);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.buyer-orders-panel {
  margin-top: 18px;
}

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

.buyer-order-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}

.buyer-order-summary {
  display: grid;
  grid-template-columns: minmax(130px, 0.35fr) minmax(0, 1fr);
  gap: 8px;
}

.buyer-order-summary div {
  min-width: 0;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 8px 10px;
}

.buyer-order-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.buyer-order-summary b {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.85fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(290px, 0.72fr) minmax(0, 1.28fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.ops-shell {
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.ops-nav {
  position: sticky;
  top: 82px;
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-soft);
  padding: 7px;
}

.ops-nav .danger-button {
  margin-top: 4px;
  justify-content: flex-start;
  width: 100%;
  min-height: 34px;
  text-align: left;
}

.nav-button {
  justify-content: flex-start;
  width: 100%;
  min-width: 0;
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  font-weight: 800;
  min-height: 34px;
}

.nav-button:hover {
  border-color: var(--line);
  background: var(--surface-soft);
}

.nav-button.is-active {
  border-color: rgba(49, 93, 159, 0.35);
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: none;
}

.ops-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(340px, 0.56fr);
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.report-workspace {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.report-grid.single {
  grid-template-columns: 1fr;
}

.report-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

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

.report-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.report-tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink-soft);
  padding: 7px 14px;
  font-weight: 900;
}

.report-tab:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.report-tab.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(49, 93, 159, 0.08);
}

.page-heading-panel {
  border-left: 4px solid var(--accent);
}

.notification-workspace,
.maintenance-workspace {
  min-width: 0;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
  padding: 13px;
}

.panel + .panel {
  margin-top: 12px;
}

.plain-section {
  padding: 4px 0 14px;
}

.plain-section h2 {
  margin-bottom: 6px;
}

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

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

.summary-row.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  min-height: 64px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff, var(--surface-soft));
  padding: 9px 10px;
}

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

.metric b {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.15;
  word-break: break-word;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 12px;
}

.product {
  display: grid;
  grid-template-rows: 142px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.product:hover {
  border-color: rgba(49, 93, 159, 0.35);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.product-art {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--art-bg, #dfe7f4);
}

.product-image {
  display: block;
  width: 100%;
  height: 142px;
  background: #fff;
  object-fit: cover;
}

.product-thumb {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  object-fit: cover;
}

.product-create-panel {
  border-left: 4px solid var(--accent);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin-bottom: 3px;
}

.count-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink-soft);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 900;
}

.product-create-form {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.product-create-form .field.wide {
  grid-column: span 1;
}

.product-admin-panel {
  overflow: hidden;
}

.product-admin-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.product-admin-head {
  display: grid;
  grid-template-columns: 96px minmax(220px, 1.25fr) minmax(150px, 0.7fr) minmax(150px, 0.72fr) minmax(220px, 1fr) minmax(132px, auto);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.product-admin-row {
  display: grid;
  grid-template-columns: 96px minmax(220px, 1.25fr) minmax(150px, 0.7fr) minmax(150px, 0.72fr) minmax(220px, 1fr) minmax(132px, auto);
  gap: 12px;
  align-items: end;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.product-admin-row:last-child,
.product-admin-head:last-child {
  border-bottom: 0;
}

.product-admin-row:hover {
  background: #fbfcff;
}

.product-admin-preview {
  align-self: stretch;
  display: grid;
  gap: 7px;
  justify-items: center;
  align-content: start;
  padding-right: 2px;
}

.product-admin-preview .badge {
  max-width: 86px;
  justify-content: center;
  white-space: nowrap;
}

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

.product-admin-main {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.72fr) minmax(0, 1fr);
}

.product-admin-numbers,
.product-admin-state {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.product-admin-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-self: end;
}

.product-admin-actions button {
  width: 100%;
  justify-content: center;
}

.product-image-picker {
  min-width: 0;
  min-height: 68px;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px dashed var(--strong-line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink-soft);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.product-image-picker:hover,
.product-image-picker:focus-within {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(49, 93, 159, 0.1);
}

.product-image-picker span {
  font-size: 13px;
  font-weight: 900;
}

.product-image-picker small {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.product-image-picker input[type="file"] {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  color: transparent;
  font-size: 12px;
}

.product-image-picker input[type="file"]::file-selector-button {
  min-height: 30px;
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 5px 9px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.product-image-picker input[type="file"]:hover::file-selector-button {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.product-card-panel {
  border-left: 4px solid var(--accent);
}

.product-card-workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

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

.card-product-button {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  text-align: left;
}

.card-product-button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.card-product-button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

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

.card-import-form {
  grid-template-columns: minmax(160px, 0.6fr) minmax(260px, 1fr) auto;
}

.card-status-tabs {
  margin: 0;
}

.product-card-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.product-card-head,
.product-card-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) 92px minmax(180px, 0.9fr) 96px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.product-card-head {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

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

.product-card-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.admin-create-panel,
.group-create-panel {
  border-left: 4px solid var(--accent);
}

.admin-create-form {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(140px, 0.8fr) minmax(160px, 1fr) auto;
}

.group-create-form {
  grid-template-columns: minmax(120px, 0.55fr) minmax(180px, 1fr) minmax(180px, 1fr) minmax(130px, 0.65fr) auto;
}

.admin-list-panel,
.group-list-panel {
  overflow: hidden;
}

.admin-table-list,
.group-table-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.admin-table-head,
.admin-table-row,
.group-table-head,
.group-table-row {
  display: grid;
  gap: 12px;
  align-items: center;
}

.admin-table-head,
.group-table-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.admin-table-row,
.group-table-row {
  min-width: 0;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.admin-table-row:last-child,
.group-table-row:last-child {
  border-bottom: 0;
}

.admin-table-row:hover,
.group-table-row:hover {
  background: #fbfcff;
}

.admin-table-head,
.admin-table-row {
  grid-template-columns: minmax(170px, 0.9fr) minmax(160px, 0.72fr) minmax(320px, 1.35fr) minmax(220px, 0.9fr);
}

.group-table-head,
.group-table-row {
  grid-template-columns: minmax(160px, 0.75fr) minmax(170px, 0.75fr) minmax(150px, 0.65fr) minmax(330px, 1.35fr) minmax(200px, 0.85fr);
}

.admin-identity,
.group-identity,
.admin-table-row > div,
.group-table-row > div {
  min-width: 0;
}

.admin-identity strong,
.group-identity strong,
.admin-table-row strong,
.group-table-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 118px;
  gap: 8px;
  min-width: 0;
}

.group-row-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 1fr) 118px;
  gap: 8px;
  min-width: 0;
}

.admin-row-actions,
.group-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}

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

.admin-context {
  margin-top: 8px;
}

.product-art::before {
  content: "";
  width: 70px;
  height: 70px;
  border: 12px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  transform: rotate(18deg);
}

.product-art::after {
  content: attr(data-label);
  position: absolute;
  left: 12px;
  bottom: 10px;
  color: rgba(23, 33, 29, 0.7);
  font-size: 12px;
  font-weight: 800;
}

.product-body {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.product-body h3 {
  margin: 0;
}

.price {
  color: var(--accent-dark);
  font-size: 19px;
  font-weight: 900;
}

.cart-list,
.order-list,
.code-list,
.audit-list,
.notification-list,
.compact-list,
.code-admin-list,
.detail-stack,
.stack {
  display: grid;
  gap: 8px;
}

.line-item,
.order-item,
.code-item,
.audit-item,
.notification-item,
.code-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
}

.line-item,
.code-item,
.notification-item,
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.code-dashboard-panel {
  border-left: 4px solid var(--accent);
}

.code-dashboard-panel .segmented {
  margin: 0;
  justify-content: flex-end;
}

.code-tools-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.72fr);
  gap: 12px;
  align-items: stretch;
}

.code-tools-grid.single {
  grid-template-columns: 1fr;
}

.code-tool-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.tool-card-heading h3 {
  margin: 0 0 3px;
  font-size: 16px;
}

.code-tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.code-tool-grid.import {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.code-tool-card .field.wide {
  grid-column: span 2;
}

.code-tool-card button {
  align-self: end;
}

.code-admin-panel {
  overflow: hidden;
}

.code-table-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.code-table-head,
.code-table-row {
  display: grid;
  grid-template-columns: 170px 160px minmax(190px, 1fr) minmax(240px, 1.15fr) 130px minmax(180px, 0.86fr) minmax(170px, 0.8fr) 118px;
  gap: 10px;
  align-items: center;
}

.code-table-row.is-admin,
.code-table-head:has(+ .code-table-row.is-admin) {
  grid-template-columns: 170px minmax(220px, 1fr) minmax(260px, 1.15fr) 130px minmax(180px, 0.86fr) minmax(170px, 0.8fr) 118px;
}

.code-table-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.code-table-row {
  min-width: 0;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

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

.code-table-row:hover {
  background: #fbfcff;
}

.code-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.code-identity strong,
.code-identity .mini-copy {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-table-notes {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.code-state-cell {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.code-state-cell .badge {
  width: fit-content;
}

.code-state-cell select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
}

.upload-picker {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 5px;
  border: 1px dashed var(--strong-line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink-soft);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.upload-picker:hover,
.upload-picker:focus-within {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(49, 93, 159, 0.1);
}

.upload-picker span {
  font-size: 13px;
  font-weight: 900;
}

.upload-picker small {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.upload-picker input[type="file"] {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  color: transparent;
  font-size: 12px;
}

.upload-picker input[type="file"]::file-selector-button {
  min-height: 30px;
  border: 1px solid var(--strong-line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 5px 9px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.upload-picker input[type="file"]:hover::file-selector-button {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.code-history {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.code-history span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-row-actions {
  display: grid;
  gap: 7px;
}

.code-row-actions button {
  width: 100%;
}

.order-item {
  display: grid;
  gap: 11px;
}

.order-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.green {
  border-color: rgba(24, 132, 92, 0.18);
  background: var(--soft-green);
  color: var(--green);
}

.badge.amber {
  border-color: rgba(154, 100, 18, 0.18);
  background: var(--soft-amber);
  color: var(--amber);
}

.badge.red {
  border-color: rgba(179, 38, 30, 0.18);
  background: var(--soft-red);
  color: var(--red);
}

.badge.blue {
  border-color: rgba(45, 102, 179, 0.18);
  background: var(--soft-blue);
  color: var(--blue);
}

.divider {
  height: 1px;
  margin: 12px 0;
  background: var(--line);
}

.checkout-box {
  display: grid;
  gap: 12px;
  border-color: rgba(49, 93, 159, 0.28);
  background: linear-gradient(180deg, #fff, var(--accent-soft));
}

.qr-box {
  display: grid;
  min-height: 170px;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.qr-art {
  width: 170px;
  height: 170px;
  border: 10px solid #fff;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, #10231c 12px, transparent 12px) 0 0 / 34px 34px,
    linear-gradient(#10231c 12px, transparent 12px) 0 0 / 34px 34px,
    #edf3fb;
}

.qr-image,
.qr-missing {
  width: 170px;
  height: 170px;
  border: 10px solid #fff;
  border-radius: var(--radius);
  background: #fff;
}

.qr-image {
  object-fit: contain;
}

.qr-missing {
  display: grid;
  place-items: center;
  border-style: dashed;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.code-thumb {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  object-fit: contain;
}

.proof-preview {
  width: min(100%, 320px);
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  object-fit: contain;
}

.field {
  display: grid;
  gap: 4px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field textarea,
.field input,
.field select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--strong-line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field textarea:focus,
.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(49, 93, 159, 0.14);
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.form-grid,
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  align-items: end;
}

.filter-grid {
  margin: 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 9px;
  grid-template-columns: repeat(5, minmax(118px, 1fr)) auto auto;
}

.code-form {
  margin-top: 9px;
  grid-template-columns: repeat(5, minmax(112px, 1fr)) auto;
}

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

.template-form {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  grid-template-columns: minmax(130px, 0.7fr) minmax(180px, 1fr) auto;
}

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

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

.maintenance-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.maintenance-card button {
  flex: 0 0 auto;
}

.delivery-panel {
  display: grid;
  gap: 9px;
}

.delivery-list {
  display: grid;
  gap: 9px;
}

.delivery-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.delivery-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}

.delivery-form {
  margin-top: 9px;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
}

.segmented {
  margin: 9px 0 12px;
}

.field.wide {
  grid-column: span 2;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.compact-table {
  min-width: 620px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: middle;
}

.table td:nth-child(4),
.table th:nth-child(4) {
  text-align: right;
}

.table td:last-child,
.table th:last-child {
  text-align: right;
}

.table td:last-child .inline-actions {
  justify-content: flex-end;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 900;
}

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

.table tbody tr {
  transition: background 120ms ease;
}

.table tbody tr:hover td {
  background: #fbfdfc;
}

.table tr.is-selected td {
  background: var(--accent-soft);
}

.edit-row td {
  background: var(--surface-soft);
}

.detail-panel {
  position: sticky;
  top: 82px;
  max-height: calc(100vh - 98px);
  overflow: auto;
  scrollbar-width: thin;
}

.detail-list {
  display: grid;
  gap: 7px;
  margin: 0;
}

.detail-list div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 7px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-list dd {
  margin: 0;
  word-break: break-word;
}

.empty-state {
  border: 1px dashed var(--strong-line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.54);
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.status-note {
  border: 1px solid rgba(45, 102, 179, 0.18);
  border-radius: var(--radius);
  background: var(--soft-blue);
  color: var(--blue);
  padding: 9px 11px;
}

.status-note.warn {
  border-color: rgba(154, 100, 18, 0.18);
  background: var(--soft-amber);
  color: var(--amber);
}

.status-note.danger {
  border-color: rgba(179, 38, 30, 0.18);
  background: var(--soft-red);
  color: var(--red);
}

.mini-copy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.trend-list {
  display: grid;
  gap: 7px;
}

.trend-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 92px 52px;
  gap: 9px;
  align-items: center;
  font-size: 13px;
}

.trend-row span {
  color: var(--muted);
  font-weight: 800;
}

.trend-row strong,
.trend-row em {
  text-align: right;
}

.trend-row em {
  color: var(--muted);
  font-style: normal;
}

.trend-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-muted);
}

.trend-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #6a86bd);
}

.report-list {
  margin-top: 10px;
}

.error-box,
.success-box {
  margin-bottom: 10px;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-weight: 700;
}

.error-box {
  border: 1px solid #efb8b1;
  background: var(--soft-red);
  color: var(--red);
}

.success-box {
  border: 1px solid #9dd6bd;
  background: var(--soft-green);
  color: #275f5e;
}

@media (max-width: 1180px) {
  .workspace-grid,
  .section-grid,
  .admin-grid,
  .buyer-hero,
  .buyer-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel,
  .ops-nav,
  .buyer-side {
    position: static;
    max-height: none;
  }

  .report-toolbar {
    flex-direction: column;
  }

  .report-actions {
    justify-content: flex-start;
  }

  .filter-grid,
  .form-grid,
  .code-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-create-form,
  .admin-create-form,
  .group-create-form,
  .product-admin-head,
  .product-admin-row,
  .admin-table-head,
  .admin-table-row,
  .group-table-head,
  .group-table-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .code-tools-grid,
  .product-card-workspace,
  .code-tool-grid,
  .code-tool-grid.import {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .code-table-row {
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr);
  }

  .code-table-row.is-super,
  .code-table-row.is-admin {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .code-table-head,
  .product-admin-head,
  .admin-table-head,
  .group-table-head {
    display: none;
  }

  .code-identity {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
  }

  .code-row-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .product-admin-preview {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-bottom: 1px solid var(--line);
    padding: 0 0 10px;
  }

  .product-image-picker,
  .product-admin-actions {
    grid-column: span 1;
  }

  .buyer-shop-filters,
  .maintenance-grid {
    grid-template-columns: 1fr;
  }

  .admin-row-fields,
  .group-row-fields,
  .card-import-form,
  .product-card-head,
  .product-card-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    width: min(calc(100% - 18px), 1520px);
    padding-top: 8px;
  }

  .topbar,
  .order-topline,
  .line-item,
  .code-item,
  .notification-item,
  .code-head,
  .maintenance-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  h1 {
    font-size: 26px;
  }

  .login-copy h2 {
    font-size: 30px;
  }

  .login-layout,
  .ops-shell,
  .buyer-stats,
  .summary-row,
  .summary-row.compact,
  .report-summary,
    .report-grid,
    .qr-box,
    .code-tools-grid,
    .product-card-workspace,
    .code-tool-grid,
    .code-tool-grid.import,
  .code-table-row,
  .code-table-row.is-super,
  .code-table-row.is-admin,
  .code-table-notes,
  .code-row-actions,
  .filter-grid,
  .form-grid,
  .code-form,
  .product-create-form,
  .admin-create-form,
  .group-create-form,
  .product-admin-head,
  .product-admin-row,
  .admin-table-head,
    .admin-table-row,
    .group-table-head,
    .group-table-row,
    .admin-row-fields,
    .group-row-fields,
    .card-import-form,
    .product-card-head,
    .product-card-row,
    .product-admin-main,
  .product-admin-numbers,
  .product-admin-state {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .buyer-card-head,
  .buyer-order-head,
  .code-dashboard-panel .segmented,
  .product-admin-preview {
    align-items: flex-start;
    flex-direction: column;
  }

  .buyer-hero {
    padding: 16px;
  }

  .buyer-hero h2 {
    font-size: 24px;
  }

  .buyer-product-grid,
  .buyer-order-summary {
    grid-template-columns: 1fr;
  }

  .top-actions {
    width: 100%;
    min-width: 0;
    max-width: none;
    justify-content: space-between;
  }

  .session-user {
    max-width: min(100%, 260px);
  }

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

  .admin-row-actions,
  .group-row-actions {
    justify-content: flex-start;
  }

  .maintenance-card button {
    width: 100%;
  }

  .code-tool-card .field.wide {
    grid-column: span 1;
  }

  .code-identity {
    grid-column: span 1;
  }

  .product-image-picker,
  .product-admin-actions {
    grid-column: span 1;
  }

  .ops-nav {
    display: flex;
    overflow-x: auto;
    padding: 8px;
  }

  .report-mode-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .report-tab {
    flex: 0 0 auto;
  }

  .ops-nav .nav-button,
  .ops-nav .danger-button {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }

  .ops-nav,
  .ops-main,
  .workspace-grid,
  .report-workspace {
    width: 100%;
    min-width: 0;
  }

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

  .qr-image,
  .qr-missing,
  .qr-art {
    width: 148px;
    height: 148px;
  }
}
