* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f5f7;
  color: #1c1e21;
  line-height: 1.45;
}
.wrap { max-width: 960px; margin: 0 auto; padding: 0 14px; }
/* main.wrap scoped so the header (which shares .wrap) isn't pushed down */
main.wrap { margin-top: 14px; }
header { background: #1a1d29; color: #fff; }
.header-inner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; flex-wrap: nowrap; }
.logo { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; white-space: nowrap; }
nav { display: flex; gap: 12px; align-items: center; flex-wrap: nowrap; }
nav a { color: #cfd3e0; text-decoration: none; white-space: nowrap; }
nav .btn { white-space: nowrap; flex-shrink: 0; }
@media (max-width: 520px) {
  .header-inner { gap: 8px; padding: 10px 10px; }
  .logo { font-size: 1rem; }
  nav { gap: 7px; }
  nav a { font-size: .9rem; }
  nav .btn { padding: 7px 10px; font-size: .85rem; }
}
main { padding: 18px 0 60px; }
h1 { font-size: 1.35rem; margin: 0 0 14px; }

.btn {
  display: inline-block;
  background: #e9ebf0; color: #1c1e21;
  border: none; border-radius: 8px;
  padding: 8px 14px; font-size: .95rem; cursor: pointer; text-decoration: none;
}
.btn-add { background: #2f6f4f; color: #fff; }
.btn-primary { background: #2f6f4f; color: #fff; }
.btn-danger { background: #b3352e; color: #fff; }

.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.flash-ok { background: #dff0e4; color: #1d5c37; }
.flash-error { background: #fbe4e2; color: #8f241d; }

/* stats */
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.stat {
  background: #fff; border-radius: 10px; padding: 10px 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  display: flex; flex-direction: column; min-width: 90px;
}
.stat-num { font-size: 1.25rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: #6b7280; }
.stat-wide { flex-direction: row; align-items: center; gap: 6px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.filters input[type=search] { flex: 1 1 180px; }
.filters input, .filters select {
  padding: 8px 10px; border: 1px solid #d4d7dd; border-radius: 8px; font-size: .95rem; background: #fff;
}

/* card grid */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card-tile {
  background: #fff; border-radius: 10px; overflow: hidden; text-decoration: none; color: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); transition: transform .08s ease;
}
.card-tile:active { transform: scale(.98); }
.thumb { aspect-ratio: 3/4; background: #e8eaef; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-empty { font-size: 2rem; opacity: .5; }
.tile-body { padding: 8px 10px; }
.tile-name { font-weight: 600; font-size: .95rem; }
.tile-meta { font-size: .78rem; color: #6b7280; margin-top: 2px; }

/* form */
.card-form { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.form-row label { flex: 1 1 160px; display: flex; flex-direction: column; font-size: .85rem; color: #4b5563; gap: 4px; }
.form-row input, .form-row select {
  padding: 8px 10px; border: 1px solid #d4d7dd; border-radius: 8px; font-size: .95rem; background: #fff;
}
.form-row input[type=file] { padding: 6px; border: 1px dashed #c9cdd4; }
.form-row input[type=checkbox] { width: 16px; height: 16px; padding: 0; border: none; background: none; }
.form-row label.checkbox-label { flex-direction: row; align-items: center; gap: 6px; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }
.hint { font-size: .75rem; color: #9aa1ab; }

/* detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.detail-meta { color: #4b5563; margin-top: 2px; }
.detail-actions { display: flex; gap: 8px; align-items: center; }
.detail-actions form { margin: 0; }
.photos { display: flex; flex-wrap: wrap; gap: 14px; margin: 18px 0; }
.photos figure { margin: 0; max-width: 280px; }
.photos img { width: 100%; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.photos figcaption { font-size: .8rem; color: #6b7280; margin-top: 4px; text-align: center; }
.kv { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.kv th, .kv td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #eef0f3; font-size: .92rem; }
.kv th { width: 160px; color: #6b7280; font-weight: 500; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: none; }

.muted { color: #6b7280; }
.small { font-size: .8rem; }
.empty { color: #6b7280; padding: 18px 0; }
.toolbar { display: flex; justify-content: flex-end; margin: 0 0 14px; }
.price-history h2 { font-size: 1.05rem; margin: 22px 0 10px; }
.price-history table { margin-top: 8px; }
