* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f4f5f7;
  color: #1f2430;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: #1f2937;
  color: white;
}

.topbar h1 {
  font-size: 1.25rem;
  margin: 0;
}

.btn {
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid #d0d3d9;
  background: white;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn:hover {
  background: #f0f1f3;
}

.btn-primary {
  background: #2f6fed;
  border-color: #2f6fed;
  color: white;
}

.btn-primary:hover {
  background: #255ac9;
}

.btn-danger {
  color: #c62828;
  border-color: #f1b3b3;
}

.btn-danger:hover {
  background: #fdecec;
}

.toolbar {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #d0d3d9;
  font-size: 0.95rem;
}

#buscador {
  flex: 1;
  min-width: 220px;
}

.galeria {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  padding: 0 1.5rem 2rem;
}

.tarjeta {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.tarjeta .foto-wrap {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #e9eaed;
  cursor: zoom-in;
  overflow: hidden;
}

.tarjeta .foto-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tarjeta .info {
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.tarjeta .categoria {
  display: inline-block;
  align-self: flex-start;
  background: #e8effe;
  color: #2f6fed;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.tarjeta .nombre {
  font-weight: 600;
  font-size: 1rem;
  margin: 0.15rem 0;
}

.tarjeta .fecha {
  font-size: 0.8rem;
  color: #6b7280;
}

.tarjeta .acciones {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.tarjeta .acciones .btn {
  flex: 1;
  padding: 0.4rem;
  font-size: 0.85rem;
}

.vacio {
  text-align: center;
  color: #6b7280;
  padding: 3rem 1rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.overlay[hidden] {
  display: none;
}

.modal {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-small {
  max-width: 320px;
}

.modal h2 {
  margin-top: 0;
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.modal label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.modal input[type="text"],
.modal input[type="search"],
.modal input:not([type="file"]):not([type="hidden"]) {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #d0d3d9;
  font-size: 0.95rem;
}

.preview {
  margin-top: 0.5rem;
  max-width: 100%;
  max-height: 180px;
  border-radius: 8px;
  object-fit: contain;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.error {
  color: #c62828;
  font-size: 0.85rem;
}

.hint {
  color: #6b7280;
  font-size: 0.85rem;
  margin-top: -0.5rem;
}

#lightbox {
  cursor: zoom-out;
}

#lightbox img {
  max-width: 95vw;
  max-height: 95vh;
  border-radius: 8px;
}
