:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #1b1d23;
  --ink-soft: #6b7280;
  --border: #e5e7eb;
  --accent: #b8862f;
  --accent-ink: #1b1d23;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 18, 24, 0.06), 0 8px 24px rgba(16, 18, 24, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: #14161c;
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #e0b567);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #14161c;
}
.brand h1 { font-size: 16px; margin: 0; letter-spacing: 0.04em; }
.brand p { font-size: 11px; margin: 0; color: #9aa0ab; }

.search-wrap { flex: 1; max-width: 480px; margin-left: auto; }
.search-wrap input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid #2a2d36;
  background: #1e2027;
  color: #fff;
  font-size: 14px;
}
.search-wrap input::placeholder { color: #6b7280; }
.search-wrap input:focus { outline: 2px solid var(--accent); }

.icon-btn {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 18px;
  cursor: pointer;
  width: 36px; height: 36px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); }
.icon-btn.danger { color: var(--danger); }

.import-status {
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: #fff8ec;
  border: 1px solid #f0dcae;
  color: #6b5116;
  font-size: 13.5px;
}
.import-status.error { background: #fdecea; border-color: #f3c1ba; color: #8a2c22; }
.import-status.ok { background: #eafaf0; border-color: #b9e6c8; color: #1e6b3d; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

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

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: flex;
  flex-direction: column;
}
.card:hover { transform: translateY(-2px); }

.card-img {
  aspect-ratio: 1 / 1;
  background: #eef0f3;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-img .placeholder { color: #b7bcc4; font-size: 12px; }

.card-body { padding: 12px 14px; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-ref { font-weight: 700; font-size: 13px; letter-spacing: 0.02em; }
.card-price {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.card-name { color: var(--ink-soft); font-size: 12.5px; margin-top: 4px; line-height: 1.3; }

.fab {
  position: fixed;
  right: 28px; bottom: 28px;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(184, 134, 47, 0.45);
}
.fab:hover { filter: brightness(1.05); }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-soft);
}
.empty-state p { margin-bottom: 16px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.btn-primary.small { padding: 7px 14px; font-size: 13px; }
.btn-primary:hover { filter: brightness(1.05); }

dialog.sheet {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(560px, 92vw);
  max-height: 88vh;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
dialog.sheet.small { width: min(420px, 92vw); }
dialog.sheet::backdrop { background: rgba(15, 17, 22, 0.55); }

.sheet-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface);
  z-index: 1;
}
.sheet-header h2 { font-size: 16px; margin: 0; flex: 1; }
.sheet-actions { margin-left: auto; display: flex; gap: 4px; }

.sheet-body { padding: 18px 20px 28px; overflow-y: auto; max-height: calc(88vh - 56px); }

.detail-img {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 10px;
  overflow: hidden;
  background: #eef0f3;
  margin-bottom: 16px;
  display: flex; align-items: center; justify-content: center;
}
.detail-img img { width: 100%; height: 100%; object-fit: cover; }

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.detail-row span:first-child { color: var(--ink-soft); font-size: 13px; }
.detail-row span:last-child { font-weight: 600; text-align: right; }
.detail-row.price span:last-child { color: var(--accent); }
.detail-row.price.highlight { background: #fff8ec; margin: 0 -20px; padding: 10px 20px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  min-width: 0;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; grid-column: span 1; min-width: 0; }
.field span { color: var(--ink-soft); font-weight: 600; }
.field.wide, .image-field, .fieldset-dims, .field.readonly.wide { grid-column: 1 / -1; }
.field input, .field select {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  width: 100%;
  min-width: 0;
}
.field.readonly output {
  padding: 9px 10px;
  background: #f6f7f9;
  border-radius: 8px;
  font-weight: 600;
  display: block;
  width: 100%;
  min-width: 0;
}
.fieldset-dims { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 0; }
.fieldset-dims legend { color: var(--ink-soft); font-size: 12px; padding: 0 4px; }
.dims-row { display: flex; gap: 8px; min-width: 0; }
.dims-row input { flex: 1; min-width: 0; }

.image-preview {
  width: 120px; height: 120px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
}

.calc-preview {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 6px;
}
.calc-preview div {
  background: #f6f7f9;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
}
.calc-preview b { display: block; font-size: 14px; margin-top: 2px; }
