:root {
  color-scheme: light;
  --bg: #d9f0c9;
  --sky: #b9e7ef;
  --grass: #6fb95b;
  --grass-dark: #3e7f43;
  --wood: #8a5a32;
  --wood-dark: #4f2f1c;
  --soil: #6b472f;
  --panel: #fff3d6;
  --panel-soft: #fff9e9;
  --panel-green: #eaf7df;
  --text: #2f261d;
  --muted: #6d604c;
  --line: #6b472f;
  --line-soft: #d3ad68;
  --red: #c94b4b;
  --teal: #24876e;
  --blue: #3d75b3;
  --gold: #c9942d;
  --green: #4f9845;
  --violet: #875da4;
  --shadow: 0 12px 0 rgba(79, 47, 28, 0.16), 0 22px 34px rgba(54, 37, 22, 0.16);
  --pixel-shadow: 4px 4px 0 rgba(79, 47, 28, 0.74);
  --small-shadow: 3px 3px 0 rgba(79, 47, 28, 0.56);
  --press-shadow: 1px 1px 0 rgba(79, 47, 28, 0.68);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(rgba(255, 255, 255, 0.14) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(180deg, var(--sky) 0 33%, #d7f3d5 33% 58%, var(--bg) 58% 100%);
  color: var(--text);
  font-family:
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui,
    sans-serif;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(45deg, transparent 0 48%, rgba(79, 152, 69, 0.2) 48% 52%, transparent 52%) 0 0 / 56px 56px,
    linear-gradient(135deg, transparent 0 48%, rgba(201, 148, 45, 0.18) 48% 52%, transparent 52%) 18px 12px / 68px 68px;
  content: "";
  pointer-events: none;
}

body.is-authenticated .auth-shell {
  display: none;
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
select,
label.file-button {
  cursor: pointer;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
label.file-button:focus-visible {
  outline: 3px solid rgba(201, 148, 45, 0.52);
  outline-offset: 3px;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px minmax(0, 1fr);
}

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

.auth-panel {
  width: min(100%, 460px);
  border: 3px solid var(--wood-dark);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 0 0 3px rgba(255, 255, 255, 0.54);
  padding: 24px;
}

.auth-brand {
  margin-bottom: 18px;
}

.auth-tabs {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.auth-tab {
  min-height: 44px;
  border: 3px solid var(--line);
  border-radius: 4px;
  background: var(--panel-soft);
  box-shadow: var(--small-shadow);
  color: var(--muted);
  font-weight: 900;
}

.auth-tab.active {
  background: #dff3e5;
  color: #1e684e;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5), var(--small-shadow);
}

.auth-form {
  display: grid;
  gap: 13px;
}

.auth-form p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-error {
  min-height: 22px;
  border-radius: 4px;
  color: #a43235 !important;
  font-weight: 900;
}

.side-panel {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  gap: 14px;
  border-right: 4px solid var(--wood-dark);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(180deg, #9a6738, #774829);
  box-shadow: 8px 0 0 rgba(79, 47, 28, 0.18);
  padding: 20px;
}

.mobile-tools-button {
  display: none;
}

.sidebar-utilities {
  display: grid;
  gap: 14px;
}

.brand,
.toolbar-actions,
.form-actions,
.record-actions,
.filter-group,
.data-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  place-items: center;
  border: 3px solid var(--wood-dark);
  border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.32) 0 12px, transparent 12px 100%),
    linear-gradient(180deg, #ffe07c, #e9a93d);
  box-shadow: var(--small-shadow), inset -5px -5px 0 rgba(128, 76, 28, 0.2);
  color: #9c332f;
  font-weight: 900;
  image-rendering: pixelated;
}

.brand h1,
.brand p,
.page-header h2,
.page-header p,
.form-heading h2,
.form-heading p,
.section-title h3,
.record-identity h3,
.record-identity p,
.record-note,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 1.45rem;
  line-height: 1.15;
}

.brand p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
}

.side-panel .brand h1 {
  color: #fff6d8;
  text-shadow: 2px 2px 0 var(--wood-dark);
}

.side-panel .brand p {
  color: #f7dca9;
}

.app-nav {
  display: grid;
  gap: 10px;
}

.user-panel,
.save-panel {
  display: grid;
  gap: 8px;
  border: 3px solid var(--line);
  border-radius: 5px;
  background: var(--panel);
  box-shadow: var(--small-shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.45);
  padding: 10px;
}

.user-panel span,
.save-panel span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.user-panel strong,
.save-panel strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 0.94rem;
}

.save-panel {
  background: #e8f7e0;
}

.save-panel span {
  color: #276c45;
}

.nav-button,
.side-action {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  border: 3px solid var(--wood-dark);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: var(--small-shadow);
  color: var(--text);
  font-weight: 900;
  text-align: left;
}

.nav-button {
  padding: 0 12px;
}

.nav-button span,
.side-action span {
  display: grid;
  width: 22px;
  flex: 0 0 22px;
  place-items: center;
  color: var(--soil);
}

.nav-button:hover,
.side-action:hover,
.ghost-button:hover,
.secondary-button:hover,
.photo-picker:hover,
.product-option:hover,
.product-row:hover {
  filter: brightness(1.03);
  transform: translate(-1px, -1px);
}

.nav-button.active {
  background: #dff3e5;
  color: #1f6f51;
  box-shadow: 2px 2px 0 rgba(79, 47, 28, 0.74), inset 0 0 0 2px rgba(255, 255, 255, 0.55);
}

.nav-button.active span {
  color: #1f6f51;
}

.data-actions {
  align-items: stretch;
  flex-direction: column;
  margin-top: 0;
}

.side-action {
  min-height: 40px;
  padding: 0 12px;
  text-decoration: none;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.workspace {
  min-width: 0;
  padding: 30px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-header h2 {
  margin-top: 5px;
  color: #24351e;
  font-size: 2.05rem;
  line-height: 1.12;
  text-shadow: 2px 2px 0 rgba(255, 246, 216, 0.9);
}

.page-header p:not(.eyebrow) {
  margin-top: 8px;
  color: #4b6041;
  font-size: 0.96rem;
  font-weight: 700;
}

.eyebrow {
  color: #1f6f51;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.quick-stats {
  display: grid;
  gap: 12px;
}

.overview-stats,
.atlas-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.stat-card {
  position: relative;
  min-height: 118px;
  border: 3px solid var(--line);
  border-top-width: 7px;
  border-radius: 5px;
  background: var(--panel);
  box-shadow: var(--small-shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.42);
  padding: 13px;
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.stat-card strong {
  display: block;
  margin: 10px 0 5px;
  overflow-wrap: anywhere;
  color: #2d3a23;
  font-size: 1.85rem;
  line-height: 1;
}

.accent-red {
  border-top-color: var(--red);
}

.accent-teal {
  border-top-color: var(--teal);
}

.accent-blue {
  border-top-color: var(--blue);
}

.accent-gold {
  border-top-color: var(--gold);
}

.accent-green {
  border-top-color: var(--green);
}

.accent-violet {
  border-top-color: var(--violet);
}

.overview-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.overview-welcome {
  display: grid;
  align-items: center;
  gap: 24px;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  border: 3px solid var(--line);
  border-radius: 6px;
  margin-bottom: 18px;
  background:
    linear-gradient(135deg, rgba(232, 247, 224, 0.96), rgba(255, 243, 214, 0.96));
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.48);
  padding: 24px;
}

.overview-welcome h3 {
  max-width: 680px;
  margin: 6px 0 10px;
  color: #2c4325;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.25;
}

.overview-welcome > div > p:not(.eyebrow) {
  max-width: 660px;
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.7;
}

.welcome-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 1.8rem;
}

.welcome-steps li {
  border: 2px solid var(--line-soft);
  border-radius: 4px;
  background: rgba(255, 249, 233, 0.86);
  color: var(--soil);
  padding: 10px 12px;
}

.welcome-steps li::marker {
  color: var(--teal);
  font-weight: 900;
}

.welcome-steps strong,
.welcome-steps span {
  display: block;
}

.welcome-steps span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

#overviewPage:not(.is-empty) .overview-welcome,
#overviewPage.is-empty .overview-stats,
#overviewPage.is-empty .overview-grid,
#overviewPage.is-empty > .page-header .primary-button {
  display: none;
}

.insight-panel,
.item-form,
.records-panel {
  border: 3px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(255, 255, 255, 0.44);
}

.insight-panel {
  padding: 16px;
}

.wide-panel {
  grid-column: 1 / -1;
}

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

.section-title h3,
.form-heading h2 {
  color: #344023;
  font-size: 1.05rem;
}

.category-bars,
.status-list,
.recent-list {
  display: grid;
  gap: 12px;
}

.category-row {
  display: grid;
  gap: 7px;
}

.category-row-header,
.status-row,
.recent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-row,
.recent-row {
  border: 2px solid var(--line-soft);
  border-radius: 4px;
  background: var(--panel-soft);
  padding: 10px 12px;
}

.status-row strong,
.recent-row strong {
  color: var(--text);
}

.status-row span,
.recent-row span {
  overflow-wrap: anywhere;
}

.bar-track {
  overflow: hidden;
  height: 12px;
  border: 2px solid var(--line);
  border-radius: 3px;
  background: #f1ddb0;
}

.bar-fill {
  height: 100%;
  border-radius: 1px;
  background: var(--teal);
}

.empty-chart,
.empty-state {
  border: 2px dashed var(--line-soft);
  border-radius: 5px;
  background: rgba(255, 249, 233, 0.7);
  color: var(--muted);
  text-align: center;
}

.empty-chart {
  padding: 24px 12px;
  font-size: 0.9rem;
}

.empty-state {
  padding: 44px 18px;
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 1rem;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.records-panel {
  overflow: hidden;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 3px solid var(--line);
  background: rgba(232, 247, 224, 0.68);
  padding: 14px;
}

.search-wrap {
  display: flex;
  width: min(520px, 100%);
  min-height: 46px;
  align-items: center;
  gap: 10px;
  border: 3px solid var(--line);
  border-radius: 4px;
  background: var(--panel-soft);
  box-shadow: inset 3px 3px 0 rgba(145, 103, 57, 0.15);
  padding: 0 13px;
}

.search-wrap span {
  color: var(--soil);
  font-size: 1.1rem;
  font-weight: 900;
}

.search-wrap input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.filter-group {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-group select {
  width: auto;
  min-width: 120px;
}

.records-list {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding: 14px;
}

.records-list::-webkit-scrollbar,
.product-results::-webkit-scrollbar {
  width: 12px;
}

.records-list::-webkit-scrollbar-thumb,
.product-results::-webkit-scrollbar-thumb {
  border: 3px solid var(--panel);
  background: var(--wood);
}

.atlas-panel {
  background: var(--panel);
}

.atlas-content {
  display: grid;
  gap: 18px;
  padding: 14px;
}

.atlas-group {
  display: grid;
  gap: 12px;
}

.atlas-group-ip {
  border-bottom: 3px dashed var(--line-soft);
  padding-bottom: 18px;
}

.atlas-group-ip:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.atlas-group-character {
  border: 2px solid var(--line-soft);
  border-radius: 5px;
  background: rgba(255, 249, 233, 0.64);
  padding: 12px;
}

.atlas-group-title {
  margin-bottom: 0;
}

.atlas-group-title h4 {
  margin: 0;
  color: #344023;
  font-size: 0.96rem;
}

.atlas-group-title span {
  border: 2px solid var(--line);
  border-radius: 3px;
  background: #e8f7e0;
  color: #276c45;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 2px 7px;
}

.atlas-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}

.atlas-card {
  display: grid;
  min-width: 0;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  border: 3px solid var(--line);
  border-radius: 5px;
  background: var(--panel-soft);
  box-shadow: var(--small-shadow);
  padding: 10px;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.atlas-card:hover {
  filter: brightness(1.03);
  transform: translate(-1px, -1px);
}

.atlas-card.is-collected {
  border-color: #8b681c;
  background: #fff4c8;
  box-shadow: 3px 3px 0 rgba(139, 104, 28, 0.62);
}

.atlas-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 3px solid var(--line);
  border-radius: 4px;
  background:
    linear-gradient(45deg, #efe0bb 25%, transparent 25% 75%, #efe0bb 75%),
    linear-gradient(45deg, #efe0bb 25%, #f7eccc 25% 75%, #efe0bb 75%);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
}

.atlas-card.is-missing img {
  filter: grayscale(1) brightness(0.56);
  opacity: 0.55;
}

.atlas-card strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.35;
}

.atlas-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.atlas-status {
  display: inline-flex;
  width: fit-content;
  min-height: 26px;
  align-items: center;
  border: 2px solid var(--line);
  border-radius: 3px;
  margin-top: 8px;
  padding: 0 8px;
  background: #ebe0c2;
  color: #5f5746;
  font-size: 0.74rem;
  font-weight: 900;
}

.atlas-card.is-collected .atlas-status {
  background: #dff3e5;
  color: #1f6f51;
}

.record-card {
  display: grid;
  gap: 14px;
  border: 3px solid var(--line);
  border-radius: 5px;
  background: var(--panel-soft);
  box-shadow: var(--small-shadow);
  padding: 14px;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.record-card:hover {
  filter: brightness(1.02);
  transform: translate(-1px, -1px);
}

.record-photo {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border: 3px solid var(--line);
  border-radius: 4px;
  background: var(--panel-soft);
}

.record-topline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

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

.record-identity h3 {
  overflow-wrap: anywhere;
  font-size: 1.02rem;
  line-height: 1.35;
}

.record-identity p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.category-dot {
  width: 12px;
  height: 12px;
  margin-top: 6px;
  border: 2px solid var(--line);
  border-radius: 2px;
  background: var(--teal);
}

.status-badge {
  display: inline-flex;
  min-height: 30px;
  flex: 0 0 auto;
  align-items: center;
  border: 2px solid #185f4d;
  border-radius: 3px;
  padding: 0 9px;
  background: #dff3e5;
  color: #1f6f51;
  font-size: 0.78rem;
  font-weight: 900;
}

.status-ordered {
  border-color: #2b5b94;
  background: #dceaf8;
  color: #2b5b94;
}

.status-wishlist {
  border-color: #9a6b18;
  background: #fff1ba;
  color: #7d5512;
}

.status-sold {
  border-color: #6a655c;
  background: #e6dfce;
  color: #5f5746;
}

.record-meta {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  margin: 0;
}

.record-meta div {
  min-width: 0;
  border: 2px solid var(--line-soft);
  border-radius: 4px;
  background: #fff7df;
  padding: 9px;
}

.record-meta dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.record-meta dd {
  overflow-wrap: anywhere;
  margin: 4px 0 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 900;
}

.record-note {
  display: none;
  border-left: 4px solid var(--gold);
  color: #514434;
  font-size: 0.9rem;
  line-height: 1.55;
  padding-left: 10px;
}

.record-note:not(:empty) {
  display: block;
}

.record-actions,
.form-actions {
  justify-content: flex-end;
}

.item-form {
  max-width: 1040px;
  padding: 20px;
}

.form-sections {
  display: grid;
  gap: 18px;
}

.form-section {
  min-width: 0;
  border: 2px solid var(--line-soft);
  border-radius: 5px;
  margin: 0;
  background: rgba(255, 249, 233, 0.66);
  padding: 18px;
}

.form-section legend {
  border: 2px solid var(--line);
  border-radius: 4px;
  background: #e8f7e0;
  color: #295f3c;
  font-size: 0.88rem;
  font-weight: 900;
  padding: 5px 10px;
}

.required-note {
  margin-left: 4px;
  color: #a43235;
  font-size: 0.72rem;
  font-style: normal;
}

.form-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.form-heading p:not(.eyebrow) {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

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

label {
  display: grid;
  gap: 7px;
}

label span,
.photo-field > span {
  color: #4c3d2d;
  font-size: 0.82rem;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 3px solid var(--line);
  border-radius: 4px;
  background: #fffdf2;
  box-shadow: inset 3px 3px 0 rgba(145, 103, 57, 0.14);
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

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

.photo-field {
  display: grid;
  gap: 10px;
}

.photo-uploader {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.photo-picker {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--line);
  border-radius: 4px;
  background: var(--panel-soft);
  box-shadow: var(--small-shadow);
  padding: 0 14px;
  color: var(--text);
  font-weight: 900;
}

.photo-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-preview {
  width: min(100%, 360px);
  max-height: 300px;
  object-fit: cover;
  border: 3px solid var(--line);
  border-radius: 4px;
  background: var(--panel-soft);
}

img.image-fallback {
  object-fit: contain !important;
  padding: 10px;
  background: var(--panel-soft) !important;
}

.atlas-card.is-missing img.image-fallback {
  filter: none;
  opacity: 1;
}

.linked-product-section {
  display: grid;
  gap: 10px;
  border: 3px solid var(--line);
  border-radius: 5px;
  background: var(--panel-green);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45);
  padding: 14px;
}

.product-variant-field {
  border-top: 2px dashed rgba(92, 66, 42, 0.42);
  padding-top: 10px;
}

#characterInput[readonly] {
  background: #f1eee1;
  color: var(--muted);
}

.product-search {
  display: grid;
  gap: 10px;
}

.product-results,
.product-list {
  display: grid;
  gap: 10px;
}

.product-results {
  max-height: 300px;
  overflow: auto;
}

.product-option,
.product-row,
.linked-product-card {
  display: grid;
  align-items: center;
  gap: 12px;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  border: 3px solid var(--line);
  border-radius: 5px;
  background: var(--panel-soft);
  box-shadow: var(--small-shadow);
  padding: 10px;
}

.product-option {
  color: var(--text);
  text-align: left;
}

.product-option img,
.product-row img,
.linked-product-card img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border: 3px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
}

.product-option strong,
.product-row strong,
.linked-product-card strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
}

.product-option p,
.product-row p,
.linked-product-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

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

.admin-layout {
  display: grid;
  align-items: start;
  gap: 18px;
  grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
}

.product-form {
  max-width: none;
}

.form-actions {
  margin-top: 16px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  border: 3px solid var(--line);
  border-radius: 4px;
  box-shadow: var(--small-shadow);
  font-weight: 900;
  padding: 0 13px;
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
  white-space: nowrap;
}

.primary-button {
  background: #49a764;
  color: #fffdf2;
  text-shadow: 1px 1px 0 rgba(47, 38, 29, 0.6);
}

.primary-button:hover {
  background: #3c9356;
  filter: brightness(1.05);
}

.secondary-button,
.ghost-button {
  background: var(--panel-soft);
  color: var(--text);
}

.danger-button {
  background: #ffe0d6;
  color: #a43235;
}

.danger-button:hover {
  background: #ffd0c4;
  filter: brightness(1.03);
}

.primary-button:not(:disabled):active,
.secondary-button:not(:disabled):active,
.ghost-button:not(:disabled):active,
.danger-button:not(:disabled):active,
.nav-button:not(:disabled):active,
.side-action:not(:disabled):active,
.auth-tab:not(:disabled):active,
.photo-picker:active,
.product-option:not(:disabled):active {
  box-shadow: var(--press-shadow);
  transform: translate(2px, 2px);
}

button:disabled {
  cursor: default;
  filter: grayscale(0.18);
  opacity: 0.72;
  transform: none;
}

.hidden {
  display: none !important;
}

@media (max-width: 1040px) {
  .app-shell {
    align-content: start;
    grid-template-columns: 1fr;
  }

  .side-panel {
    display: grid;
    min-height: auto;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.45fr);
    border-right: 0;
    border-bottom: 4px solid var(--wood-dark);
    box-shadow: 0 8px 0 rgba(79, 47, 28, 0.18);
    padding: 18px;
  }

  .app-nav,
  .sidebar-utilities,
  .save-panel,
  .data-actions {
    grid-column: 1 / -1;
  }

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

  .sidebar-utilities .data-actions {
    grid-column: 1 / -1;
  }

  .app-nav {
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  }

  .data-actions {
    flex-direction: row;
    margin-top: 0;
  }

  .overview-stats,
  .atlas-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .records-list {
    max-height: none;
  }

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

@media (max-width: 760px) {
  .workspace {
    padding: 14px;
  }

  .side-panel {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    min-height: 0;
    align-items: center;
    flex-direction: row;
    gap: 10px;
    border-bottom-width: 3px;
    box-shadow: 0 5px 0 rgba(79, 47, 28, 0.18);
    padding: 10px 12px;
  }

  .side-panel .brand {
    min-width: 0;
    flex: 1;
    gap: 10px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .brand h1 {
    font-size: 1.08rem;
  }

  .side-panel .brand p {
    display: none;
  }

  .mobile-tools-button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--wood-dark);
    border-radius: 4px;
    background: var(--panel);
    box-shadow: var(--small-shadow);
    color: var(--text);
    font-weight: 900;
    padding: 0 13px;
  }

  .mobile-tools-button[aria-expanded="true"] {
    background: #dff3e5;
    color: #1f6f51;
  }

  .sidebar-utilities {
    position: absolute;
    top: calc(100% + 8px);
    right: 12px;
    left: 12px;
    display: none;
    max-height: calc(100vh - 100px);
    overflow: auto;
    grid-template-columns: 1fr;
    border: 3px solid var(--wood-dark);
    border-radius: 5px;
    background:
      linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px) 0 0 / 18px 18px,
      linear-gradient(180deg, #9a6738, #774829);
    box-shadow: var(--shadow);
    padding: 12px;
  }

  .side-panel.tools-open .sidebar-utilities {
    display: grid;
  }

  .user-panel,
  .save-panel {
    padding: 10px;
  }

  .app-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
    gap: 4px;
    border-top: 3px solid var(--wood-dark);
    background: rgba(119, 72, 41, 0.97);
    box-shadow: 0 -5px 0 rgba(79, 47, 28, 0.18);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }

  .nav-button {
    display: grid;
    min-height: 52px;
    justify-content: center;
    justify-items: center;
    gap: 2px;
    border: 0;
    background: transparent;
    box-shadow: none;
    color: #fff3d6;
    font-size: 0.72rem;
    padding: 4px 2px;
    text-align: center;
  }

  .nav-button span {
    width: 18px;
    flex-basis: 18px;
    color: #ffe4a4;
    font-size: 1rem;
  }

  .nav-button.active {
    border: 2px solid var(--wood-dark);
    background: #dff3e5;
    box-shadow: none;
    color: #1f6f51;
  }

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

  .side-action {
    justify-content: center;
  }

  .page-header,
  .list-toolbar,
  .form-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .page-header h2 {
    font-size: 1.62rem;
  }

  .page-header .primary-button,
  .form-actions .primary-button,
  .form-actions .secondary-button,
  .form-actions .ghost-button,
  .form-actions .danger-button {
    width: 100%;
  }

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

  .overview-welcome {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .workspace {
    min-height: calc(100vh - 65px);
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .form-actions,
  .record-actions {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .filter-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .filter-group select:last-child {
    grid-column: 1 / -1;
  }

  .filter-group select {
    width: 100%;
  }

  .search-wrap {
    width: 100%;
  }

  .status-row,
  .recent-row,
  .record-topline {
    align-items: stretch;
    flex-direction: column;
  }

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

  .record-meta div:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .product-option,
  .product-row,
  .linked-product-card {
    grid-template-columns: 62px minmax(0, 1fr);
  }

  .product-option img,
  .product-row img,
  .linked-product-card img {
    width: 62px;
    height: 62px;
  }

  .product-row-actions,
  .linked-product-card .ghost-button {
    grid-column: 1 / -1;
  }

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

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

  .item-form {
    padding: 16px;
  }

  .form-section {
    padding: 14px;
  }
}

@media (max-width: 430px) {
  .auth-shell {
    padding: 14px;
  }

  .auth-panel {
    padding: 18px;
  }

  .workspace,
  .side-panel {
    padding: 10px;
  }

  .app-nav {
    gap: 3px;
  }

  .nav-button,
  .side-action {
    font-size: 0.78rem;
  }

  .overview-stats,
  .atlas-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-card {
    min-height: 112px;
    padding: 11px;
  }

  .stat-card strong {
    font-size: 1.38rem;
  }

  .atlas-card {
    padding: 8px;
  }

  .atlas-card strong {
    font-size: 0.86rem;
  }

  .atlas-card p {
    font-size: 0.76rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
