:root {
  color-scheme: dark;
  --bg: #101010;
  --panel: #181818;
  --panel-2: #202020;
  --line: #303030;
  --text: #f7f2ea;
  --muted: #a9a198;
  --gold: #d9b56f;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --ink: #111111;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

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

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px 88px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 0 12px;
  background: rgba(16, 16, 16, 0.94);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.05;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 24px;
}

.summary-band {
  position: sticky;
  top: 76px;
  z-index: 4;
  display: grid;
  grid-template-columns: 1.45fr 0.8fr 0.8fr;
  gap: 8px;
  padding: 8px 0 12px;
  background: rgba(16, 16, 16, 0.94);
  backdrop-filter: blur(14px);
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #222 0%, #171717 100%);
  padding: 10px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

.metric strong {
  display: block;
  font-size: clamp(15px, 5vw, 22px);
  line-height: 1.1;
  white-space: nowrap;
}

.controls {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.search-box,
.detail-grid label,
.memo-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.search-box input,
.detail-grid input,
.detail-grid select,
.memo-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151515;
  color: var(--text);
  padding: 12px;
  outline: none;
}

.search-box input:focus,
.detail-grid input:focus,
.detail-grid select:focus,
.memo-field textarea:focus {
  border-color: var(--gold);
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  padding: 0 13px;
  font-size: 13px;
  font-weight: 700;
}

.chip.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

.compact .chip {
  min-height: 32px;
  font-size: 12px;
}

.utility-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.ghost-button,
.primary-button,
.accent-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 14px;
  color: var(--text);
  background: var(--panel-2);
  text-decoration: none;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
}

.primary-button {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
}

.accent-button {
  background: #f3f4f6;
  color: #111827;
}

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

.product-card {
  display: grid;
  grid-template-columns: 76px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
}

.thumb,
.detail-media {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(217, 181, 111, 0.2), transparent 52%),
    #242424;
  color: var(--gold);
  font-weight: 900;
}

.thumb {
  width: 76px;
  aspect-ratio: 1;
}

.thumb img,
.detail-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-main {
  min-width: 0;
}

.card-title {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.25;
}

.card-subtitle,
.card-spec {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.badge {
  border-radius: 999px;
  padding: 4px 8px;
  background: #292929;
  color: #ded8cf;
  font-size: 11px;
  font-weight: 850;
}

.badge.high {
  color: #052e16;
  background: #86efac;
}

.badge.loss {
  color: #450a0a;
  background: #fca5a5;
}

.badge.normal {
  color: #422006;
  background: #fde68a;
}

.card-side {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.profit {
  font-weight: 900;
  white-space: nowrap;
  font-size: 14px;
}

.quick-button {
  min-width: 46px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f2ea;
  color: var(--ink);
  font-weight: 950;
}

.quick-button.done {
  background: var(--green);
  color: #052e16;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 28px 16px;
  text-align: center;
}

.detail-dialog {
  width: min(100% - 18px, 720px);
  max-height: min(92dvh, 880px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
}

.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.detail-sheet {
  display: grid;
  gap: 14px;
  padding: 14px;
}

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

.detail-header h2 {
  font-size: 22px;
  line-height: 1.15;
}

.detail-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  font-size: 32px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.profit-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151515;
  padding: 10px;
}

.profit-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.profit-panel strong {
  font-size: 19px;
}

.profit-panel p {
  grid-column: 1 / -1;
  color: var(--gold);
  font-weight: 850;
}

.link-row,
.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 20;
  transform: translateX(-50%) translateY(24px);
  opacity: 0;
  min-width: min(92vw, 360px);
  border-radius: 8px;
  background: #f7f2ea;
  color: var(--ink);
  padding: 13px 16px;
  text-align: center;
  font-weight: 850;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 430px) {
  .app-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .product-card {
    grid-template-columns: 66px 1fr auto;
    gap: 10px;
  }

  .thumb {
    width: 66px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
