* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f3f4f6; color: #111827; }
header { background: #111827; color: white; padding: 22px; }
header h1 { margin: 0; font-size: 28px; }
header p { margin: 5px 0 0; opacity: .75; }
main { max-width: 1300px; margin: auto; padding: 20px; }
.panel { background: white; border-radius: 14px; padding: 20px; margin-bottom: 18px; }
.search-panel h2 { margin-top: 0; }
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid #d1d5db; border-radius: 9px; background: white; }
textarea { resize: vertical; }
button { cursor: pointer; }
.primary { border: none; background: #111827; color: white; padding: 11px 16px; border-radius: 9px; font-weight: 600; }
.link-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; white-space: nowrap; }
.secondary { border: 1px solid #d1d5db; background: white; color: #111827; padding: 10px 14px; border-radius: 9px; font-weight: 600; }
.big { width: 100%; padding: 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.compact-title h3 { margin-bottom: 8px; }
.parts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 18px; }
.part-card { border: 1px solid #e5e7eb; border-radius: 13px; overflow: hidden; background: white; cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.part-card:hover, .part-card:focus { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(17,24,39,.09); outline: none; }
.part-image { height: 190px; background: #f9fafb; position: relative; }
.part-image img { width: 100%; height: 100%; object-fit: contain; }
.no-image { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 55px; opacity: .2; }
.image-count { position: absolute; right: 9px; bottom: 9px; background: rgba(17,24,39,.85); color: white; border-radius: 18px; padding: 5px 9px; font-size: 12px; }
.part-info { padding: 14px; }
.part-info h3 { margin: 8px 0; }
.part-code { font-size: 18px; font-weight: 700; }
.card-action { margin-top: 12px; font-size: 13px; font-weight: 600; color: #374151; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badges span { background: #e5e7eb; border-radius: 20px; padding: 4px 8px; font-size: 12px; }
.muted { color: #6b7280; font-size: 14px; margin-top: 5px; }
.empty { padding: 50px; text-align: center; color: #6b7280; }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 30px 15px; }
.hidden { display: none !important; }
.modal-card { width: min(700px, 100%); background: white; border-radius: 15px; padding: 22px; }
.detail-card { width: min(1180px, 100%); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin-bottom: 10px; }
.modal-header h2 { margin: 0; }
.icon-button { border: none; background: transparent; font-size: 22px; padding: 4px 8px; }
form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 600; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
#formMessage, .message { text-align: center; min-height: 24px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 28px; }
.image-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.gallery-item { position: relative; min-height: 180px; border: 1px solid #e5e7eb; border-radius: 12px; overflow: hidden; background: #f9fafb; }
.gallery-item img { width: 100%; height: 100%; max-height: 320px; object-fit: contain; display: block; }
.delete-image { position: absolute; top: 8px; right: 8px; border: none; border-radius: 8px; padding: 7px 9px; background: rgba(255,255,255,.92); box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.gallery-empty { border: 1px dashed #d1d5db; border-radius: 12px; padding: 50px 15px; text-align: center; color: #6b7280; grid-column: 1 / -1; }
.image-upload-box { margin-top: 14px; padding: 14px; border: 1px solid #e5e7eb; border-radius: 12px; background: #f9fafb; }
@media (max-width: 900px) { .detail-layout { grid-template-columns: 1fr; } }
@media (max-width: 700px) {
  .filters, .two-cols, .three-cols { grid-template-columns: 1fr; }
  .section-title { align-items: stretch; flex-direction: column; }
  .parts-grid { grid-template-columns: 1fr 1fr; }
  .modal { padding: 12px; }
  .modal-card { padding: 16px; }
}
@media (max-width: 520px) { .parts-grid, .image-gallery { grid-template-columns: 1fr; } }
