:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #617069;
  --line: rgba(23, 32, 27, 0.14);
  --blue: #315d8f;
  --green: #2f7d57;
  --amber: #a96112;
  --red: #a43b32;
  --bg: #eef2ef;
  --panel: #fff;
  --soft: #f6f8f6;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body,
button,
input,
select,
textarea {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}

button,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

.brand {
  display: grid;
}

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

.brand span,
.eyebrow,
.auth-context p,
.denied-shell p,
.form-message {
  color: var(--muted);
}

.brand span {
  font-size: 11px;
  font-weight: 800;
}

.eyebrow {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.danger-button,
.admin-header nav a,
.admin-header nav button,
.denied-actions a,
.denied-actions button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 850;
  cursor: pointer;
}

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

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

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

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: 52px;
  min-height: 100vh;
  padding: 48px clamp(24px, 7vw, 96px);
  align-items: center;
}

.auth-context {
  display: grid;
  gap: 48px;
  max-width: 680px;
}

.auth-context > div {
  display: grid;
  gap: 12px;
}

.auth-context h1 {
  font-size: 44px;
  line-height: 1.05;
}

.auth-context p:not(.eyebrow) {
  max-width: 620px;
  line-height: 1.6;
}

.auth-context nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-context nav a {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 850;
}

.auth-panel {
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.auth-panel > div {
  display: grid;
  gap: 4px;
}

.auth-panel h2 {
  font-size: 24px;
}

.auth-panel label,
.product-form label,
.browser-filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input,
select {
  min-height: 40px;
  padding: 0 10px;
}

textarea {
  min-height: 92px;
  padding: 10px;
  line-height: 1.45;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(49, 93, 143, 0.7);
  box-shadow: 0 0 0 3px rgba(49, 93, 143, 0.1);
}

input[readonly] {
  color: var(--muted);
  background: #f0f3f1;
}

.form-message {
  min-height: 18px;
  font-size: 12px;
  font-weight: 800;
}

.form-message.error {
  color: var(--red);
}

.denied-shell {
  display: grid;
  min-height: 100vh;
  padding: 32px;
  place-items: center;
}

.denied-shell > div {
  display: grid;
  gap: 14px;
  width: min(100%, 560px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.denied-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.denied-actions a {
  display: inline-flex;
  align-items: center;
  color: #fff;
  background: var(--blue);
}

.denied-actions button {
  color: var(--blue);
  background: #fff;
}

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

.admin-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) auto;
  gap: 24px;
  min-height: 68px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  align-items: center;
}

.header-title {
  display: grid;
  gap: 2px;
}

.header-title h1 {
  font-size: 18px;
}

.admin-header nav {
  display: flex;
  gap: 7px;
  align-items: center;
}

.admin-header nav a,
.admin-header nav button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--blue);
  background: #fff;
  font-size: 12px;
}

.admin-workspace {
  display: grid;
  grid-template-columns: minmax(310px, 370px) minmax(0, 1fr);
  min-height: calc(100vh - 68px);
}

.catalog-browser {
  position: sticky;
  top: 68px;
  align-self: start;
  display: grid;
  grid-template-rows: auto auto auto minmax(240px, 1fr);
  max-height: calc(100vh - 68px);
  border-right: 1px solid var(--line);
  background: #fff;
}

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

.browser-head > div,
.editor-head > div {
  display: grid;
  gap: 3px;
}

.browser-head h2,
.editor-head h2 {
  font-size: 18px;
}

.browser-head .primary-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 11px;
}

.catalog-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.catalog-stats span {
  display: grid;
  gap: 1px;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 10px;
}

.catalog-stats span + span {
  border-left: 1px solid var(--line);
}

.catalog-stats strong {
  color: var(--ink);
  font-size: 17px;
}

.browser-filters {
  display: grid;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

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

.browser-filters input,
.browser-filters select {
  min-height: 35px;
  font-size: 12px;
}

.product-admin-list {
  overflow: auto;
}

.product-admin-row {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.product-admin-row:hover,
.product-admin-row.active {
  background: #edf4fa;
}

.product-admin-row.active {
  box-shadow: inset 3px 0 0 var(--blue);
}

.row-title,
.row-meta {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
}


.row-title strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-zh-name {
  overflow: hidden;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  color: var(--muted);
  font-size: 10px;
}

.row-badge,
.editor-state {
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--green);
  background: rgba(47, 125, 87, 0.1);
  font-size: 9px;
  font-weight: 900;
}

.row-badge.hidden,
.editor-state.hidden-state {
  color: var(--red);
  background: rgba(164, 59, 50, 0.1);
}


.product-editor {
  min-width: 0;
  padding: 20px clamp(18px, 3vw, 42px) 48px;
}

.editor-head {
  display: flex;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto 14px;
  justify-content: space-between;
  align-items: center;
}

.product-form {
  display: grid;
  gap: 12px;
  max-width: 1080px;
  margin: 0 auto;
}

.form-band {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.identity-band {
  grid-template-columns: minmax(190px, 1.6fr) minmax(140px, 1fr) minmax(110px, 0.7fr) auto;
  align-items: end;
}

.commerce-band {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wide-field,
.full-field {
  grid-column: 1 / -1;
}

.annotation-band,
.bilingual-band {
  border-left: 3px solid var(--amber);
  background: #fffdf8;
}

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

.annotation-head > div,
.bilingual-head > div {
  display: grid;
  gap: 3px;
}

.annotation-head h3,
.bilingual-head h3 {
  margin: 0;
  font-size: 16px;
}

.annotation-head > span,
.bilingual-head > span {
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.compact-head {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.language-field > span {
  display: flex;
  gap: 7px;
  align-items: center;
}

.language-field > span b {
  display: inline-grid;
  width: 25px;
  height: 20px;
  border-radius: 4px;
  place-items: center;
  font-size: 9px;
}

.language-en > span b {
  color: var(--blue);
  background: rgba(49, 93, 143, 0.11);
}

.language-zh > span b {
  color: var(--amber);
  background: rgba(169, 97, 18, 0.11);
}

.language-en input,
.language-en textarea {
  border-left: 3px solid rgba(49, 93, 143, 0.58);
}

.language-zh input,
.language-zh textarea {
  border-left: 3px solid rgba(169, 97, 18, 0.58);
}

.toggle-field {
  display: flex !important;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink) !important;
  background: var(--soft);
  align-items: center;
}

.toggle-field input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.image-upload-field {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.image-upload-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(120px, auto);
  gap: 10px;
  align-items: end;
}

.image-upload-controls input[type="file"] {
  padding: 6px;
  font-size: 12px;
}

.image-upload-controls button {
  min-height: 40px;
}

.image-upload-controls span {
  padding-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.product-image-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.product-image-item {
  position: relative;
  display: grid;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--soft);
}

.product-image-item.primary-image {
  border-color: rgba(169, 97, 18, 0.62);
  box-shadow: inset 0 0 0 1px rgba(169, 97, 18, 0.16);
}

.product-image-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #fff;
}

.product-image-item figcaption {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 8px;
}

.product-image-item figcaption strong {
  font-size: 11px;
}

.product-image-item figcaption span {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-image-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.product-image-actions button,
.primary-image-badge {
  display: inline-flex;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid rgba(49, 93, 143, 0.28);
  border-radius: 5px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.94);
  font-size: 10px;
  font-weight: 900;
  align-items: center;
}

.product-image-actions button {
  cursor: pointer;
}

.product-image-actions .remove-image-button {
  min-height: 28px;
  border: 1px solid rgba(164, 59, 50, 0.28);
  color: var(--red);
}

.primary-image-badge {
  color: var(--amber);
  border-color: rgba(169, 97, 18, 0.3);
  background: rgba(255, 252, 245, 0.96);
}

.empty-image-preview {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
}

.editor-actions {
  position: sticky;
  z-index: 10;
  bottom: 12px;
  display: flex;
  gap: 16px;
  min-height: 62px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 24px rgba(23, 32, 27, 0.11);
  justify-content: space-between;
  align-items: center;
}

.editor-actions > div {
  display: flex;
  gap: 8px;
}

@media (max-width: 980px) {
  .admin-header {
    grid-template-columns: 1fr auto;
  }

  .header-title {
    display: none;
  }

  .admin-workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }

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

@media (max-width: 760px) {
  .auth-shell {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 24px 18px;
    align-content: start;
    align-items: stretch;
  }

  .auth-context,
  .auth-panel {
    width: min(100%, 354px);
    min-width: 0;
    margin-inline: 0;
  }

  .auth-context {
    gap: 24px;
  }

  .auth-context h1 {
    font-size: 31px;
    overflow-wrap: anywhere;
  }

  .admin-header {
    position: static;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .admin-header nav {
    overflow-x: auto;
  }

  .admin-workspace {
    display: block;
  }

  .catalog-browser {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .product-admin-list {
    display: grid;
    grid-auto-columns: minmax(220px, 74vw);
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .product-admin-row {
    border-right: 1px solid var(--line);
  }

  .product-editor {
    padding: 18px 12px 36px;
  }

  .form-band,
  .identity-band,
  .commerce-band {
    grid-template-columns: 1fr;
  }

  .image-upload-controls {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .annotation-head,
  .bilingual-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .annotation-head > span,
  .bilingual-head > span {
    text-align: left;
  }

  .image-upload-controls span {
    padding-bottom: 0;
  }

  .editor-actions {
    bottom: 6px;
    align-items: stretch;
    flex-direction: column;
  }

  .editor-actions > div {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}
