:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-strong: #eef4ff;
  --ink: #152033;
  --muted: #68758b;
  --line: #dfe6f2;
  --brand: #1d6fd8;
  --brand-strong: #0d4ea6;
  --mint: #20a886;
  --amber: #f59d22;
  --rose: #e4576a;
  --slate: #253348;
  --shadow: 0 18px 45px rgba(26, 44, 72, 0.12);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  min-height: 72px;
  padding: 0 clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(223, 230, 242, 0.9);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 230px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--mint));
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 12px; }

.main-nav {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.main-nav a {
  min-width: 72px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #46566f;
  text-align: center;
}

.main-nav a:hover, .main-nav a.active {
  background: var(--surface-strong);
  color: var(--brand-strong);
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: #46566f;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(32, 168, 134, 0.14);
}

.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 4px auto;
  border-radius: 2px;
  background: #41516a;
}

main {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.view { display: none; }
.view.active { display: block; }

.hero {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: #101c2f;
}

.hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(13, 28, 49, 0.9), rgba(13, 28, 49, 0.5) 52%, rgba(13, 28, 49, 0.12)),
    linear-gradient(0deg, rgba(12, 22, 36, 0.26), transparent 38%);
}

.hero-overlay {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(280px, 600px) minmax(240px, 340px);
  gap: 32px;
  align-items: end;
  min-height: 430px;
  padding: clamp(24px, 5vw, 56px);
  color: #fff;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--mint);
  font-size: 13px;
  font-weight: 700;
}

.hero h1, .page-heading h1, .section-heading h2, .form-panel h2, .panel-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.hero h1 {
  max-width: 620px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.05;
}

.hero p {
  max-width: 620px;
  margin: 18px 0 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 17px;
  line-height: 1.8;
}

.hero-actions, .page-heading, .section-heading, .panel-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-actions { margin-top: 28px; }

.primary-action, .secondary-action, .ghost-button, .text-link, .quick-strip a, .order-query button, .search-box button, .tiny-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary-action, .order-query button, .search-box button {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 22px rgba(29, 111, 216, 0.22);
}

.primary-action:hover, .order-query button:hover, .search-box button:hover { background: var(--brand-strong); }
.secondary-action { border: 1px solid rgba(255, 255, 255, 0.38); background: rgba(255, 255, 255, 0.15); color: #fff; }
.ghost-button { border: 1px solid var(--line); background: var(--surface); color: #41516a; }
.text-link { color: var(--brand); padding: 0; min-height: auto; }
.full { width: 100%; }

.hero-metrics { display: grid; gap: 12px; }

.hero-metrics article {
  min-height: 84px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(16px);
}

.hero-metrics strong { display: block; font-size: 30px; }
.hero-metrics span { color: rgba(255, 255, 255, 0.76); }

.quick-strip {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(3, auto);
  gap: 12px;
  align-items: center;
  margin-top: 18px;
}

.search-box, .order-query {
  display: grid;
  grid-template-columns: 1fr auto;
  min-height: 48px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-box input, .order-query input {
  width: 100%;
  min-width: 0;
  border: 0;
  padding: 0 16px;
  background: transparent;
  outline: 0;
}

.quick-strip a { border: 1px solid var(--line); background: var(--surface); color: #41516a; }

.section-block { margin-top: 34px; }
.section-heading, .page-heading, .panel-heading { justify-content: space-between; margin-bottom: 18px; }
.page-heading { min-height: 74px; margin-bottom: 22px; }
.page-heading h1 { font-size: clamp(28px, 4vw, 42px); }

.category-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 14px;
}

.category-card, .product-card, .license-card, .stat-card, .form-panel, .table-wrap, .admin-panel, .preview-card, .summary-card, .domain-chain {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.category-card {
  min-height: 126px;
  padding: 18px;
  cursor: pointer;
  text-align: left;
}

.category-card:hover, .product-card:hover, .license-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.category-icon, .product-thumb, .license-badge {
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
}

.category-icon { width: 44px; height: 44px; margin-bottom: 14px; }
.category-card strong, .category-card span { display: block; }
.category-card span { margin-top: 6px; color: var(--muted); font-size: 13px; }

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

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

.product-card {
  display: flex;
  flex-direction: column;
  min-height: 330px;
  padding: 16px;
}

.product-card header {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
}

.product-thumb { width: 54px; height: 54px; }
.product-card h3 { margin: 0; font-size: 17px; line-height: 1.35; }
.product-card .seller { margin-top: 4px; color: var(--muted); font-size: 13px; }
.product-card p { min-height: 58px; margin: 14px 0; color: #58677d; line-height: 1.65; }

.product-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }

.tag, .state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: #eef4ff;
  color: #3e5f94;
  font-size: 13px;
  font-weight: 700;
}

.state-pill.pending { background: #fff5dd; color: #9a620b; }
.state-pill.approved { background: #e5f8f2; color: #146f5a; }
.state-pill.rejected { background: #ffe9ed; color: #9e263b; }
.state-pill.offline { background: #eef1f6; color: #52627a; }

.product-media {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  margin-bottom: 14px;
  overflow: hidden;
  border-radius: 8px;
  background: #eef4ff;
}

.product-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-media-fallback {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
}

.product-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: -4px 0 14px;
}

.product-gallery img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4ff;
}

.video-link {
  text-decoration: none;
}

.product-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.price { color: var(--rose); font-size: 22px; font-weight: 800; }
.price small { font-size: 13px; }

.market-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px 180px;
  gap: 12px;
  margin-bottom: 16px;
}

.market-toolbar input, .market-toolbar select, .form-panel input, .form-panel select, .form-panel textarea, .agent-switch {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  outline: 0;
}

.agent-switch { max-width: 220px; }
.form-panel textarea { min-height: auto; padding: 12px; resize: vertical; }

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

.two-column {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.form-panel { display: grid; gap: 14px; padding: 20px; }
.compact-form { max-width: 640px; }
.form-panel label { display: grid; gap: 8px; color: #40506a; font-weight: 700; }
.form-panel .toggle-field {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}
.form-panel .toggle-field input {
  width: 18px;
  min-height: 18px;
  margin-top: 3px;
}
.form-panel .toggle-field small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}
.form-panel .disclaimer-box {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  color: #243653;
  font-weight: 600;
  line-height: 1.55;
}
.form-panel .disclaimer-box input {
  width: 18px;
  min-height: 18px;
  margin-top: 3px;
}
.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.table-wrap { overflow-x: auto; }
.top-gap { margin-top: 16px; }

table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8fbff; color: #52627a; font-size: 13px; }
td { color: #314157; }
tr:last-child td { border-bottom: 0; }
.license-table { min-width: 1240px; }
.cell-stack {
  display: grid;
  gap: 4px;
  min-width: 120px;
}
.cell-stack strong {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
}
.cell-stack small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  word-break: break-all;
}
.license-record-list {
  display: grid;
  gap: 12px;
}
.license-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, auto);
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.license-record-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.license-record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.license-code-block {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.license-code-block span,
.license-detail span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.license-code-block strong {
  display: inline-block;
  max-width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  background: #101c2f;
  color: #d9fff4;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-all;
}
.license-record-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
}
.license-detail {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid #e8eef8;
  border-radius: 8px;
  background: #f8fbff;
}
.license-detail strong {
  color: var(--ink);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.license-detail small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.license-record-actions {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}
.license-record-actions .table-actions {
  justify-content: flex-end;
  min-width: 0;
  max-width: 260px;
}

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

.license-card { min-height: 158px; padding: 16px; }
.license-card h3 { margin: 14px 0 8px; font-size: 16px; }
.license-card p { margin: 0; color: var(--muted); line-height: 1.6; }
.license-badge { width: 42px; height: 42px; background: #eef4ff; color: var(--brand); }

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

.stat-card { min-height: 112px; padding: 18px; }
.stat-card strong { display: block; font-size: 30px; }
.stat-card span { color: var(--muted); }

.admin-layout {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 16px;
  align-items: start;
}

.admin-tabs {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-tabs button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #4a5a72;
  cursor: pointer;
  text-align: left;
  padding: 0 12px;
}

.admin-tabs button.active {
  background: var(--surface-strong);
  color: var(--brand-strong);
  font-weight: 800;
}

.admin-panel { display: none; padding: 18px; }
.admin-panel.active { display: block; }

.agent-summary, .review-list, .payment-list, .software-admin-list, .domain-list, .agent-list, .withdraw-list {
  display: grid;
  gap: 12px;
}

.summary-card, .review-item, .payment-item, .software-admin-item, .domain-item, .agent-item, .withdraw-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.summary-card { grid-template-columns: 1fr; }
.summary-card h3, .review-item h3, .payment-item h3, .software-admin-item h3, .domain-item h3, .agent-item h3, .withdraw-item h3 { margin: 0 0 6px; font-size: 16px; }
.summary-card p, .review-item p, .payment-item p, .software-admin-item p, .domain-item p, .agent-item p, .withdraw-item p { margin: 0; color: var(--muted); line-height: 1.55; }

.button-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.table-actions { justify-content: flex-start; min-width: 190px; }
.tiny-button { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); background: var(--surface); color: #40506a; }
.tiny-button.primary { border-color: transparent; background: var(--brand); color: #fff; }
.tiny-button.danger { border-color: transparent; background: var(--rose); color: #fff; }

.empty-state {
  display: grid;
  min-height: 160px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.modal {
  width: min(960px, calc(100% - 30px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop { background: rgba(13, 25, 42, 0.48); backdrop-filter: blur(4px); }
.modal-box { position: relative; margin: 0; padding: 24px; background: var(--surface); }
#productEditForm {
  display: grid;
  gap: 14px;
}

#productEditForm label {
  display: grid;
  gap: 8px;
  color: #40506a;
  font-weight: 700;
}

#productEditForm input,
#productEditForm select,
#productEditForm textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  outline: 0;
}

#productEditForm textarea {
  min-height: auto;
  padding: 12px;
  resize: vertical;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.purchase-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, 360px); gap: 18px; }
.purchase-layout h2 { margin: 0 38px 10px 0; }
.purchase-layout p { color: var(--muted); line-height: 1.7; }

.pay-panel {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.pay-panel label { display: grid; gap: 8px; font-weight: 700; }
.pay-panel select, .pay-panel input { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; }
.payment-choice-section {
  display: grid;
  gap: 10px;
}
.pay-label {
  color: #40506a;
  font-weight: 800;
}
.payment-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.payment-choice {
  position: relative;
  display: grid;
  gap: 8px;
  min-width: 0;
  cursor: pointer;
}
.payment-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.payment-choice-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 62px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.payment-choice input:checked + .payment-choice-card {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29, 111, 216, 0.12);
}
.pay-logo {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}
.pay-logo.wechat { background: #20a886; }
.pay-logo.qqpay { background: #7659d6; }
.pay-logo.bank { background: #253348; }
.pay-logo.balance { background: #f59d22; }
.payment-choice-card strong,
.payment-choice-card small {
  display: block;
  line-height: 1.15;
}
.payment-choice-card small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}
.payment-channel-name {
  color: #e60033;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}
.payment-choice > small {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.compact-empty {
  min-height: 62px;
  padding: 12px;
}

.delivery-code {
  padding: 8px 10px;
  border-radius: 8px;
  background: #101c2f;
  color: #d9fff4;
  font-family: Consolas, "Courier New", monospace;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 80;
  transform: translate(-50%, 12px);
  min-width: 220px;
  max-width: min(520px, calc(100% - 40px));
  padding: 12px 16px;
  border-radius: 8px;
  background: #102139;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  text-align: center;
}

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

.backend-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(13, 37, 48, 0.92), rgba(16, 28, 47, 0.94)),
    url("assets/hero-marketplace.png") center / cover;
}

.backend-login-card {
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(8, 19, 34, 0.32);
}

.backend-login-card .brand-mark {
  width: 48px;
  height: 48px;
}

.backend-login-card h1 {
  margin: 6px 0 8px;
  font-size: 30px;
  letter-spacing: 0;
}

.backend-login-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.backend-login-card label {
  display: grid;
  gap: 8px;
  color: #40506a;
  font-weight: 800;
}

.backend-login-card input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

.master-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.master-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px;
  background: #101c2f;
  color: #fff;
}

.master-sidebar .brand { min-width: 0; margin-bottom: 24px; }
.master-sidebar .brand small { color: rgba(255, 255, 255, 0.64); }

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

.master-nav button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.76);
  cursor: pointer;
  text-align: left;
  padding: 0 12px;
}

.master-nav button.active {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font-weight: 800;
}

.backend-session {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.backend-session span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.backend-session button {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

.master-content {
  padding: 24px clamp(18px, 4vw, 42px) 56px;
}

.master-panel { display: none; }
.master-panel.active { display: block; }

.domain-chain {
  padding: 16px;
  margin-bottom: 14px;
  background: #fbfcff;
}

.domain-chain strong { display: block; margin-bottom: 8px; }
.domain-flow { display: flex; flex-wrap: wrap; gap: 8px; color: #40506a; }
.domain-flow span { padding: 8px 10px; border-radius: 8px; background: #eef4ff; }

.license-sidebar {
  background: #0d2530;
}

.endpoint-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.endpoint-list span {
  padding: 8px 10px;
  border-radius: 8px;
  background: #eef4ff;
  color: #243653;
  font-weight: 700;
  font-size: 13px;
}

.license-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px;
  gap: 12px;
  margin: 18px 0 14px;
}

.license-toolbar input,
.license-toolbar select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  outline: 0;
}

#licenseDbExport,
#licenseDbImportForm textarea {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.usage-guide-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 18px;
  align-items: start;
}

.compact-heading { margin-top: 4px; }
.compact-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

.usage-guide-editor-list { display: grid; gap: 12px; }
.usage-guide-editor-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}
.usage-guide-item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.usage-guide-item-head strong { color: var(--ink); }
.usage-guide-item-actions { display: flex; gap: 6px; }
.usage-guide-item-actions button { min-width: 36px; padding: 0 10px; }
.usage-guide-preview-panel { position: sticky; top: 18px; }
.usage-guide-preview { display: grid; gap: 12px; }
.usage-guide-preview h3 { margin: 0; font-size: 22px; }
.usage-guide-preview > p { margin: -4px 0 4px; }
.usage-guide-preview-link {
  display: block;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.usage-guide-preview-link strong { display: block; margin-bottom: 6px; }
.usage-guide-preview-link span,
.usage-guide-preview-link small { display: block; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.usage-guide-preview-link small { margin-top: 7px; }
.version-release-preview { display: grid; gap: 14px; }
.version-release-preview h3 { margin: 0; font-size: 22px; }
.version-release-preview p { margin: 0; color: var(--muted); line-height: 1.65; white-space: pre-wrap; }
.version-release-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.version-release-meta span { padding: 6px 9px; border-radius: 6px; background: #eef5ff; color: #245b96; font-size: 13px; font-weight: 700; }
.version-release-section { padding-top: 12px; border-top: 1px solid var(--line); }
.version-release-section strong { display: block; margin-bottom: 8px; }
.version-release-section ul { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.75; }
.version-release-download { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; border-radius: 6px; background: var(--brand); color: white; font-weight: 700; text-decoration: none; }
.version-release-download.disabled { background: #dfe6ee; color: #718095; pointer-events: none; }

.compact-toggle { align-self: end; margin-bottom: 2px; }
.license-plan-editor-list { display: grid; gap: 12px; }
.license-plan-editor-item {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}
.license-plan-editor-head { display: flex; align-items: center; gap: 12px; }
.license-plan-editor-head strong { margin-right: auto; }
.license-plan-editor-head .checkbox-line { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.license-plan-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 90px;
  gap: 10px;
}
.license-plan-editor-grid label { min-width: 0; }
.license-plan-preview { display: grid; gap: 14px; }
.license-plan-preview.is-disabled { opacity: .58; }
.license-plan-preview table { width: 100%; border-collapse: collapse; font-size: 13px; }
.license-plan-preview th,
.license-plan-preview td { padding: 10px 8px; border: 1px solid var(--line); text-align: left; }
.license-plan-preview th { background: #eef5ff; color: #31435f; }
.license-plan-preview td:last-child { color: #f45d22; font-weight: 800; }
.license-plan-preview-notice {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--brand);
  border-radius: 4px;
  background: #eef8ff;
  color: #40506a;
  line-height: 1.6;
  white-space: pre-wrap;
}

@media (max-width: 1020px) {
  .topbar { grid-template-columns: auto auto 1fr; }
  .menu-toggle { display: block; grid-column: 2; }
  .main-nav {
    position: absolute;
    top: 72px;
    left: 16px;
    right: 16px;
    display: none;
    grid-template-columns: repeat(2, 1fr);
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .main-nav.open { display: grid; }
  .account-chip { justify-self: end; }
  .hero-overlay, .auth-layout, .two-column, .admin-layout { grid-template-columns: 1fr; }
  .hero-metrics { grid-template-columns: repeat(3, 1fr); }
  .category-grid, .license-grid, .product-grid.compact, .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-tabs { grid-template-columns: repeat(4, minmax(120px, 1fr)); overflow-x: auto; }
  .admin-tabs button { text-align: center; }
  .master-shell { grid-template-columns: 1fr; }
  .master-sidebar { position: static; height: auto; }
  .master-nav { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .license-record { grid-template-columns: 1fr; }
  .license-record-actions { justify-content: flex-start; }
  .license-record-actions .table-actions { justify-content: flex-start; max-width: none; }
}

@media (max-width: 720px) {
  main { width: min(100% - 20px, 1220px); padding-top: 14px; }
  .topbar { gap: 10px; min-height: 66px; padding: 0 10px; }
  .brand { min-width: 0; }
  .brand small, .account-chip span:last-child { display: none; }
  .hero, .hero-overlay { min-height: 560px; }
  .hero-overlay { align-items: end; padding: 22px; }
  .hero-metrics, .quick-strip, .market-toolbar, .license-toolbar, .form-row, .purchase-layout, .category-grid, .license-grid, .product-grid, .product-grid.compact, .admin-stats, .master-nav {
    grid-template-columns: 1fr;
  }
  .payment-choice-grid { grid-template-columns: 1fr; }
  .license-record-grid { grid-template-columns: 1fr; }
  .license-record-head { display: grid; justify-content: stretch; }
  .section-heading, .page-heading, .panel-heading, .summary-card, .review-item, .payment-item, .software-admin-item, .domain-item, .agent-item, .withdraw-item {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }
  .button-row { justify-content: flex-start; }
  .usage-guide-layout { grid-template-columns: 1fr; }
  .license-plan-editor-grid { grid-template-columns: 1fr; }
  .usage-guide-preview-panel { position: static; }
  .main-nav { top: 66px; }
}
