:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #fff;
  --surface-soft: #eef3f8;
  --line: #d8e0ea;
  --text: #17202a;
  --muted: #667085;
  --brand: #047a7a;
  --brand-dark: #035f5f;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #067647;
  --warning: #9a6700;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
}

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

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  min-height: 40px;
  padding: 0 12px;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

a {
  color: var(--brand);
}

.app {
  margin: 0 auto;
  max-width: 1440px;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

h1 {
  font-size: 20px;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
}

.summary {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.panel,
.detailPanel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(24, 39, 75, .08);
  margin-bottom: 12px;
  padding: 12px;
}

.panel h2,
.detailPanel h2 {
  font-size: 16px;
  line-height: 1.25;
  margin: 0 0 10px;
}

.loginForm {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
}

.loginForm input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 12px;
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter {
  background: #edf2f7;
  border: 1px solid var(--line);
  color: #1d2939;
  flex: 0 0 auto;
  font-size: 13px;
}

.filter.isActive,
.primary {
  background: var(--brand);
  color: #fff;
}

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

.secondary {
  background: #e9eef5;
  color: #1d2939;
}

.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.success {
  background: #ecfdf3;
  color: var(--success);
}

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(24, 39, 75, .08);
  overflow: hidden;
}

.cardInner {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.selectRow {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  gap: 8px;
  width: fit-content;
}

.selectRow input {
  accent-color: var(--brand);
  height: 18px;
  width: 18px;
}

.cardMain {
  display: grid;
  gap: 10px;
  grid-template-columns: 88px minmax(0, 1fr);
}

.imageBox {
  align-items: center;
  aspect-ratio: 1 / 1;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.imageBox img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

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

.productTitle {
  font-size: 15px;
  line-height: 1.35;
  margin: 0;
}

.meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill {
  background: #e6f4f1;
  border: 1px solid #b8ddd6;
  border-radius: 999px;
  color: #075e54;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 8px;
}

.pill.score {
  background: #eef4ff;
  border-color: #c7d7fe;
  color: #3538cd;
}

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

.fact {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  padding: 7px 8px;
}

.factName {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
}

.factValue {
  display: block;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

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

.notice,
.empty {
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.notice {
  background: #ecfdf3;
  color: var(--success);
}

.notice.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.empty {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
}

.detailPanel {
  bottom: 0;
  left: 0;
  margin: 0;
  max-height: 88vh;
  overflow: auto;
  position: fixed;
  right: 0;
  z-index: 20;
}

.detailHeader {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--surface);
  padding-bottom: 10px;
}

.detailBody {
  display: grid;
  gap: 12px;
}

.detailImage {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  min-height: 180px;
  overflow: hidden;
}

.detailImage img {
  display: block;
  max-height: 260px;
  max-width: 100%;
  object-fit: contain;
}

.previewBox,
.xPostBox,
.rawBox {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 280px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
}

@media (min-width: 760px) {
  .products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .detailPanel {
    border-radius: 8px 0 0 8px;
    bottom: 14px;
    left: auto;
    max-width: 620px;
    right: 14px;
    top: 14px;
  }
}

@media (min-width: 1180px) {
  .products {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
