:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #64717f;
  --line: #d8e0e8;
  --panel: #ffffff;
  --soft: #f3f7fb;
  --accent: #0f7b6c;
  --accent-strong: #085e53;
  --warn: #ad5c00;
  --shadow: 0 12px 34px rgba(21, 37, 54, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: #eef4f7;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 18px;
}

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

.secondary-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-button:hover {
  border-color: var(--accent);
  background: #f7fbfa;
}

.danger-button {
  background: #b3261e;
}

.danger-button:hover {
  background: #8f1d17;
}

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

.date-input {
  display: block;
  line-height: 56px;
  padding-right: 48px;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
}

.date-control {
  position: relative;
}

.date-input::-webkit-date-and-time-value {
  min-height: 56px;
  line-height: 56px;
  text-align: left;
}

.date-input::-webkit-datetime-edit {
  text-align: left;
}

.date-input::-webkit-calendar-picker-indicator {
  opacity: 0;
  margin: 0;
}

.date-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 54px;
  min-height: 54px;
  border-left: 1px solid var(--line);
  border-radius: 0 6px 6px 0;
  background: #fff;
  padding: 0;
}

.date-toggle:hover {
  background: #f7fbfa;
}

.date-toggle::before {
  content: "";
  width: 16px;
  height: 15px;
  border: 2px solid #17202a;
  border-radius: 3px;
  box-shadow: inset 0 4px 0 0 #fff, inset 0 6px 0 0 #17202a;
}

.date-toggle::after {
  content: "";
  position: absolute;
  top: 17px;
  width: 10px;
  height: 2px;
  border-right: 2px solid #17202a;
  border-left: 2px solid #17202a;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 123, 108, 0.14);
}

label span {
  display: block;
  margin-bottom: 8px;
  color: #33404d;
  font-size: 14px;
  font-weight: 700;
}

.combo-field {
  position: relative;
}

.combo-control {
  position: relative;
  display: block;
}

.combo-control input {
  -webkit-appearance: none;
  appearance: none;
  height: 56px;
  min-height: 56px;
  padding-left: 16px;
  padding-right: 92px;
}

.combo-control input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.combo-clear {
  position: absolute;
  top: 1px;
  right: 45px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 54px;
  min-height: 54px;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  padding: 0;
}

.combo-clear[hidden] {
  display: none;
}

.combo-clear:hover {
  background: #f7fbfa;
  color: var(--ink);
}

.combo-control input:disabled {
  background: #f6f8fa;
  color: var(--muted);
}

.combo-toggle:disabled {
  background: #f6f8fa;
  color: #9aa6b2;
  cursor: not-allowed;
}

.combo-toggle:disabled::before {
  border-top-color: #9aa6b2;
}

.combo-clear::before,
.combo-clear::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.combo-clear::before {
  transform: rotate(45deg);
}

.combo-clear::after {
  transform: rotate(-45deg);
}

.combo-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 44px;
  height: 54px;
  min-height: 54px;
  border-radius: 0 6px 6px 0;
  border-left: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0;
  display: grid;
  place-items: center;
}

.combo-toggle:hover,
.combo-toggle[aria-expanded="true"] {
  background: #f7fbfa;
}

.combo-toggle::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-left: 5px solid transparent;
  border-top: 6px solid #3d4b58;
}

.combo-dropdown {
  position: absolute;
  z-index: 15;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(260px, 45vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(21, 37, 54, 0.14);
  padding: 6px;
}

.combo-option {
  display: block;
  width: 100%;
  min-height: 40px;
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font-weight: 400;
  text-align: left;
  line-height: 1.35;
  padding: 9px 10px;
  touch-action: manipulation;
}

.combo-option:hover {
  background: var(--soft);
}

.combo-empty {
  color: var(--muted);
  padding: 12px 10px;
}

a {
  color: var(--accent-strong);
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.query-hero {
  display: grid;
  align-items: end;
  min-height: 220px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(11, 55, 61, 0.9), rgba(11, 55, 61, 0.46)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='420' viewBox='0 0 1200 420'%3E%3Crect width='1200' height='420' fill='%23d8e8eb'/%3E%3Cg fill='none' stroke='%2393afb5' stroke-width='3' opacity='.7'%3E%3Cpath d='M82 88h270v210H82zM420 68h310v250H420zM792 104h290v182H792z'/%3E%3Cpath d='M118 136h198M118 178h160M118 220h206M458 124h232M458 170h194M458 216h224M828 152h214M828 198h152'/%3E%3Ccircle cx='1026' cy='276' r='50'/%3E%3Cpath d='m1062 312 58 58'/%3E%3C/g%3E%3C/svg%3E")
      center/cover;
  color: #fff;
  padding: 34px;
}

.eyebrow {
  margin: 0 0 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.query-hero h1,
.admin-sidebar h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.18;
}

.hero-copy {
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 16px;
}

.search-panel,
.tool-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
  padding: 18px;
}

.section-heading,
.records-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.results-section {
  margin-top: 24px;
}

.section-heading h2,
.panel-title h2 {
  margin: 0;
  font-size: 22px;
}

.section-heading span {
  color: var(--muted);
  font-weight: 700;
}

.results-list,
.admin-records,
.brand-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.product-result,
.record-row,
.brand-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.product-meta,
.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--soft);
  color: #3d4b58;
  padding: 0 10px;
}

.report-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.report-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 12px;
  text-decoration: none;
}

.report-button {
  width: 100%;
  min-height: 0;
  background: #fff;
  font-weight: 400;
  text-align: left;
}

.report-button:hover {
  background: #fff;
}

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

.report-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.report-text strong {
  overflow-wrap: anywhere;
}

.report-text small {
  color: var(--muted);
  font-size: 13px;
}

.report-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  min-height: 34px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 0 12px;
  white-space: nowrap;
}

.empty {
  border: 1px dashed #b6c3cf;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
  padding: 22px;
  text-align: center;
}

.admin-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  background: #17343a;
  color: #fff;
  padding: 28px;
}

.admin-sidebar .eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

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

.admin-sidebar a,
.menu-button {
  border-radius: 6px;
  color: #e9f8f5;
  padding: 11px 12px;
  text-decoration: none;
}

.menu-button {
  width: 100%;
  min-height: 42px;
  border: 0;
  background: transparent;
  text-align: left;
}

.admin-sidebar a:hover,
.menu-button:hover,
.menu-button.active,
.public-link {
  background: rgba(255, 255, 255, 0.11);
}

.public-link {
  margin-top: auto;
}

.admin-content {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.tool-panel {
  padding: 20px;
}

.admin-page-panel {
  display: none;
}

.admin-page-panel.active {
  display: block;
}

.panel-title p {
  margin: 8px 0 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
  margin-top: 18px;
}

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

.message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--accent-strong);
  font-weight: 700;
}

.message.error {
  color: #b3261e;
}

.inline-search {
  display: grid;
  grid-template-columns: minmax(180px, 260px) auto;
  gap: 10px;
}

.report-search {
  grid-template-columns: minmax(180px, 260px) 150px auto;
}

.record-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.record-row h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

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

.row-actions button {
  min-height: 36px;
  padding: 0 12px;
}

.hidden {
  display: none !important;
}

.preview-open {
  overflow: hidden;
}

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(12, 25, 31, 0.62);
  padding: 18px;
}

.preview-dialog {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1080px, 100%);
  height: min(88vh, 860px);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.preview-header h2 {
  margin: 0;
  font-size: 20px;
}

.preview-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.preview-body {
  min-height: 0;
  overflow: auto;
  background: #f6f8fa;
}

.preview-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.preview-open-new {
  border-top: 1px solid var(--line);
  color: var(--accent-strong);
  font-weight: 700;
  padding: 13px 16px;
  text-decoration: none;
}

.login-panel {
  max-width: 520px;
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 24px, 1120px);
    padding-top: 12px;
  }

  .query-hero {
    min-height: 190px;
    padding: 24px;
  }

  .query-hero h1,
  .admin-sidebar h1 {
    font-size: 26px;
  }

  .search-grid,
  .form-grid,
  .admin-layout,
  .records-toolbar {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .records-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-layout {
    display: block;
  }

  .admin-sidebar {
    padding: 22px;
  }

  .admin-sidebar nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .admin-sidebar a,
  .menu-button {
    text-align: center;
  }

  .public-link {
    margin-top: 0;
  }

  .admin-content {
    width: min(100% - 24px, 1120px);
  }

  .form-grid .wide {
    grid-column: auto;
  }

  .inline-search,
  .report-search {
    width: 100%;
    grid-template-columns: 1fr auto;
  }

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

@media (max-width: 520px) {
  body.public-page {
    background: #fff;
  }

  .public-page .page-shell {
    width: 100%;
    padding: 0 0 28px;
  }

  .public-page .query-hero {
    min-height: 138px;
    border-radius: 0;
    padding: 20px 16px;
  }

  .public-page .query-hero h1 {
    font-size: 24px;
  }

  .public-page .hero-copy {
    margin-top: 8px;
    font-size: 14px;
  }

  .public-page .search-panel {
    margin: 0;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .public-page .search-grid {
    gap: 10px;
    padding: 14px 16px;
  }

  .public-page .search-grid > button {
    width: 100%;
  }

  .public-page .combo-toggle {
    position: absolute;
    right: 1px;
    width: 44px;
    height: 54px;
    min-height: 54px;
  }

  .public-page .results-section {
    margin-top: 16px;
    padding: 0 16px;
  }

  .public-page .section-heading {
    gap: 6px;
  }

  .public-page .section-heading h2 {
    font-size: 19px;
  }

  .admin-sidebar nav,
  .inline-search,
  .report-search,
  .report-link {
    grid-template-columns: 1fr;
  }

  .admin-sidebar nav {
    display: grid;
  }

  .report-link {
    display: grid;
  }

  .report-action {
    width: 100%;
    min-height: 40px;
    border-radius: 6px;
  }

  .preview-overlay {
    padding: 0;
  }

  .preview-dialog {
    width: 100%;
    height: 100vh;
    border-radius: 0;
  }

  .preview-header {
    display: grid;
  }

  .tag {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .record-row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
