:root {
  --bg: #f4efe7;
  --bg-strong: #eadfce;
  --panel: rgba(255, 252, 247, 0.92);
  --panel-strong: #fff8ef;
  --line: rgba(86, 63, 36, 0.14);
  --ink: #2b2117;
  --muted: #6e6255;
  --accent: #91643b;
  --accent-strong: #6e4521;
  --olive: #55624b;
  --ok-bg: #eef6ee;
  --ok-ink: #355b35;
  --warn-bg: #fff3de;
  --warn-ink: #8c5d19;
  --err-bg: #fff0ee;
  --err-ink: #943a2d;
  --shadow: 0 18px 50px rgba(56, 40, 20, 0.08);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 35%),
    radial-gradient(circle at 100% 10%, rgba(145, 100, 59, 0.18), transparent 28%),
    linear-gradient(180deg, #f8f4ee 0%, var(--bg) 52%, #efe5d8 100%);
  font: 13px/1.42 "Avenir Next", "Helvetica Neue", "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
h1, h2, h3, p { margin: 0; }

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

.auth-shell {
  width: min(470px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.auth-shell-wide {
  width: min(820px, calc(100vw - 32px));
}

.eyebrow,
.panel-kicker {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.auth-shell h1,
.topbar h1,
.panel-card h2,
.analysis-copy h3 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

.auth-shell h1 { margin-top: 8px; font-size: 31px; }
.auth-shell p { margin-top: 12px; color: var(--muted); }

.auth-form,
.stack-form,
.inventory-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(92, 68, 40, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(145, 100, 59, 0.52);
  box-shadow: 0 0 0 4px rgba(145, 100, 59, 0.12);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #fff;
}

.secondary-btn {
  background: rgba(145, 100, 59, 0.12);
  color: var(--accent-strong);
}

.ghost-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger-btn {
  background: rgba(148, 58, 45, 0.12);
  color: var(--err-ink);
  border: 1px solid rgba(148, 58, 45, 0.2);
}

.text-link {
  color: var(--accent-strong);
  font-weight: 700;
}

.error-banner,
.ok-banner,
.warning-banner {
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 14px;
}

.error-banner { background: var(--err-bg); color: var(--err-ink); border: 1px solid rgba(148, 58, 45, 0.16); }
.ok-banner { background: var(--ok-bg); color: var(--ok-ink); border: 1px solid rgba(53, 91, 53, 0.16); }
.warning-banner { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid rgba(140, 93, 25, 0.16); }

.totp-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 18px;
  margin-top: 18px;
}

.qr-card { text-align: center; }
.qr-card img {
  width: 190px;
  height: 190px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px;
  border-radius: 18px;
}

.mono {
  font: 600 13px/1.45 Consolas, monospace;
  word-break: break-all;
  margin-top: 10px;
}

.page-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 20px 0 30px;
  display: grid;
  gap: 14px;
  transition: opacity 180ms ease, filter 180ms ease;
}

[data-section] {
  scroll-margin-top: 36px;
}

.page-shell.is-nav-transition {
  opacity: 0.42;
  filter: saturate(0.92);
}

.section-focus {
  animation: section-fade-in 0.32s ease;
}

@keyframes section-fade-in {
  0% {
    opacity: 0.55;
    transform: translateY(4px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.topbar h1 {
  margin-top: 6px;
  font-size: clamp(26px, 3.5vw, 43px);
  line-height: 0.96;
}

.topbar p {
  margin-top: 10px;
  max-width: 700px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-pill {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--accent-strong);
  font-weight: 700;
}

.mobile-dock {
  display: none;
}

.metrics-grid,
.app-grid,
.list-grid {
  display: grid;
  gap: 12px;
}

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

.app-grid {
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
}

.list-grid {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.metric-card,
.panel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.metric-card {
  padding: 14px;
  min-height: 108px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(22px, 2.5vw, 30px);
  line-height: 1.05;
}

.metric-detail {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.panel-card { padding: 16px; }
.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.panel-header-tight {
  margin-bottom: 10px;
}

.panel-copy { color: var(--muted); margin-bottom: 18px; }

.camera-shell {
  display: grid;
  gap: 12px;
}

.camera-stage {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  min-height: 240px;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.22), transparent 42%),
    linear-gradient(180deg, #443323 0%, #24170f 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.camera-stage video,
.camera-stage img {
  display: none;
  width: 100%;
  min-height: 240px;
  max-height: 48vh;
  object-fit: cover;
}

.camera-overlay {
  position: absolute;
  inset: auto 16px 16px 16px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(21, 14, 9, 0.56);
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.03em;
}

.camera-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

[data-camera-mode="live"] .camera-stage video,
[data-camera-mode="captured"] .camera-stage img {
  display: block;
}

[data-camera-mode="live"] [data-camera-shot] {
  opacity: 1;
}

[data-camera-mode="idle"] [data-camera-shot],
[data-camera-mode="fallback"] [data-camera-shot],
[data-camera-mode="idle"] [data-camera-retake] {
  opacity: 0.45;
}

.analysis-hero {
  display: grid;
  grid-template-columns: 184px 1fr;
  gap: 14px;
  align-items: start;
}

.analysis-hero img,
.mini-item img,
.inventory-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
}

.analysis-copy h3 {
  font-size: 23px;
  line-height: 1.04;
}

.meta-line {
  color: var(--muted);
  font-size: 12px;
}

.analysis-copy .meta-line { margin-top: 8px; }

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

.analysis-hint {
  margin-bottom: 0;
}

.analysis-subnav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.analysis-subnav-link,
.mobile-dock-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 999px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.analysis-subnav-link.is-active,
.mobile-dock-link.is-active {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #fff;
  border-color: transparent;
}

.price-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.price-strip > div {
  padding: 10px;
  border-radius: 15px;
  background: rgba(145, 100, 59, 0.08);
}

.price-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.price-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 17px;
}

.market-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.market-card {
  padding: 10px;
  border-radius: 15px;
  background: rgba(85, 98, 75, 0.08);
  border: 1px solid rgba(85, 98, 75, 0.12);
}

.market-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.market-card strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.source-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.source-pill,
.offer-rank {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(43, 33, 23, 0.08);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.analysis-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.inventory-lock-card {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.56);
}

.inventory-lock-link {
  justify-self: start;
}

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

.offer-list,
.inventory-list,
.mini-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.inventory-room-list,
.inventory-category-list {
  display: grid;
  gap: 12px;
}

.offer-item,
.inventory-item,
.mini-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.offer-item {
  grid-template-columns: 88px 1fr auto;
  align-items: start;
}

.offer-item-secondary {
  background: rgba(255, 255, 255, 0.52);
}

.offer-media {
  width: 88px;
}

.offer-media img,
.offer-media-placeholder {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.offer-media-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.offer-item p,
.inventory-item p {
  margin-top: 6px;
  color: var(--muted);
}

.offer-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.offer-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.offer-badge-score {
  background: rgba(145, 100, 59, 0.12);
  color: var(--accent-strong);
}

.offer-badge-ok {
  background: rgba(53, 91, 53, 0.14);
  color: #355b35;
}

.offer-badge-warn {
  background: rgba(140, 93, 25, 0.14);
  color: #8c5d19;
}

.offer-badge-muted {
  background: rgba(110, 98, 85, 0.12);
  color: var(--muted);
}

.offer-side {
  display: grid;
  gap: 6px;
  justify-items: end;
  min-width: 96px;
}

.offer-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-strong);
  text-align: right;
}

.offer-rationale {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.offer-source-icon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  margin-right: 4px;
  object-fit: contain;
}

.other-offers-header {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.offer-list-secondary .offer-item {
  border-style: dashed;
}

.mini-item {
  grid-template-columns: 76px 1fr;
  align-items: center;
}

.history-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 999px;
}

.history-badge-sesame {
  border: 1px solid rgba(85, 98, 75, 0.16);
  background-color: rgba(85, 98, 75, 0.08);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='%2355624b' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.35'%3E%3Cpath d='M8.4 18.2c-2.1-1.5-3.8-4.1-4.2-7.1'/%3E%3Cpath d='M7.5 15.8c-1.5-.9-2.8-2.4-3.4-4.2'/%3E%3Cpath d='M6.9 13.2c-1-.5-1.9-1.3-2.4-2.3'/%3E%3Cpath d='M15.6 18.2c2.1-1.5 3.8-4.1 4.2-7.1'/%3E%3Cpath d='M16.5 15.8c1.5-.9 2.8-2.4 3.4-4.2'/%3E%3Cpath d='M17.1 13.2c1-.5 1.9-1.3 2.4-2.3'/%3E%3C/g%3E%3Ccircle cx='12' cy='11.9' r='1.7' fill='%2355624b' fill-opacity='.92'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 17px 17px;
}

.swipe-item {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
}

.swipe-action-shell {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  pointer-events: none;
}

.swipe-action-shell form {
  height: 100%;
}

.swipe-delete-btn {
  height: 100%;
  min-width: 92px;
  border: 1px solid rgba(148, 58, 45, 0.16);
  border-radius: 22px;
  background: rgba(148, 58, 45, 0.08);
  color: var(--err-ink);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  pointer-events: auto;
  cursor: pointer;
}

.inline-purge-form {
  margin: 0;
}

.subtle-danger-btn {
  border: 0;
  background: transparent;
  color: rgba(148, 58, 45, 0.78);
  font-size: 13px;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(148, 58, 45, 0.32);
  text-underline-offset: 3px;
}

.subtle-danger-btn:hover {
  color: var(--err-ink);
  text-decoration-color: rgba(148, 58, 45, 0.55);
}

.swipe-surface {
  position: relative;
  z-index: 1;
  transition: transform 180ms ease;
  will-change: transform;
}

.mini-item.active {
  border-color: rgba(145, 100, 59, 0.32);
  background: rgba(255, 248, 239, 0.95);
}

.inventory-item {
  grid-template-columns: 76px 1fr;
  align-items: center;
}

.inventory-panel-stats,
.inventory-room-stats {
  display: grid;
  gap: 2px;
  justify-items: end;
  text-align: right;
}

.inventory-panel-stats span,
.inventory-room-stats span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.inventory-panel-stats strong,
.inventory-room-stats strong {
  font-size: 16px;
  color: var(--accent-strong);
}

.inventory-room-card,
.inventory-category-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.56);
  padding: 12px;
}

.inventory-room-header,
.inventory-category-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.inventory-room-header h3 {
  font-size: 18px;
  line-height: 1.04;
}

.inventory-category-header strong {
  font-size: 14px;
}

.inventory-category-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-strong);
}

.muted { color: var(--muted); }

@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-grid,
  .list-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .page-shell {
    width: calc(100vw - 20px);
    padding-top: 14px;
    padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px));
    gap: 14px;
  }

  [data-section] {
    scroll-margin-top: 104px;
  }

  .topbar {
    grid-template-columns: 1fr;
    display: grid;
    align-items: start;
  }

  .topbar-actions {
    justify-content: start;
  }

  .topbar p {
    max-width: none;
  }

  .mobile-dock {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(86, 63, 36, 0.18);
    border-radius: 24px;
    background: rgba(255, 248, 239, 0.92);
    backdrop-filter: blur(14px);
    box-shadow: 0 18px 45px rgba(56, 40, 20, 0.16);
  }

  .mobile-dock-link {
    min-height: 52px;
    padding: 8px 6px;
    border-radius: 18px;
    font-size: 11px;
    line-height: 1.1;
    text-align: center;
  }

  .analysis-subnav {
    position: sticky;
    top: 12px;
    z-index: 10;
    margin: -2px 0 12px;
    padding: 8px;
    border-radius: 18px;
    background: rgba(255, 248, 239, 0.88);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(86, 63, 36, 0.14);
  }

  .analysis-subnav-link {
    flex: 1 1 calc(33.333% - 8px);
    min-width: 92px;
    min-height: 44px;
    padding: 10px 8px;
    font-size: 12px;
  }

  .analysis-inline-actions {
    align-items: start;
    flex-direction: column;
  }

  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .metric-card {
    min-height: 96px;
    padding: 12px;
  }
  .analysis-hero { grid-template-columns: 1fr; }
  .price-strip { grid-template-columns: 1fr 1fr; }
  .market-strip { grid-template-columns: 1fr; }
  .offer-item { grid-template-columns: 88px 1fr; }
  .inventory-room-header,
  .inventory-category-header {
    flex-direction: column;
    align-items: start;
  }
  .inventory-panel-stats,
  .inventory-room-stats {
    justify-items: start;
    text-align: left;
  }
  .offer-side { justify-items: start; }
  .offer-price { text-align: left; }
  .offer-rationale { text-align: left; }
  .offer-media,
  .offer-media img,
  .offer-media-placeholder {
    width: 88px;
    height: 88px;
  }
  .totp-grid { grid-template-columns: 1fr; }
  .camera-stage {
    min-height: 360px;
  }
  .camera-stage video,
  .camera-stage img {
    min-height: 360px;
  }
  .camera-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .auth-shell { padding: 24px; border-radius: 24px; }
  .metric-card strong { font-size: 28px; }
}
