:root {
  color-scheme: light;
  --bg: #f3f4f1;
  --surface: #ffffff;
  --surface-soft: #e9ece7;
  --ink: #202421;
  --muted: #6c746f;
  --line: #d9ddd8;
  --accent: #c9513b;
  --accent-dark: #a63d2c;
  --green: #345b54;
  --yellow: #d09a32;
  --blue: #52617a;
  --shadow: 0 16px 40px rgba(30, 38, 33, 0.12);
  --sidebar-width: 244px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  color: inherit;
}

button,
a,
input,
select,
textarea {
  outline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
}

.icon {
  display: inline-flex;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
}

i.icon[data-lucide="plus"]::before { content: "+"; }
i.icon[data-lucide="x"]::before { content: "×"; }
i.icon[data-lucide="search"]::before { content: "⌕"; }
i.icon[data-lucide="menu"]::before { content: "≡"; }

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

.sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fafbf9;
}

.brand {
  display: flex;
  height: 72px;
  align-items: center;
  gap: 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  background: transparent;
  font-size: 20px;
  font-weight: 750;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 5px;
  background: var(--ink);
  color: white;
  font-size: 16px;
}

.side-nav {
  overflow-y: auto;
  padding: 18px 12px;
}

.nav-label {
  margin: 0 8px 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-label-spaced {
  margin-top: 28px;
}

.nav-item,
.quiet-button {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  background: transparent;
  color: #434a46;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.quiet-button:hover {
  background: var(--surface-soft);
}

.nav-item.active {
  background: #dfe7e2;
  color: #23473f;
  font-weight: 700;
}

.nav-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 14px 12px;
}

.storage-summary {
  padding: 4px 8px 16px;
  color: var(--muted);
  font-size: 12px;
}

.storage-summary > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.storage-summary strong {
  color: var(--ink);
  font-weight: 650;
}

.storage-bar {
  height: 4px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 2px;
  background: #dfe3de;
}

.storage-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width 220ms ease;
}

.main-content {
  grid-column: 2;
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  height: 72px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(217, 221, 216, 0.92);
  padding: 12px 30px;
  background: rgba(243, 244, 241, 0.92);
  backdrop-filter: blur(12px);
}

.search-box {
  display: flex;
  width: min(520px, 58vw);
  height: 42px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: var(--surface);
  color: var(--muted);
}

.search-box:focus-within {
  border-color: #9ca7a0;
  box-shadow: 0 0 0 3px rgba(52, 91, 84, 0.1);
}

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

.search-box kbd {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px;
  background: #f5f6f3;
  color: #7f8782;
  font-family: inherit;
  font-size: 10px;
  white-space: nowrap;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 650;
  cursor: pointer;
}

.primary-button {
  margin-left: auto;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
}

.primary-button:hover {
  border-color: #080a09;
  background: #080a09;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
}

.secondary-button:hover {
  border-color: #b8bfba;
  background: #fafbf9;
}

.icon-button {
  width: 40px;
  flex: 0 0 40px;
  border: 1px solid var(--line);
  padding: 0;
  background: var(--surface);
}

.content-wrap {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px 30px 64px;
}

.breadcrumbs {
  display: flex;
  min-height: 28px;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb-button {
  border: 0;
  padding: 3px 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.breadcrumb-button:hover {
  color: var(--ink);
}

.breadcrumb-separator {
  color: #afb5b1;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 18px 0 26px;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-heading h1 {
  max-width: 900px;
  margin: 3px 0 4px;
  font-size: 34px;
  line-height: 1.08;
  overflow-wrap: anywhere;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.page-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.content-section + .content-section {
  margin-top: 38px;
}

.section-heading {
  display: flex;
  min-height: 32px;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
}

.place-grid {
  display: grid;
  grid-auto-flow: dense;
  grid-auto-rows: 72px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}

.place-card {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  padding: 0;
  background: var(--tile-color, var(--green));
  color: white;
  box-shadow: 0 1px 0 rgba(12, 15, 13, 0.08);
}

.place-card.size-small { grid-column: span 3; grid-row: span 2; }
.place-card.size-medium { grid-column: span 4; grid-row: span 3; }
.place-card.size-large { grid-column: span 8; grid-row: span 4; }

.place-card-cover {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  transition: transform 280ms ease;
}

.place-card::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 14, 12, 0.06) 25%, rgba(11, 14, 12, 0.78) 100%);
  content: "";
  pointer-events: none;
}

.place-card.no-cover::after {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.16));
}

.place-card:hover .place-card-cover {
  transform: scale(1.025);
}

.place-open-button {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  width: 100%;
  flex-direction: column;
  justify-content: flex-end;
  border: 0;
  padding: 16px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.place-card.size-small .place-open-button {
  padding: 12px;
}

.place-type {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: auto;
  font-size: 11px;
  font-weight: 650;
  opacity: 0.88;
  text-transform: uppercase;
}

.place-card h3 {
  max-width: 75%;
  margin: 0 0 5px;
  font-size: 21px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.place-card.size-small h3 {
  max-width: 100%;
  font-size: 16px;
}

.place-meta {
  font-size: 12px;
  opacity: 0.8;
}

.place-card-actions {
  position: absolute;
  z-index: 4;
  top: 9px;
  right: 9px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.tile-action-button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 5px;
  background: rgba(16, 20, 18, 0.38);
  color: white;
  cursor: pointer;
}

.place-card:hover .place-card-actions,
.place-card-actions:focus-within {
  opacity: 1;
}

.preview-stack {
  position: absolute;
  z-index: 3;
  right: 14px;
  bottom: 14px;
  display: flex;
}

.preview-stack span {
  display: grid;
  width: 34px;
  height: 34px;
  margin-left: -8px;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  background: #d9ddd8;
  color: #262b28;
  font-size: 11px;
  font-weight: 750;
}

.preview-stack .preview-photo {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background-position: center;
  background-repeat: no-repeat;
}

.place-card.size-small .preview-stack,
.place-card.size-small .place-type {
  display: none;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.item-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.item-card:hover {
  border-color: #b8c0ba;
  box-shadow: 0 8px 24px rgba(37, 45, 40, 0.08);
  transform: translateY(-1px);
}

.item-open-button {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: inherit;
  cursor: pointer;
}

.item-photo {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #e1e4df;
}

.item-photo-image {
  width: 100%;
  height: 100%;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

.item-photo-placeholder {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  background: var(--placeholder, var(--blue));
  color: white;
  font-size: 38px;
  font-weight: 750;
}

.status-badge {
  position: absolute;
  top: 9px;
  left: 9px;
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 4px;
  padding: 3px 7px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(20, 24, 22, 0.12);
}

.status-badge.status-selling { color: #a63d2c; }
.status-badge.status-lent { color: #425778; }
.status-badge.status-using { color: #2b6757; }

.item-card-body {
  min-height: 112px;
  padding: 13px 14px 15px;
}

.item-card h3 {
  margin: 0 0 5px;
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.item-path {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-identified-name {
  overflow: hidden;
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-loan {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 7px 0 0;
  color: #425778;
  font-size: 12px;
  font-weight: 700;
}

.item-loan .icon {
  width: 14px;
  height: 14px;
}

.item-price {
  margin: 13px 0 0;
  font-size: 14px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.item-price.is-personal,
.item-price-secondary.is-personal {
  color: #2f6a4f;
}

.item-price-secondary,
.item-price-origin {
  overflow: hidden;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-price-origin {
  color: #765c2b;
}

.search-summary {
  margin: -8px 0 24px;
  border-left: 3px solid var(--yellow);
  padding: 9px 12px;
  background: #f7f0df;
  color: #5c523e;
  font-size: 13px;
}

.empty-state {
  display: grid;
  min-height: 340px;
  place-items: center;
  align-content: center;
  border: 1px dashed #cbd0cc;
  border-radius: 6px;
  padding: 32px;
  text-align: center;
}

.empty-state[hidden] { display: none; }

.empty-state h2 {
  margin: 14px 0 5px;
  font-size: 20px;
}

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

.empty-state .primary-button {
  margin: 0;
}

.empty-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: #e4e7e3;
  color: var(--muted);
}

.empty-icon .icon {
  width: 24px;
  height: 24px;
}

.app-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-dialog::backdrop {
  background: rgba(18, 22, 20, 0.48);
  backdrop-filter: blur(3px);
}

.dialog-shell {
  display: flex;
  max-height: calc(100vh - 28px);
  flex-direction: column;
}

.dialog-header,
.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 2px 0 0;
  font-size: 23px;
}

.dialog-footer {
  border-top: 1px solid var(--line);
}

.dialog-footer .primary-button {
  margin-left: 0;
}

.dialog-body {
  overflow-y: auto;
  padding: 20px 22px 22px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  margin: 16px 22px 0;
  border-radius: 6px;
  padding: 3px;
  background: #e8ebe7;
}

.segmented-control button {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.segmented-control button.active {
  background: white;
  box-shadow: 0 1px 4px rgba(26, 32, 28, 0.12);
  font-weight: 700;
}

.segmented-control.compact {
  width: fit-content;
  grid-template-columns: repeat(4, 62px);
  margin: 0;
}

.upload-field {
  display: block;
  margin-bottom: 18px;
  cursor: pointer;
}

.upload-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.upload-preview {
  display: grid;
  min-height: 150px;
  place-items: center;
  align-content: center;
  gap: 5px;
  overflow: hidden;
  border: 1px dashed #b9c0bb;
  border-radius: 6px;
  background-position: center;
  background-size: cover;
  color: var(--muted);
}

.upload-preview.has-image {
  min-height: 210px;
  border-style: solid;
}

.upload-preview.has-image > * {
  display: none;
}

.upload-preview .icon {
  width: 24px;
  height: 24px;
  margin-bottom: 5px;
}

.upload-preview strong {
  color: var(--ink);
  font-size: 14px;
}

.upload-preview small {
  font-size: 12px;
}

.form-photo-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin: -7px 0 18px;
}

.form-photo-card {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e1e4df;
}

.form-photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.form-photo-card.is-cover {
  box-shadow: 0 0 0 2px var(--green);
}

.photo-card-actions {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 4px;
}

.photo-card-action {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 5px;
  background: rgba(18, 22, 20, 0.72);
  color: white;
  cursor: pointer;
}

.photo-card-action .icon {
  width: 15px;
  height: 15px;
}

.cover-photo-label {
  position: absolute;
  right: 5px;
  bottom: 5px;
  left: 5px;
  overflow: hidden;
  border-radius: 4px;
  padding: 4px 6px;
  background: rgba(18, 22, 20, 0.76);
  color: white;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiet-danger-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  margin: -8px 0 18px;
  border: 0;
  padding: 0 4px;
  background: transparent;
  color: #a63d2c;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.compact-upload .upload-preview {
  min-height: 112px;
}

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

.field {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
}

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

.field > span,
.swatch-fieldset legend,
.size-fieldset legend {
  color: #4d5550;
  font-size: 12px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea,
.drawer-select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 9px 10px;
  background: white;
  color: var(--ink);
}

.field textarea {
  resize: vertical;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  cursor: pointer;
}

.loan-fields {
  margin-top: 18px;
  border: 1px solid #cad4cf;
  border-radius: 6px;
  padding: 16px;
  background: #f1f5f2;
}

.loan-fields-heading {
  display: flex;
  align-items: center;
  gap: 9px;
}

.loan-fields-heading > div {
  display: grid;
  gap: 2px;
}

.loan-fields-heading strong {
  font-size: 13px;
}

.loan-fields-heading small {
  color: var(--muted);
  font-size: 11px;
}

.loan-direction-control.segmented-control {
  width: 100%;
  margin: 14px 0;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--green);
}

.check-row span {
  display: grid;
  gap: 2px;
}

.check-row strong {
  font-size: 13px;
}

.check-row small {
  color: var(--muted);
}

.swatch-fieldset,
.size-fieldset {
  margin: 20px 0 0;
  border: 0;
  padding: 0;
}

.swatch-fieldset legend,
.size-fieldset legend {
  margin-bottom: 9px;
}

.swatches {
  display: flex;
  gap: 9px;
}

.swatches label {
  cursor: pointer;
}

.swatches input {
  position: absolute;
  opacity: 0;
}

.swatches span {
  display: block;
  width: 30px;
  height: 30px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px #c7cdc8;
}

.swatches input:checked + span {
  box-shadow: 0 0 0 2px var(--ink);
}

.item-drawer {
  position: fixed;
  z-index: 70;
  inset: 0;
  visibility: hidden;
  pointer-events: none;
}

.item-drawer.open {
  visibility: visible;
  pointer-events: auto;
}

.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(18, 22, 20, 0.42);
  opacity: 0;
  transition: opacity 180ms ease;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100vw);
  overflow-y: auto;
  background: white;
  box-shadow: -16px 0 40px rgba(29, 35, 31, 0.16);
  transform: translateX(100%);
  transition: transform 220ms ease;
}

.item-drawer.open .drawer-scrim { opacity: 1; }
.item-drawer.open .drawer-panel { transform: translateX(0); }

.drawer-header {
  position: sticky;
  z-index: 3;
  top: 0;
  display: flex;
  height: 58px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.drawer-edit-button {
  min-height: 38px;
}

.drawer-photo {
  aspect-ratio: 16 / 10;
  margin: 0 22px;
  overflow: hidden;
  border-radius: 6px;
  background: #e0e4df;
}

.drawer-photo .item-photo-image {
  width: 100%;
  height: 100%;
}

.drawer-photo-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 10px 22px 0;
  padding: 2px 1px 4px;
}

.drawer-photo-thumb {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 5px;
  padding: 0;
  background: #e1e4df;
  cursor: pointer;
}

.drawer-photo-thumb.active {
  border-color: var(--green);
}

.drawer-photo-thumb .item-photo-image {
  width: 100%;
  height: 100%;
}

.drawer-body {
  padding: 20px 22px 40px;
}

.drawer-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer-body h2 {
  margin: 0;
  font-size: 27px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.drawer-path {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.drawer-loan-card {
  margin-top: 18px;
  border-left: 3px solid var(--blue);
  padding: 12px 13px;
  background: #eef1f5;
}

.drawer-loan-main {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.drawer-loan-main > div {
  display: grid;
  gap: 3px;
}

.drawer-loan-main strong {
  font-size: 14px;
}

.drawer-loan-main small {
  color: #5c6674;
  font-size: 12px;
}

.drawer-loan-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.loan-connection {
  color: #58655f;
  font-size: 11px;
}

.compact-dialog {
  width: min(510px, calc(100vw - 28px));
}

.share-item-summary,
.incoming-loan-card {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: #f6f7f4;
}

.share-item-summary strong,
.incoming-loan-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
}

.share-item-summary span,
.incoming-loan-card span {
  color: var(--muted);
  font-size: 12px;
}

.share-link-field {
  margin-top: 16px;
}

.copy-field {
  display: flex;
  align-items: center;
  gap: 7px;
}

.copy-field input {
  min-width: 0;
  flex: 1;
}

.form-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.drawer-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.drawer-identified-name {
  margin: 7px 0 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.drawer-identified-name span {
  color: var(--muted);
  font-weight: 500;
}

.drawer-info-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.vision-search-lab {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.vision-search-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.vision-search-heading .eyebrow {
  margin: 0 0 3px;
}

.vision-search-heading h3 {
  margin: 0;
  font-size: 17px;
}

.vision-search-heading > span {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.vision-usage-track {
  overflow: hidden;
  height: 5px;
  margin-top: 13px;
  border-radius: 3px;
  background: #dfe4e1;
}

.vision-usage-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #c9513b;
  transition: width 180ms ease;
}

.vision-search-button {
  margin-top: 13px;
}

.vision-search-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.vision-search-button.is-loading .icon {
  animation: market-search-spin 900ms linear infinite;
}

.vision-error,
.vision-empty {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.vision-error {
  color: #944532;
}

.vision-result {
  margin-top: 16px;
}

.vision-result-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.vision-best-guess {
  margin: 0;
  font-size: 20px;
  font-weight: 760;
  overflow-wrap: anywhere;
}

.vision-best-guess.unresolved {
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}

.vision-specificity-warning {
  margin: 7px 0 0;
  color: #8a5a19;
  font-size: 12px;
  font-weight: 700;
}

.vision-recognized-text {
  margin: 8px 0 0;
  color: #4f5c56;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.vision-identification-proof {
  margin: 7px 0 0;
  color: #345b54;
  font-size: 12px;
  font-weight: 700;
}

.identification-sources {
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.vision-entities {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.vision-entities span {
  border: 1px solid #cbd5d0;
  border-radius: 4px;
  padding: 4px 7px;
  background: #f1f5f2;
  color: #38564d;
  font-size: 11px;
  font-weight: 700;
}

.vision-match-count {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.vision-pages {
  margin-top: 10px;
}

.vision-pages a {
  display: grid;
  gap: 3px;
  border-top: 1px solid var(--line);
  padding: 11px 0;
  color: inherit;
  text-decoration: none;
}

.vision-pages a:hover strong {
  color: var(--accent-dark);
}

.vision-pages strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.vision-pages small {
  color: var(--muted);
  font-size: 11px;
}

.market-search-lab {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.market-search-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.market-search-heading .eyebrow {
  margin: 0 0 3px;
}

.market-search-heading h3 {
  margin: 0;
  font-size: 17px;
}

.market-search-heading > span {
  color: var(--muted);
  font-size: 12px;
}

.valuation-context-controls {
  display: flex;
  gap: 7px;
  align-items: end;
}

.valuation-context-controls label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.valuation-context-controls select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 24px 5px 8px;
  background: white;
  color: var(--ink);
  font-size: 12px;
  text-transform: none;
}

.save-default-currency {
  display: block;
  margin: 6px 0 0 auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.market-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 13px;
}

.market-search-form input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 9px 10px;
  background: white;
  color: var(--ink);
}

.market-search-form button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.market-search-form button:disabled .icon {
  animation: market-search-spin 900ms linear infinite;
}

.market-query-warning {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 8px 0 0;
  color: #79541d;
  font-size: 11px;
  line-height: 1.4;
}

.market-query-warning .icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  margin-top: 1px;
}

@keyframes market-search-spin {
  to { transform: rotate(360deg); }
}

.market-source-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.market-source-status {
  border: 1px solid #cbd5d0;
  border-radius: 4px;
  padding: 3px 6px;
  background: #f1f5f2;
  color: #38564d;
  font-size: 11px;
  font-weight: 700;
}

.market-source-status.error {
  border-color: #e2c3bd;
  background: #fff2ef;
  color: #944532;
}

.market-source-status.warning {
  border-color: #d8cba9;
  background: #faf6e9;
  color: #745f2c;
}

.market-source-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.valuation-focus {
  margin-top: 17px;
  border-block: 1px solid var(--line);
  border-left: 3px solid var(--ink);
  padding: 15px 0 15px 14px;
}

.valuation-focus.is-personal {
  border-left-color: #2f6a4f;
}

.valuation-focus-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.valuation-focus-label > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.valuation-focus-label small,
.valuation-rate {
  color: var(--muted);
  font-size: 10px;
}

.valuation-focus > strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.valuation-focus.is-personal > strong {
  color: #2f6a4f;
}

.valuation-focus > p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.valuation-focus > p b {
  color: var(--ink);
}

.valuation-focus .valuation-fallback {
  color: #765c2b;
}

.valuation-rate {
  display: block;
  margin-top: 7px;
}

.price-priority-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin-top: 9px;
  border-radius: 5px;
  padding: 3px;
  background: #e7eae6;
}

.price-priority-control button {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.price-priority-control button.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(27, 34, 30, 0.1);
}

.price-priority-control button.active.personal {
  color: #2f6a4f;
}

.valuation-market-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

.valuation-market-heading > div {
  display: flex;
  gap: 7px;
  align-items: baseline;
}

.valuation-market-heading strong {
  font-size: 14px;
}

.valuation-market-heading span,
.valuation-market-heading small {
  color: var(--muted);
  font-size: 10px;
}

.condition-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
  border-block: 1px solid var(--line);
}

.condition-metric {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 13px 12px 13px 0;
}

.condition-metric + .condition-metric {
  border-left: 1px solid var(--line);
  padding-right: 0;
  padding-left: 12px;
}

.condition-metric > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.condition-metric > strong {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.condition-metric > small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.condition-metric em {
  display: flex;
  gap: 4px;
  align-items: center;
  color: #765c2b;
  font-size: 10px;
  font-style: normal;
}

.condition-metric em .icon {
  width: 12px;
  height: 12px;
}

.condition-metric.is-empty strong {
  color: var(--muted);
  font-size: 14px;
}

.personal-valuation {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: end;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.personal-valuation h4,
.personal-valuation p {
  margin: 0;
}

.personal-valuation h4 {
  color: #2f6a4f;
  font-size: 13px;
}

.personal-valuation p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.personal-valuation-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 42px;
  gap: 7px;
  align-items: end;
}

.personal-valuation-form label {
  display: grid;
  min-width: 0;
  gap: 3px;
  color: var(--muted);
  font-size: 9px;
}

.personal-valuation-form input,
.personal-valuation-form select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px;
  background: white;
  color: var(--ink);
}

.personal-valuation-form .icon-button {
  width: 42px;
  height: 42px;
}

.other-market-button {
  width: 100%;
  margin-top: 16px;
}

.valuation-details {
  border-top: 1px solid var(--line);
  margin-top: 17px;
  padding-top: 2px;
}

.valuation-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  list-style: none;
}

.valuation-details summary::-webkit-details-marker { display: none; }
.valuation-details summary::after { content: "+"; color: var(--muted); font-size: 18px; }
.valuation-details[open] summary::after { content: "−"; }
.valuation-details summary span { margin-left: auto; color: var(--muted); font-size: 10px; }

.other-market {
  padding-bottom: 14px;
}

.listing-group {
  padding: 6px 0 12px;
}

.listing-group h4,
.listing-group > p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.valuation-listing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
  color: inherit;
  text-decoration: none;
}

.valuation-listing > span,
.valuation-listing > b {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.valuation-listing strong {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.valuation-listing small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
  line-height: 1.35;
}

.valuation-listing > b {
  align-content: start;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.market-valuations {
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.market-valuation {
  border-bottom: 1px solid var(--line);
  padding: 17px 0 19px;
}

.market-valuation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.market-valuation-header strong {
  font-size: 14px;
}

.market-valuation-header span,
.market-valuation-median {
  color: var(--muted);
  font-size: 11px;
}

.market-valuation-range {
  margin: 10px 0 2px;
  font-size: 27px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.market-valuation-median {
  margin: 0;
}

.market-condition-ranges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
}

.market-condition-ranges strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.manual-prices {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.manual-prices h4 {
  margin: 0 0 9px;
  font-size: 13px;
}

.manual-prices-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 72px 42px;
  gap: 8px;
  align-items: end;
}

.manual-prices-form label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 10px;
}

.manual-prices-form input,
.manual-prices-form select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.manual-prices-form .icon-button {
  width: 42px;
  height: 42px;
}

.valuation-links {
  margin-top: 15px;
}

.valuation-links h4,
.market-results h4 {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.valuation-links a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  border-top: 1px solid var(--line);
  padding: 11px 0;
  color: inherit;
  text-decoration: none;
}

.valuation-links a:hover strong {
  color: var(--accent-dark);
}

.valuation-links strong {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.valuation-links span {
  font-size: 13px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.valuation-links small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}

.market-results {
  margin-top: 18px;
}

.market-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
  border-top: 1px solid var(--line);
  padding: 13px 0;
  color: inherit;
  text-decoration: none;
}

.market-result-source {
  grid-column: 1 / -1;
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.market-result strong {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-result:hover strong {
  color: var(--accent-dark);
}

.market-result p {
  display: -webkit-box;
  grid-column: 1 / -1;
  overflow: hidden;
  margin: 0;
  color: #58605c;
  font-size: 12px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.market-result small {
  color: var(--muted);
  font-size: 11px;
}

.market-result b {
  grid-column: 2;
  grid-row: 2;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.market-search-error,
.market-search-empty {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.market-search-error {
  color: #944532;
}

.drawer-notes {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.drawer-notes h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.drawer-notes p {
  margin: 0;
  color: #4f5752;
  font-size: 13px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  z-index: 100;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 32px));
  border-radius: 6px;
  padding: 11px 14px;
  background: #202421;
  color: white;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.mobile-nav,
.mobile-only,
.sidebar-scrim {
  display: none;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1120px) {
  .place-card.size-small { grid-column: span 4; }
  .place-card.size-medium { grid-column: span 6; }
  .place-card.size-large { grid-column: span 12; }
  .item-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app-shell { display: block; }

  .sidebar {
    width: min(300px, 86vw);
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-scrim {
    position: fixed;
    z-index: 35;
    inset: 0;
    background: rgba(20, 25, 22, 0.42);
  }

  .sidebar-scrim.open { display: block; }

  .main-content { grid-column: auto; }
  .mobile-only { display: inline-flex; }
  .topbar { padding-inline: 18px; }
  .content-wrap { padding-inline: 18px; }
  .search-box { width: auto; flex: 1; }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  body { padding-bottom: 66px; }

  .topbar {
    height: 62px;
    gap: 8px;
    padding: 9px 12px;
  }

  .topbar .primary-button {
    width: 42px;
    flex: 0 0 42px;
    padding: 0;
  }

  .topbar .primary-button span,
  .search-box kbd {
    display: none;
  }

  .search-box { height: 42px; }
  .content-wrap { padding: 17px 12px 30px; }
  .page-heading {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0 20px;
  }
  .heading-actions { display: flex; }
  .heading-actions .secondary-button { flex: 1; }
  .page-heading h1 { font-size: 27px; }
  .page-subtitle { font-size: 13px; }

  .place-grid {
    grid-auto-rows: 62px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .place-card.size-small { grid-column: span 1; grid-row: span 2; }
  .place-card.size-medium { grid-column: span 2; grid-row: span 3; }
  .place-card.size-large { grid-column: span 2; grid-row: span 4; }
  .place-card h3 { max-width: 72%; }
  .place-card.size-small h3 { max-width: 100%; font-size: 15px; }
  .place-card-actions { opacity: 1; }

  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .item-card-body { min-height: 104px; padding: 10px 11px 12px; }
  .item-card h3 { font-size: 14px; }
  .item-price { margin-top: 10px; font-size: 13px; }
  .item-path { font-size: 11px; }

  .mobile-nav {
    position: fixed;
    z-index: 45;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    height: 66px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border-top: 1px solid var(--line);
    padding: 4px 7px env(safe-area-inset-bottom);
    background: rgba(250, 251, 249, 0.96);
    backdrop-filter: blur(14px);
  }

  .mobile-nav button {
    display: grid;
    min-width: 0;
    place-items: center;
    align-content: center;
    gap: 2px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
  }

  .mobile-nav button.active { color: var(--ink); font-weight: 700; }
  .mobile-nav .icon { width: 20px; height: 20px; }

  .field-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .form-photo-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dialog-header, .dialog-footer { padding-inline: 16px; }
  .dialog-body { padding-inline: 16px; }
  .segmented-control { margin-inline: 16px; }
  .segmented-control.compact { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; }
  .dialog-footer .secondary-button { min-width: 92px; }
  .drawer-info-grid { grid-template-columns: 1fr; }
  .drawer-photo { margin-inline: 14px; }
  .drawer-photo-strip { margin-inline: 14px; }
  .drawer-body { padding-inline: 16px; }
  .market-search-heading {
    position: sticky;
    z-index: 3;
    top: 0;
    align-items: center;
    margin-inline: -16px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
  }
  .valuation-context-controls { gap: 5px; }
  .valuation-context-controls select { max-width: 92px; min-height: 32px; }
  .market-search-form { grid-template-columns: 1fr; }
  .market-search-form .secondary-button { width: 100%; }
  .market-valuation-range { font-size: 24px; }
  .personal-valuation { grid-template-columns: 1fr; }
  .valuation-focus > strong { font-size: 27px; }
  .toast { right: 16px; bottom: 82px; }
}

@media (max-width: 390px) {
  .item-grid { grid-template-columns: 1fr; }
  .item-photo { aspect-ratio: 16 / 8; }
  .condition-metrics { grid-template-columns: 1fr; }
  .condition-metric + .condition-metric { border-top: 1px solid var(--line); border-left: 0; padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
