:root {
  color-scheme: light;
  --paper: #f7f4ee;
  --surface: #fffdf8;
  --surface-2: #f0eee8;
  --ink: #25221f;
  --muted: #766f66;
  --line: #ddd7ce;
  --teal: #0f8f83;
  --teal-soft: #dff2ed;
  --rose: #b34d6b;
  --rose-soft: #f6e3e9;
  --gold: #a06b18;
  --gold-soft: #f7ecd4;
  --blue: #446ea6;
  --blue-soft: #e3ebf7;
  --shadow: 0 18px 50px rgba(58, 48, 38, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui,
    -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: #ede7df;
  display: flex;
  flex-direction: column;
  gap: 26px;
  z-index: 20;
}

.brand,
.mobile-brand,
.panel-heading,
.section-head,
.topbar,
.hero-band,
.hero-actions,
.top-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 760;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.3;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.icon-button:hover,
.tool-button:hover,
.nav-item:hover,
.filter-chip:hover,
.text-button:hover {
  background: rgba(37, 34, 31, 0.07);
}

.menu-toggle span,
.mobile-brand .icon-button span {
  width: 18px;
  height: 12px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  position: relative;
}

.menu-toggle span::after,
.mobile-brand .icon-button span::after {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 18px;
  border-top: 2px solid currentColor;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 11px;
  text-align: left;
}

.nav-item.active {
  background: var(--surface);
  color: var(--teal);
  box-shadow: inset 3px 0 0 var(--teal);
}

.nav-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.55);
  display: inline-grid;
  place-items: center;
  color: currentColor;
  font-size: 16px;
}

.sidebar-footer {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-footer p {
  margin: 0 0 4px;
}

.content {
  min-width: 0;
  padding: 22px 28px 40px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  gap: 14px;
  padding: 10px 0 20px;
  background: rgba(247, 244, 238, 0.92);
  backdrop-filter: blur(16px);
}

.mobile-brand {
  display: none;
  gap: 8px;
  flex: 0 0 auto;
}

.search-field {
  min-width: 220px;
  flex: 1 1 auto;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
}

.search-field span {
  color: var(--muted);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.top-actions,
.hero-actions {
  gap: 8px;
  flex-wrap: wrap;
}

.tool-button,
.text-button,
.filter-chip,
.segmented button {
  min-height: 38px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 0 13px;
  white-space: nowrap;
}

.tool-button.primary,
.filter-chip.active,
.segmented button.active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

.tool-button.accent {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--teal);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-band {
  justify-content: space-between;
  gap: 22px;
  min-height: 150px;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(15, 143, 131, 0.12), rgba(179, 77, 107, 0.08)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.metric {
  min-height: 106px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.metric strong {
  display: block;
  margin-bottom: 8px;
  font-size: 26px;
  line-height: 1.1;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 16px;
}

.panel {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.panel-heading,
.section-head {
  justify-content: space-between;
  gap: 16px;
}

.compact-list,
.records-list,
.bar-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.compact-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
}

.thumb {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: var(--surface-2);
  object-fit: cover;
  border: 1px solid var(--line);
}

.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 750;
}

.card-placeholder {
  width: 100%;
  height: 100%;
  background: var(--surface-2);
  font-size: 32px;
}

.item-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.meta {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  min-width: 44px;
  min-height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  background: var(--teal-soft);
  color: #086b62;
  font-size: 12px;
}

.badge.warn {
  background: var(--gold-soft);
  color: #86550d;
}

.badge.danger {
  background: var(--rose-soft);
  color: #92324f;
}

.bar-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--teal);
}

.section-head {
  margin: 8px 0 16px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.result-count {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.filter-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.colored-filters {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(15, 143, 131, 0.06), rgba(179, 77, 107, 0.05)),
    rgba(255, 253, 248, 0.72);
}

.filter-chip {
  box-shadow: 0 3px 10px rgba(58, 48, 38, 0.04);
}

.filter-chip.tone-source {
  background: #f7ecd4;
  border-color: #e6c985;
  color: #74500f;
}

.filter-chip.tone-season {
  background: #dff2ed;
  border-color: #a7d7ce;
  color: #086b62;
}

.filter-chip.tone-group {
  background: #e3ebf7;
  border-color: #b6c9e3;
  color: #335a8f;
}

.filter-chip.tone-color {
  background: #f6e3e9;
  border-color: #e5b9c7;
  color: #92324f;
}

.filter-chip.tone-status {
  background: #eee8df;
  border-color: #d7cbbd;
  color: #5b4f44;
}

.filter-chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
  box-shadow: 0 8px 18px rgba(37, 34, 31, 0.18);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.item-card {
  min-width: 0;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(58, 48, 38, 0.06);
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--surface-2);
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.favorite-button {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.92);
  color: var(--ink);
  border: 1px solid rgba(221, 215, 206, 0.85);
}

.favorite-button.active {
  background: var(--rose);
  color: #fff;
  border-color: var(--rose);
}

.card-body {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.card-title {
  min-height: 42px;
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  max-width: 100%;
  min-height: 25px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tag.teal {
  background: var(--teal-soft);
  color: #087166;
}

.tag.rose {
  background: var(--rose-soft);
  color: #92324f;
}

.tag.blue {
  background: var(--blue-soft);
  color: #335a8f;
}

.open-detail {
  justify-self: stretch;
}

.inventory-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.inventory-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.inventory-table th,
.inventory-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.inventory-table th {
  color: var(--muted);
  font-size: 12px;
  background: #f3eee7;
}

.inventory-name {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 220px;
}

.records-list {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.record-card {
  min-height: 120px;
  padding: 15px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.record-card dl {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 5px 10px;
  margin: 12px 0 0;
  font-size: 13px;
}

.record-card dt {
  color: var(--muted);
}

.record-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented button {
  border: 0;
  background: transparent;
}

.detail-dialog {
  width: min(920px, calc(100vw - 30px));
  max-height: min(820px, calc(100vh - 30px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.add-dialog {
  width: min(820px, calc(100vw - 28px));
  max-height: min(860px, calc(100vh - 28px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.add-dialog::backdrop {
  background: rgba(28, 24, 20, 0.36);
}

.add-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.form-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.photo-picker {
  min-height: 190px;
  border: 1px dashed #cfc5b8;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(15, 143, 131, 0.1), rgba(68, 110, 166, 0.08)),
    var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-weight: 700;
}

.photo-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.image-preview,
.image-preview img {
  width: 100%;
  height: 100%;
  min-height: 190px;
}

.image-preview {
  display: grid;
  place-items: center;
  gap: 6px;
  text-align: center;
  padding: 18px;
}

.image-preview small {
  color: var(--muted);
  font-weight: 500;
}

.image-preview img {
  object-fit: cover;
  padding: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-grid label[hidden] {
  display: none;
}

.form-grid input,
.form-grid textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffaf2;
  color: var(--ink);
  padding: 9px 11px;
  outline: 0;
}

.form-grid textarea {
  resize: vertical;
}

.form-grid input:focus,
.form-grid textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 143, 131, 0.12);
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.choice-field {
  align-content: start;
}

.choice-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 42px;
}

.choice-chip {
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid #d7cbbd;
  background: #fffaf2;
  color: var(--ink);
  padding: 0 13px;
}

.choice-chip:hover {
  background: rgba(15, 143, 131, 0.08);
}

.choice-chip.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
  box-shadow: 0 7px 16px rgba(15, 143, 131, 0.18);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.detail-dialog::backdrop {
  background: rgba(28, 24, 20, 0.36);
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 253, 248, 0.92);
  z-index: 2;
  font-size: 22px;
}

.detail-body {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.1fr);
  gap: 22px;
  padding: 24px;
}

.detail-image {
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  background: var(--surface-2);
  object-fit: cover;
  border: 1px solid var(--line);
}

.detail-info {
  min-width: 0;
}

.detail-title {
  padding-right: 46px;
  margin-bottom: 14px;
  overflow-wrap: anywhere;
}

.detail-grid {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px 12px;
  margin-top: 16px;
}

.detail-grid dt {
  color: var(--muted);
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

.danger-button {
  color: #92324f;
  border-color: #e5b9c7;
  background: #f6e3e9;
}

.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.scrim {
  display: none;
}

@media (max-width: 1080px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(80vw, 290px);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: var(--shadow);
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  body.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(28, 24, 20, 0.28);
    z-index: 14;
  }

  .content {
    padding: 12px 14px 34px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding-bottom: 14px;
  }

  .mobile-brand {
    display: flex;
  }

  .brand .menu-toggle {
    display: none;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hero-band {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }

  h2 {
    font-size: 23px;
  }

  .metric-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-actions {
    width: 100%;
  }

  .section-actions .tool-button,
  .section-actions .result-count {
    flex: 1 1 140px;
  }

  .result-count {
    align-self: stretch;
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .card-title {
    min-height: 48px;
    font-size: 14px;
  }

  .tool-button,
  .filter-chip,
  .segmented button {
    padding-inline: 10px;
  }

  .detail-body {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .add-form {
    padding: 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .detail-title {
    padding-right: 40px;
  }
}

@media (max-width: 430px) {
  .card-grid {
    grid-template-columns: 1fr 1fr;
  }

  .card-body {
    padding: 10px;
  }

  .tag {
    font-size: 11px;
    padding-inline: 7px;
  }

  .top-actions {
    grid-template-columns: 1fr;
  }

  .compact-row {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .compact-row .badge {
    grid-column: 2;
    justify-self: start;
  }
}
