:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #637083;
  --line: #d9e0e7;
  --soft: #f4f7f9;
  --paper: #ffffff;
  --brand: #0f766e;
  --brand-2: #b42318;
  --accent: #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #eef3f6;
}

button,
input,
select {
  font: inherit;
}

button {
  white-space: nowrap;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 16px clamp(16px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-width: 330px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  min-width: 140px;
  min-height: 52px;
  padding: 4px 26px 8px 16px;
  border-radius: 20px;
  background: #1f6b3d;
  color: #fff;
  font-size: 42px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0;
  line-height: 1;
}

.brand-company {
  color: #202326;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 3px;
  text-align: center;
}

.brand-contact {
  color: var(--brand);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.brand-contact:hover {
  text-decoration: underline;
}

.tabs,
.metric-tabs,
.account-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.top-language {
  display: flex;
  grid-auto-flow: column;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: center;
}

.top-language select {
  min-height: 36px;
}

.tab,
.metric,
.primary,
.close {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
}

.tab.active,
.metric.active,
.primary {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

button:disabled,
.primary:disabled {
  cursor: not-allowed;
  border-color: #cbd5e1;
  background: #e2e8f0;
  color: #64748b;
}

main {
  padding: 22px clamp(16px, 4vw, 48px) 48px;
}

.hero {
  min-height: 0;
  padding: 16px;
  background:
    linear-gradient(rgba(14, 29, 39, 0.76), rgba(14, 29, 39, 0.76)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.16) 0 2px, transparent 2px 22px),
    linear-gradient(120deg, #0f766e, #1f4e79 58%, #a63d40);
  color: #fff;
  margin-bottom: 22px;
}

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

.video-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
}

.video-card video,
.video-placeholder {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 230px;
  object-fit: cover;
  background: #111827;
}

.video-placeholder {
  display: grid;
  place-items: center;
}

.video-placeholder span {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  font-size: 24px;
  font-weight: 700;
}

.video-card h3,
.video-card p {
  margin: 0;
}

.video-card div:last-child {
  padding: 10px;
}

.video-card h3 {
  font-size: 15px;
}

.video-card p {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  line-height: 1.45;
}

.video-dots {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.video-dots button {
  width: 8px;
  height: 8px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
}

.video-dots button.active {
  background: #fff;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.toolbar,
.panel,
.quotation {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.catalog-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.tag-sidebar {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.tag-sidebar h3 {
  margin: 0 0 12px;
}

.tag-filter-list,
.selected-tags,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-filter-list {
  flex-direction: column;
}

.tag-filter-list button {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 10px;
}

.tag-filter-list button.active {
  color: #0f172a;
  background: #dbeafe;
  border-color: #93c5fd;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e8f4f1;
  color: #0c625a;
  font-size: 12px;
  line-height: 1.3;
}

.tag-chip.editable {
  border: 1px solid #b7d8d2;
  cursor: pointer;
}

.tag-editor {
  display: grid;
  gap: 8px;
}

.tag-entry {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
}

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

input,
select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

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

.product-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 620px;
}

.product-media,
.detail-media {
  display: grid;
  place-items: center;
  color: var(--text);
  font-weight: 700;
  background: #f3f5f7;
  overflow: hidden;
}

.product-media {
  aspect-ratio: 1 / 1;
  height: auto;
  padding: 8px;
}

.detail-media {
  height: min(58vh, 520px);
  min-height: 320px;
}

.product-media img,
.product-media video,
.detail-media img,
.detail-media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

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

.gallery-thumbs,
.media-preview-list {
  display: flex;
  gap: 8px;
  padding: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.media-thumb {
  position: relative;
  width: 96px;
  height: 72px;
  flex: 0 0 auto;
  padding: 0;
  overflow: hidden;
  background: #f3f5f7;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.media-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-weight: 700;
  line-height: 1;
}

.media-cover {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(20, 83, 45, 0.86);
  color: #fff;
  font-size: 10px;
}

.media-thumb.active {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px #bfdbfe;
}

.media-thumb img,
.media-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.product-card:nth-child(2n) .product-media,
.detail-media.alt {
  background: linear-gradient(135deg, #1f4e79, #a63d40);
}

.product-card article {
  padding: 14px;
  min-width: 0;
}

.product-card h3,
.panel h2,
.quotation h2 {
  margin: 0 0 10px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  min-width: 0;
  overflow-x: auto;
}

.meta-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-price {
  white-space: normal;
  overflow-wrap: anywhere;
}

.card-actions {
  display: flex;
  gap: 8px;
  padding: 0 14px 14px;
  flex-wrap: wrap;
  align-items: center;
}

.card-actions button {
  min-width: 62px;
  flex: 0 0 auto;
}

.price-hidden {
  color: var(--brand-2);
  font-weight: 700;
}

.split,
.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 18px;
}

.admin-layout {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.panel,
.quotation {
  padding: 18px;
}

#quoteForm {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
}

#quoteForm label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

#quoteForm .primary {
  justify-self: start;
  margin-top: 2px;
}

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

.compact-form .primary {
  grid-column: 1 / -1;
}

.compact-form textarea {
  width: 100%;
  resize: vertical;
}

.field-group,
.full-row,
.tier-editor {
  grid-column: 1 / -1;
}

.field-group {
  display: grid;
  grid-template-columns: 70px 92px repeat(3, minmax(90px, 1fr));
  gap: 10px;
  align-items: center;
}

.field-group input,
.field-group select {
  min-width: 0;
}

.field-group span {
  color: var(--muted);
  font-size: 13px;
}

.tier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 8px;
}

.tier-header h3 {
  margin: 0;
}

.tier-editor table {
  width: 100%;
  border-collapse: collapse;
}

.tier-editor th,
.tier-editor td {
  border: 1px solid var(--line);
  padding: 8px;
}

.tier-editor input {
  width: 100%;
}

.upload-box {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px dashed #9aa4af;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.upload-box.drag-over {
  border-color: var(--brand);
  background: #e8f5f3;
}

.upload-box img,
.upload-box video {
  display: none;
  width: min(100%, 320px);
  max-height: 220px;
  object-fit: contain;
  border-radius: 6px;
  background: #111827;
}

.upload-box.has-media img,
.upload-box.has-media video {
  display: block;
}

.upload-box.has-media img[hidden],
.upload-box.has-media video[hidden] {
  display: none;
}

.upload-box .media-thumb img,
.upload-box .media-thumb video {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
}

.tier-actions {
  width: 92px;
}

.quotation table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  background: #fff;
}

.quotation th,
.quotation td {
  border: 1px solid #9aa4af;
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.quote-quantity-input {
  width: 96px;
}

.quote-product-name {
  display: none;
}

.mobile-label {
  display: none;
}

.quote-error {
  display: inline-block;
  margin-top: 4px;
  color: var(--brand-2);
  font-weight: 700;
}

.quote-pending {
  background: #f8fafc;
  color: var(--muted);
}

.quote-calculating {
  color: var(--brand);
  font-weight: 700;
}

.quote-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.quote-notes {
  margin: 14px 0;
  border: 1px solid #111827;
  background: #fff;
}

.quote-notes p {
  margin: 0;
  padding: 9px 10px;
  font-size: 16px;
  line-height: 1.35;
}

.quote-notes p + p {
  border-top: 1px solid #111827;
}

.ranking {
  margin: 16px 0 0;
  padding-left: 24px;
}

.ranking li {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.notice {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.6;
}

.form-status {
  min-height: 20px;
  margin: -4px 0 4px;
  color: var(--brand);
  font-size: 14px;
  line-height: 1.4;
}

.form-status.error {
  color: var(--brand-2);
}

.admin-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.record-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

#productDeleteList {
  max-height: 792px;
  overflow-y: auto;
  padding-right: 6px;
}

#inquiryRecordList {
  max-height: 860px;
  overflow-y: auto;
  padding-right: 6px;
}

.admin-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.admin-row video,
.admin-row img {
  width: 120px;
  height: 76px;
  object-fit: cover;
  border-radius: 6px;
  background: #111827;
}

.admin-row label {
  display: flex;
  grid-auto-flow: column;
  gap: 6px;
  align-items: center;
}

.admin-row .record-check {
  flex: 0 0 auto;
}

.admin-row .record-check input {
  width: auto;
  min-height: auto;
}

.auth-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 16px;
  padding: 18px;
}

#loginForm,
#registerForm {
  display: grid;
  gap: 10px;
  align-content: start;
}

#loginForm input,
#registerForm input,
#loginForm button,
#registerForm button {
  width: 100%;
  min-height: 36px;
}

#registerForm .form-status {
  margin: 0;
}

dialog {
  width: min(780px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.38);
}

.app-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.app-toast.error {
  border-color: #f3b4ac;
  color: var(--brand-2);
}

.close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 24px;
}

.detail {
  display: grid;
  grid-template-columns: 280px 1fr;
}

.detail-copy {
  padding: 22px;
}

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

.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 14px;
}

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

@media (max-width: 820px) {
  .topbar,
  .hero,
  .split,
  .admin-layout,
  .detail,
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: sticky;
    align-items: start;
    gap: 12px;
    padding: 12px;
  }

  body[data-active-view="quote"] .topbar {
    position: static;
  }

  .topbar.compact {
    align-items: center;
    padding: 8px 12px;
  }

  .topbar.compact .brand-lockup,
  .topbar.compact .top-language {
    display: none;
  }

  .topbar.compact .tabs {
    width: auto;
    flex: 1 1 auto;
    gap: 6px;
  }

  .topbar.compact .tab {
    min-height: 34px;
    padding: 7px 10px;
  }

  .topbar.compact .account-bar {
    width: auto;
    margin: 0;
    gap: 6px;
  }

  .topbar.compact #accountStatus {
    flex: 1 1 auto;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar.compact:not(.has-user) #accountStatus {
    display: none;
  }

  .topbar.compact #openAuth,
  .topbar.compact #logoutBtn {
    min-height: 34px;
    padding: 7px 10px;
  }

  .brand-lockup {
    justify-items: start;
    min-width: 0;
    width: 100%;
  }

  .brand-mark {
    min-width: 112px;
    min-height: 42px;
    padding: 3px 20px 6px 12px;
    font-size: 34px;
  }

  .brand-company {
    font-size: clamp(9px, 2.6vw, 13px);
    letter-spacing: 1px;
    text-align: left;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-contact {
    font-size: 13px;
  }

  .tabs {
    width: 100%;
  }

  .tabs [data-view="productEditor"],
  .tabs [data-view="admin"] {
    display: none;
  }

  .account-bar {
    width: 100%;
    gap: 10px;
  }

  #accountStatus {
    flex: 1 1 100%;
  }

  main {
    padding: 14px 10px 32px;
  }

  .toolbar {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .catalog-layout {
    grid-template-columns: 1fr;
  }

  .tag-sidebar {
    padding: 12px;
  }

  .tag-filter-list {
    flex-direction: row;
  }

  .tag-entry {
    grid-template-columns: 1fr;
  }

  .video-showcase {
    grid-template-columns: 1fr;
  }

  .mobile-video-card video,
  .mobile-video-card .video-placeholder {
    max-height: 52vh;
    object-fit: contain;
  }

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

  .product-card {
    min-height: 0;
  }

  .product-media {
    aspect-ratio: 4 / 3;
  }

  .card-actions button {
    min-height: 40px;
  }

  .compact-form {
    grid-template-columns: 1fr;
  }

  .field-group {
    grid-template-columns: 1fr;
  }

  #loginForm {
    display: none;
  }

  .auth-layout {
    display: block;
    padding: 12px;
  }

  .quote-meta {
    flex-direction: column;
  }

  .quotation {
    padding: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .quotation table {
    table-layout: fixed;
    min-width: 560px;
  }

  .quotation th:nth-child(1),
  .quotation td:nth-child(1),
  .quotation th:nth-child(5),
  .quotation td:nth-child(5) {
    display: none;
  }

  .quotation th:nth-child(2) {
    width: 190px;
  }

  .quotation th:nth-child(3),
  .quotation th:nth-child(4) {
    width: 150px;
  }

  .quotation th:nth-child(6) {
    width: 96px;
  }

  .quotation td:nth-child(6) button {
    min-height: 34px;
    padding: 7px 9px;
  }

  .quote-product-name {
    display: block;
    font-weight: 700;
  }

  .quote-description {
    display: none;
  }

  .quote-description-heading .desktop-label {
    display: none;
  }

  .quote-description-heading .mobile-label {
    display: inline;
  }

  .quotation .quote-empty-row td {
    display: table-cell !important;
  }

  .quotation th,
  .quotation td {
    padding: 8px;
  }

  .quote-quantity-input {
    width: 100%;
    min-width: 0;
  }

  #quoteForm .primary {
    margin-top: 8px;
  }

  dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    overflow: auto;
  }

  .detail-media {
    height: min(55vh, 420px);
    min-height: 260px;
  }

  .detail-copy {
    padding: 14px;
  }
}
