:root {
  --bg: #f4f1ea;
  --paper: #ffffff;
  --ink: #161513;
  --muted: #5e5a54;
  --line: #e3ddd4;
  --red: #d01012;
  --yellow: #f2cd37;
  --high: #16803c;
  --mid: #b45309;
  --low: #c40012;
  --sidebar: 16.5rem;
  --radius: 4px;
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", "Segoe UI Mono", Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font: 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  z-index: 20;
  padding: 0.4rem 0.7rem;
  background: var(--paper);
  color: var(--ink);
}

.skip:focus {
  top: 0.75rem;
}

.top {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem 1.25rem;
  padding: 0.7rem 1.15rem;
  background: var(--red);
  color: #fff;
  border-bottom: 4px solid var(--yellow);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brick {
  flex-shrink: 0;
  display: block;
}

.kicker {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffd4d8;
}

.top h1 {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.pages {
  display: flex;
  gap: 0.2rem;
}

.pages a {
  color: #ffd4d8;
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.32rem 0.65rem;
  border-radius: var(--radius);
}

.pages a:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.18);
}

.pages a[aria-current="page"] {
  background: var(--yellow);
  color: #161513;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
}

.stats li {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
}

.stats b {
  font-variant-numeric: tabular-nums;
  margin-right: 0.25rem;
}

.stats .era {
  background: var(--yellow);
  color: #161513;
  font-weight: 650;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  align-items: start;
  min-height: calc(100vh - 7rem);
}

.filters {
  position: sticky;
  top: 4.55rem;
  max-height: calc(100vh - 4.55rem);
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #ebe7df;
  padding: 0.9rem 0.95rem 2rem;
}

.filters summary {
  cursor: pointer;
  font-weight: 650;
  margin-bottom: 0.85rem;
  list-style: none;
}

.filters summary::-webkit-details-marker {
  display: none;
}

.filters summary::before {
  content: "";
  display: inline-block;
  width: 0.38rem;
  height: 0.38rem;
  margin-right: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-0.05rem, -0.12rem);
  vertical-align: 0.1rem;
}

.filters:not([open]) summary::before {
  transform: rotate(-45deg) translate(-0.05rem, 0.05rem);
}

.field {
  display: grid;
  gap: 0.35rem;
  margin: 0 0 1rem;
  border: 0;
  padding: 0;
  min-width: 0;
}

.field > span,
.field legend {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3f3c38;
}

input[type="search"],
select,
.quiet {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem;
}

input[type="search"]:focus,
select:focus,
textarea:focus,
button:focus-visible,
input[type="range"]:focus-visible,
input[type="number"]:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.range {
  display: grid;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.55rem;
}

.filters input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  margin: 0.45rem 0 0.15rem;
  border-radius: 99px;
  background: #ddd4c8;
  cursor: pointer;
  accent-color: var(--red);
}

.filters input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: transparent;
}

.filters input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(208, 16, 18, 0.35);
  cursor: pointer;
}

.filters input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: transparent;
}

.filters input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 1px rgba(208, 16, 18, 0.35);
  cursor: pointer;
}

.checks {
  display: grid;
  gap: 0.35rem;
}

.checks label,
.check-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.theme-n {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.swatch {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 99px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.check-row {
  margin: 0 0 1rem;
}

.quiet {
  width: auto;
  cursor: pointer;
  background: transparent;
}

.legend {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.legend h2 {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.legend p {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.pill {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--ink);
  color: #fff;
  border-radius: 99px;
  padding: 0.1rem 0.4rem;
}

.bar-swatch {
  width: 1.6rem;
  height: 0.4rem;
  border-radius: 99px;
}

.bar-swatch.is-high { background: var(--high); }
.bar-swatch.is-mid { background: var(--mid); }
.bar-swatch.is-low { background: var(--low); }

main {
  padding: 1rem 1.15rem 2.5rem;
  min-width: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.toolbar-lead {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chips[hidden] {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 99px;
  padding: 0.08rem 0.45rem 0.08rem 0.55rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.chip span[aria-hidden="true"] {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
}

.chip:hover {
  border-color: var(--red);
}

.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.toolbar-right label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
}

.view {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.view button {
  border: 0;
  background: var(--paper);
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  color: var(--muted);
}

.view button.is-on {
  background: var(--ink);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12.4rem, 1fr));
  gap: 0.75rem;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid #e7e1d8;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  width: 100%;
  box-shadow: 0 1px 2px rgba(22, 21, 19, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #cfc8bc;
  box-shadow: 0 8px 18px rgba(22, 21, 19, 0.08);
}

.card:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.card-stripe {
  height: 5px;
}

.thumb {
  position: relative;
  height: 10rem;
  background: #f6f3ee;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card .thumb {
  height: 10.25rem;
  overflow: hidden;
}

.thumb img {
  height: 100%;
  width: 100%;
  object-fit: contain;
  padding: 0.45rem;
}

.card .thumb img {
  position: absolute;
  inset: 0;
  max-height: 100%;
  box-sizing: border-box;
  transition: transform 0.2s ease;
}

.card:hover .thumb img {
  transform: scale(1.045);
}

.fallback {
  display: none;
  font-family: var(--mono);
  font-size: 1.4rem;
  color: #8a847a;
}

.thumb.is-fallback img {
  display: none;
}

.thumb.is-fallback .fallback {
  display: block;
}

.badge,
.set-no,
.qty-badge {
  position: absolute;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 2px;
}

.badge {
  top: 0.45rem;
  left: 0.45rem;
  background: var(--ink);
  color: #fff;
}

.qty-badge {
  top: 0.4rem;
  right: 0.4rem;
  z-index: 1;
  background: var(--yellow);
  color: #161513;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  padding: 0.18rem 0.42rem;
  box-shadow: 0 2px 6px rgba(22, 21, 19, 0.22);
  font-variant-numeric: tabular-nums;
  text-transform: none;
}

.set-no {
  right: 0.45rem;
  bottom: 0.45rem;
  background: rgba(255, 252, 248, 0.92);
  font-family: var(--mono);
  text-transform: none;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.75rem 0.8rem 0.85rem;
  flex: 1;
}

.card h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.3;
  min-height: 2.6em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.tag {
  font-size: 0.68rem;
  font-weight: 650;
  padding: 0.08rem 0.42rem;
  border-radius: 2px;
  color: #fff;
  line-height: 1.45;
}

.card .tag[data-theme] {
  cursor: pointer;
}

.card .tag[data-theme]:hover {
  filter: brightness(1.08);
}

.tag.is-year {
  background: #ece9e2;
  color: var(--muted);
}

.facts {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: auto;
  font-variant-numeric: tabular-nums;
}

.facts-main {
  display: flex;
  gap: 0.7rem;
}

.meter {
  height: 0.28rem;
  background: #ece9e2;
  border-radius: 99px;
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
}

.pct {
  font-size: 0.72rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}

.grid.is-list {
  display: block;
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th,
.table td {
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table th {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.table button {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font-weight: 650;
  text-align: left;
}

.table button:hover {
  text-decoration: underline;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(22, 21, 19, 0.55);
}

.dialog {
  width: min(34rem, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--paper);
  border-radius: 6px;
  box-shadow: 0 16px 40px rgba(22, 21, 19, 0.2);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem 0.9rem;
  color: #fff;
  background: var(--red);
  border-bottom: 3px solid var(--yellow);
}

.dialog-head h2 {
  font-size: 1.2rem;
  font-weight: 650;
}

.dialog-head p {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: #ffd4d8;
  font-family: var(--mono);
}

.close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
}

.dialog-body {
  padding: 1.1rem 1.2rem 1.3rem;
  display: grid;
  gap: 1rem;
}

.hero-img {
  position: relative;
  background: #f0ece4;
  min-height: 10rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-img img {
  max-height: 14rem;
  object-fit: contain;
  margin: 0 auto;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.kpis div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.5rem;
  text-align: center;
}

.kpis b {
  display: block;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.kpis span {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spec {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.spec div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
}

.spec dt {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spec dd {
  margin: 0.15rem 0 0;
  font-weight: 650;
}

.note {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.edit-block {
  display: grid;
  gap: 0.4rem;
}

.edit-block > span {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3f3c38;
}

.pair-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem 1rem;
  align-items: start;
}

.theme-line {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.35rem;
  font-weight: 650;
}

.complete-slider {
  width: 100%;
}

.qty-field,
input[type="number"].qty-field {
  width: 5.5rem;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem;
}

.notes-box {
  width: 100%;
  min-height: 4.5rem;
  resize: vertical;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.5rem 0.55rem;
}

.save-status {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.78rem;
  color: var(--muted);
}

.save-status.is-err {
  color: var(--low);
}

.out-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin: 0;
}

.out-links a {
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 650;
}

kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 0.28rem;
  background: var(--paper);
}

.foot {
  padding: 0.9rem 1.25rem 1.4rem;
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .filters {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stats {
    margin-left: 0;
  }
}

.readout {
  margin: 0;
  white-space: pre-wrap;
}

.export-btn {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.export-btn[hidden] {
  display: none;
}

.login-wrap {
  max-width: 24rem;
  margin: 2.5rem auto;
  padding: 0 1rem 3rem;
}

.login-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: grid;
  gap: 0.85rem;
}

.login-card h2 {
  font-size: 1.15rem;
}

.login-card > p {
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.45rem 0.55rem;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
}

.login-submit {
  border: 0;
  background: var(--red);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.5rem 0.8rem;
  font-weight: 650;
  cursor: pointer;
}

.login-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

.login-error {
  min-height: 1.2em;
  color: var(--low);
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
